Postgresql 中文操作指南

Chapter 59. Writing a Foreign Data Wrapper

Table of Contents

外部表上的所有操作均通过其外部数据包装器来处理,该包装器由核心服务器调用的函数集组成。外部数据包装器负责从远程数据源获取数据并将其返回到 PostgreSQL 执行器。如果要支持更新外部表,包装器也必须处理此操作。本章概述了如何编写新的外部数据包装器。

All operations on a foreign table are handled through its foreign data wrapper, which consists of a set of functions that the core server calls. The foreign data wrapper is responsible for fetching data from the remote data source and returning it to the PostgreSQL executor. If updating foreign tables is to be supported, the wrapper must handle that, too. This chapter outlines how to write a new foreign data wrapper.

标准发行版中包含的外部数据包装器在尝试编写自己的包装器时是不错的参考。查看源代码树的 contrib 子目录。 CREATE FOREIGN DATA WRAPPER 参考页也有一些有用的细节。

The foreign data wrappers included in the standard distribution are good references when trying to write your own. Look into the contrib subdirectory of the source tree. The CREATE FOREIGN DATA WRAPPER reference page also has some useful details.

Note

SQL 标准指定了用于编写外部数据包装器的接口。然而,PostgreSQL 不实现该 API,因为将它纳入 PostgreSQL 所需的精力很大,并且该标准 API 并没有得到广泛采用。

The SQL standard specifies an interface for writing foreign data wrappers. However, PostgreSQL does not implement that API, because the effort to accommodate it into PostgreSQL would be large, and the standard API hasn’t gained wide adoption anyway.