2 58.3. Foreign Data Wrapper Helper Functions #
4 Several helper functions are exported from the core server so that
5 authors of foreign data wrappers can get easy access to attributes of
6 FDW-related objects, such as FDW options. To use any of these
7 functions, you need to include the header file foreign/foreign.h in
8 your source file. That header also defines the struct types that are
9 returned by these functions.
12 GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
14 This function returns a ForeignDataWrapper object for the foreign-data
15 wrapper with the given OID. A ForeignDataWrapper object contains
16 properties of the FDW (see foreign/foreign.h for details). flags is a
17 bitwise-or'd bit mask indicating an extra set of options. It can take
18 the value FDW_MISSING_OK, in which case a NULL result is returned to
19 the caller instead of an error for an undefined object.
22 GetForeignDataWrapper(Oid fdwid);
24 This function returns a ForeignDataWrapper object for the foreign-data
25 wrapper with the given OID. A ForeignDataWrapper object contains
26 properties of the FDW (see foreign/foreign.h for details).
29 GetForeignServerExtended(Oid serverid, bits16 flags);
31 This function returns a ForeignServer object for the foreign server
32 with the given OID. A ForeignServer object contains properties of the
33 server (see foreign/foreign.h for details). flags is a bitwise-or'd bit
34 mask indicating an extra set of options. It can take the value
35 FSV_MISSING_OK, in which case a NULL result is returned to the caller
36 instead of an error for an undefined object.
39 GetForeignServer(Oid serverid);
41 This function returns a ForeignServer object for the foreign server
42 with the given OID. A ForeignServer object contains properties of the
43 server (see foreign/foreign.h for details).
46 GetUserMapping(Oid userid, Oid serverid);
48 This function returns a UserMapping object for the user mapping of the
49 given role on the given server. (If there is no mapping for the
50 specific user, it will return the mapping for PUBLIC, or throw error if
51 there is none.) A UserMapping object contains properties of the user
52 mapping (see foreign/foreign.h for details).
55 GetForeignTable(Oid relid);
57 This function returns a ForeignTable object for the foreign table with
58 the given OID. A ForeignTable object contains properties of the foreign
59 table (see foreign/foreign.h for details).
62 GetForeignColumnOptions(Oid relid, AttrNumber attnum);
64 This function returns the per-column FDW options for the column with
65 the given foreign table OID and attribute number, in the form of a list
66 of DefElem. NIL is returned if the column has no options.
68 Some object types have name-based lookup functions in addition to the
72 GetForeignDataWrapperByName(const char *name, bool missing_ok);
74 This function returns a ForeignDataWrapper object for the foreign-data
75 wrapper with the given name. If the wrapper is not found, return NULL
76 if missing_ok is true, otherwise raise an error.
79 GetForeignServerByName(const char *name, bool missing_ok);
81 This function returns a ForeignServer object for the foreign server
82 with the given name. If the server is not found, return NULL if
83 missing_ok is true, otherwise raise an error.