]> begriffs open source - ai-pg/blob - full-docs/txt/fdw-functions.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / fdw-functions.txt
1
2 58.1. Foreign Data Wrapper Functions #
3
4    The FDW author needs to implement a handler function, and optionally a
5    validator function. Both functions must be written in a compiled
6    language such as C, using the version-1 interface. For details on C
7    language calling conventions and dynamic loading, see Section 36.10.
8
9    The handler function simply returns a struct of function pointers to
10    callback functions that will be called by the planner, executor, and
11    various maintenance commands. Most of the effort in writing an FDW is
12    in implementing these callback functions. The handler function must be
13    registered with PostgreSQL as taking no arguments and returning the
14    special pseudo-type fdw_handler. The callback functions are plain C
15    functions and are not visible or callable at the SQL level. The
16    callback functions are described in Section 58.2.
17
18    The validator function is responsible for validating options given in
19    CREATE and ALTER commands for its foreign data wrapper, as well as
20    foreign servers, user mappings, and foreign tables using the wrapper.
21    The validator function must be registered as taking two arguments, a
22    text array containing the options to be validated, and an OID
23    representing the type of object the options are associated with. The
24    latter corresponds to the OID of the system catalog the object would be
25    stored in, one of:
26      * AttributeRelationId
27      * ForeignDataWrapperRelationId
28      * ForeignServerRelationId
29      * ForeignTableRelationId
30      * UserMappingRelationId
31
32    If no validator function is supplied, options are not checked at object
33    creation time or object alteration time.