Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
59.3. Foreign Data Wrapper Helper Functions
Prev UpChapter 59. Writing a Foreign Data WrapperHome Next

59.3. Foreign Data Wrapper Helper Functions#

Several helper functions are exported from the core server so that authors of foreign data wrappers can get easy access to attributes of FDW-related objects, such as FDW options. To use any of these functions, you need to include the header fileforeign/foreign.h in your source file. That header also defines the struct types that are returned by these functions.

ForeignDataWrapper *GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);

This function returns aForeignDataWrapper object for the foreign-data wrapper with the given OID. AForeignDataWrapper object contains properties of the FDW (seeforeign/foreign.h for details).flags is a bitwise-or'd bit mask indicating an extra set of options. It can take the valueFDW_MISSING_OK, in which case aNULL result is returned to the caller instead of an error for an undefined object.

ForeignDataWrapper *GetForeignDataWrapper(Oid fdwid);

This function returns aForeignDataWrapper object for the foreign-data wrapper with the given OID. AForeignDataWrapper object contains properties of the FDW (seeforeign/foreign.h for details).

ForeignServer *GetForeignServerExtended(Oid serverid, bits16 flags);

This function returns aForeignServer object for the foreign server with the given OID. AForeignServer object contains properties of the server (seeforeign/foreign.h for details).flags is a bitwise-or'd bit mask indicating an extra set of options. It can take the valueFSV_MISSING_OK, in which case aNULL result is returned to the caller instead of an error for an undefined object.

ForeignServer *GetForeignServer(Oid serverid);

This function returns aForeignServer object for the foreign server with the given OID. AForeignServer object contains properties of the server (seeforeign/foreign.h for details).

UserMapping *GetUserMapping(Oid userid, Oid serverid);

This function returns aUserMapping object for the user mapping of the given role on the given server. (If there is no mapping for the specific user, it will return the mapping forPUBLIC, or throw error if there is none.) AUserMapping object contains properties of the user mapping (seeforeign/foreign.h for details).

ForeignTable *GetForeignTable(Oid relid);

This function returns aForeignTable object for the foreign table with the given OID. AForeignTable object contains properties of the foreign table (seeforeign/foreign.h for details).

List *GetForeignColumnOptions(Oid relid, AttrNumber attnum);

This function returns the per-column FDW options for the column with the given foreign table OID and attribute number, in the form of a list ofDefElem. NIL is returned if the column has no options.

Some object types have name-based lookup functions in addition to the OID-based ones:

ForeignDataWrapper *GetForeignDataWrapperByName(const char *name, bool missing_ok);

This function returns aForeignDataWrapper object for the foreign-data wrapper with the given name. If the wrapper is not found, return NULL if missing_ok is true, otherwise raise an error.

ForeignServer *GetForeignServerByName(const char *name, bool missing_ok);

This function returns aForeignServer object for the foreign server with the given name. If the server is not found, return NULL if missing_ok is true, otherwise raise an error.


Prev Up Next
59.2. Foreign Data Wrapper Callback Routines Home 59.4. Foreign Data Wrapper Query Planning
pdfepub
Go to PostgreSQL 16
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp