Redrock Postgres Search Chinese
Version: 9.3 / 9.4 / 9.5 / 9.6 / 10 / 11 / 12 / 13 / 14 / 15 / 16 / 17

Chapter 57. Writing A Foreign Data Wrapper

Table of Contents

57.1. Foreign Data Wrapper Functions
57.2. Foreign Data Wrapper Callback Routines
57.2.1. FDW Routines For Scanning Foreign Tables
57.2.2. FDW Routines For Scanning Foreign Joins
57.2.3. FDW Routines For Planning Post-Scan/Join Processing
57.2.4. FDW Routines For Updating Foreign Tables
57.2.5. FDW Routines For Row Locking
57.2.6. FDW Routines for EXPLAIN
57.2.7. FDW Routines for ANALYZE
57.2.8. FDW Routines For IMPORT FOREIGN SCHEMA
57.2.9. FDW Routines for Parallel Execution
57.2.10. FDW Routines For reparameterization of paths
57.3. Foreign Data Wrapper Helper Functions
57.4. Foreign Data Wrapper Query Planning
57.5. Row Locking in Foreign Data Wrappers

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.

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

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.