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

59.1. 外部データラッパー関数 #

<title>Foreign Data Wrapper Functions</title>

The FDW author needs to implement a handler function, and optionally a validator function. Both functions must be written in a compiled language such as C, using the version-1 interface. For details on C language calling conventions and dynamic loading, see <xref linkend="xfunc-c"/>. FDWの作者は、ハンドラ関数と、オプションで検証関数を実装する必要があります。 両関数とも、version-1インタフェースを使用して、Cなどのコンパイル言語で作成しなければなりません。 C言語の呼び出し規約と動的ロードについては38.10を参照してください。

The handler function simply returns a struct of function pointers to callback functions that will be called by the planner, executor, and various maintenance commands. Most of the effort in writing an FDW is in implementing these callback functions. The handler function must be registered with <productname>PostgreSQL</productname> as taking no arguments and returning the special pseudo-type <type>fdw_handler</type>. The callback functions are plain C functions and are not visible or callable at the SQL level. The callback functions are described in <xref linkend="fdw-callbacks"/>. ハンドラ関数は単に、プランナやエグゼキュータ、様々なメンテナンスコマンドから呼び出されるコールバックの関数ポインタを含む構造体を返します。 FDWを作成するための労力のほとんどは、これらのコールバック関数を実装することに費やされます。 ハンドラ関数は、引数を取らず特殊な仮想型であるfdw_handlerを返す関数としてPostgreSQLに登録しなければなりません。 コールバック関数は通常のC言語関数で、SQLレベルでは参照も呼び出しもできません。コールバック関数の説明は59.2にあります。

The validator function is responsible for validating options given in <command>CREATE</command> and <command>ALTER</command> commands for its foreign data wrapper, as well as foreign servers, user mappings, and foreign tables using the wrapper. The validator function must be registered as taking two arguments, a text array containing the options to be validated, and an OID representing the type of object the options are associated with (in the form of the OID of the system catalog the object would be stored in, either <literal>ForeignDataWrapperRelationId</literal>, <literal>ForeignServerRelationId</literal>, <literal>UserMappingRelationId</literal>, or <literal>ForeignTableRelationId</literal>). If no validator function is supplied, options are not checked at object creation time or object alteration time. 検証関数は、そのラッパーを使用する外部サーバ、ユーザマッピング、外部テーブルだけでなく、外部データラッパー自身のCREATEALTERといったコマンドで指定されたオプションの妥当性の検証を担当します。 検証関数は、検証するオプションを含むtext配列と、オプションを関連付けるオブジェクトの種類を表すOID(そのオブジェクトが格納されるシステムカタログのOIDで次のいずれか、ForeignDataWrapperRelationIdForeignServerRelationIdUserMappingRelationIdForeignTableRelationId)という二つの引数を取るものとして登録しなければなりません。 検証関数が指定されなかった場合、オブジェクト作成時やオブジェクト変更時にオプションはチェックされません。