]> begriffs open source - ai-pg/blob - full-docs/txt/fdw-helpers.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / fdw-helpers.txt
1
2 58.3. Foreign Data Wrapper Helper Functions #
3
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.
10
11 ForeignDataWrapper *
12 GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);
13
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.
20
21 ForeignDataWrapper *
22 GetForeignDataWrapper(Oid fdwid);
23
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).
27
28 ForeignServer *
29 GetForeignServerExtended(Oid serverid, bits16 flags);
30
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.
37
38 ForeignServer *
39 GetForeignServer(Oid serverid);
40
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).
44
45 UserMapping *
46 GetUserMapping(Oid userid, Oid serverid);
47
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).
53
54 ForeignTable *
55 GetForeignTable(Oid relid);
56
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).
60
61 List *
62 GetForeignColumnOptions(Oid relid, AttrNumber attnum);
63
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.
67
68    Some object types have name-based lookup functions in addition to the
69    OID-based ones:
70
71 ForeignDataWrapper *
72 GetForeignDataWrapperByName(const char *name, bool missing_ok);
73
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.
77
78 ForeignServer *
79 GetForeignServerByName(const char *name, bool missing_ok);
80
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.