バージョンごとのドキュメント一覧

59.3. 外部データラッパーヘルパ関数 #

<title>Foreign Data Wrapper Helper Functions</title>

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 file <filename>foreign/foreign.h</filename> in your source file. That header also defines the struct types that are returned by these functions. FDWオプションのようなFDW関連オブジェクトの属性に外部データラッパーの作者が簡単にアクセスできるように、いくつかのヘルパ関数がコアサーバからエクスポートされています。 これらの関数を使用するには、ヘッダファイルforeign/foreign.hをあなたのソースファイルにインクルードする必要があります。 このヘッダはまたこれらの関数が返す構造体も定義しています。

ForeignDataWrapper *
GetForeignDataWrapperExtended(Oid fdwid, bits16 flags);

This function returns a <structname>ForeignDataWrapper</structname> object for the foreign-data wrapper with the given OID. A <structname>ForeignDataWrapper</structname> object contains properties of the FDW (see <filename>foreign/foreign.h</filename> for details). <structfield>flags</structfield> is a bitwise-or'd bit mask indicating an extra set of options. It can take the value <literal>FDW_MISSING_OK</literal>, in which case a <literal>NULL</literal> result is returned to the caller instead of an error for an undefined object. この関数は、与えられたOIDの外部データラッパーに対してForeignDataWrapperオブジェクトを返します。 ForeignDataWrapperオブジェクトにはFDWの属性(詳しくはforeign/foreign.hを参照)が含まれます。 flags は追加的なオプション一式を示すビット毎にorを取ったビットマスクです。 ここにはFDW_MISSING_OK値を指定できて、この場合、未定義オブジェクトに対するエラーの代わりに呼び出し元にNULL結果が返されます。

ForeignDataWrapper *
GetForeignDataWrapper(Oid fdwid);

This function returns a <structname>ForeignDataWrapper</structname> object for the foreign-data wrapper with the given OID. A <structname>ForeignDataWrapper</structname> object contains properties of the FDW (see <filename>foreign/foreign.h</filename> for details). この関数は指定されたOIDを持つ外部データラッパーのForeignDataWrapperオブジェクトを返します。ForeignDataWrapperオブジェクトはFDWのプロパティを含みます(詳細はforeign/foreign.hを参照して下さい)。

ForeignServer *
GetForeignServerExtended(Oid serverid, bits16 flags);

This function returns a <structname>ForeignServer</structname> object for the foreign server with the given OID. A <structname>ForeignServer</structname> object contains properties of the server (see <filename>foreign/foreign.h</filename> for details). <structfield>flags</structfield> is a bitwise-or'd bit mask indicating an extra set of options. It can take the value <literal>FSV_MISSING_OK</literal>, in which case a <literal>NULL</literal> result is returned to the caller instead of an error for an undefined object. この関数は、与えられたOIDの外部サーバに対してForeignServerオブジェクトを返します。 ForeignServerオブジェクトにはサーバの属性(詳しくはforeign/foreign.hを参照)が含まれます。 flagsは追加的なオプション一式を示すビット毎にorを取ったビットマスクです。 ここにはFSV_MISSING_OK値を指定できて、この場合、未定義オブジェクトに対するエラーの代わりに呼び出し元にNULL結果が返されます。

ForeignServer *
GetForeignServer(Oid serverid);

This function returns a <structname>ForeignServer</structname> object for the foreign server with the given OID. A <structname>ForeignServer</structname> object contains properties of the server (see <filename>foreign/foreign.h</filename> for details). この関数は指定されたOIDを持つ外部サーバのForeignServerオブジェクトを返します。ForeignServerオブジェクトは外部サーバのプロパティを含みます(詳細はforeign/foreign.hを参照して下さい)。

UserMapping *
GetUserMapping(Oid userid, Oid serverid);

This function returns a <structname>UserMapping</structname> 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 for <literal>PUBLIC</literal>, or throw error if there is none.) A <structname>UserMapping</structname> object contains properties of the user mapping (see <filename>foreign/foreign.h</filename> for details). この関数は指定されたロールと指定された外部サーバのユーザマッピングのUserMappingオブジェクトを返します。(もし特定のユーザのマッピングがない場合は、PUBLICのためのマッピングを返すか、それもなければエラーを発生させます。) UserMappingオブジェクトはユーザマッピングのプロパティを含みます(詳細はforeign/foreign.hを参照して下さい)。

ForeignTable *
GetForeignTable(Oid relid);

This function returns a <structname>ForeignTable</structname> object for the foreign table with the given OID. A <structname>ForeignTable</structname> object contains properties of the foreign table (see <filename>foreign/foreign.h</filename> for details). この関数は指定されたOIDを持つ外部テーブルのForeignTableオブジェクトを返します。ForeignTableオブジェクトは外部テーブルのプロパティを含みます(詳細はforeign/foreign.hを参照して下さい)。

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 of <structname>DefElem</structname>. NIL is returned if the column has no options. この関数は指定された外部テーブルOIDと属性番号に該当する列の列単位のFDWオプションをDefElemのリスト形式で返します。その列がオプションを持たない場合はNILが返ります。

Some object types have name-based lookup functions in addition to the OID-based ones: いくつかのオブジェクト種別については、OIDベースのものに加えて名前ベースの検索関数もあります。

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

This function returns a <structname>ForeignDataWrapper</structname> 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. この関数は指定された名前の外部データラッパーのForeignDataWrapperオブジェクトを返します。外部データラッパーが見つからない場合は、missing_okがtrueの場合はNULLを返し、それ以外の場合はエラーを発生させます。

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

This function returns a <structname>ForeignServer</structname> 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. この関数は指定された名前の外部サーバのForeignServerオブジェクトを返します。外部サーバが見つからない場合は、missing_okがtrueの場合はNULLを返し、それ以外の場合はエラーを発生させます。