113) Postgres provides a fast path interface to send function calls to the backend. This is a trapdoor into system internals and can be a potential security hole. Most users will not need this feature.
Postgres は, バックエンドへの関数呼び出しインターフェースに近道を用意しています. これはシステム内部への抜け穴であると同時に, 潜在的なセキュリティホールにもなり得ます. 大多数のユーザの人はこの機能を必要とはしないでしょう.
PQfn 114) Request execution of a backend function via the fast path interface. 「近道」を使ってバックエンドの関数実行を要求します.
PGresult* PQfn(PGconn* conn, int fnid, int *result_buf, int *result_len, int result_is_int, PQArgBlock *args, int nargs);115) The fnid argument is the object identifier of the function to be executed. result_buf is the buffer in which to place the return value. The caller must have allocated sufficient space to store the return value (there is no check!). The actual result length will be returned in the integer pointed to by result_len. If a 4-byte integer result is expected, set result_is_int to 1; otherwise set it to 0. (Setting result_is_int to 1 tells libpq to byte-swap the value if necessary, so that it is delivered as a proper int value for the client machine. When result_is_int is 0, the byte string sent by the backend is returned unmodified.) args and nargs specify the arguments to be passed to the function. このうち fnid 引数は,実行する関数のオブジェクト識別子, result_buf は戻り値を格納するバッファです. 呼び出し側は戻り値を格納するのに十分な領域を確保しておかなければなりません. (このチェックは(ライブラリ側では)していません!) 結果の実データ長は result_len が指す整数で返されます. 結果が 4 バイト整数だと想定できるなら result_is_int を 1 に, そうでなければ 0 を設定します. (result_is_int を 1 にすれば,必要に応じて値のバイト順を入れ換えるよう libpq に指示することになります. そしてクライアントマシン上で正しい整数値となるように転送します. result_is_int が 0 の場合は, バックエンドが送ったバイト列を何も修正せずに返します) args と nargs は関数に渡す引数を指定します.
typedef struct { int len; int isint; union { int *ptr; int integer; } u; } PQArgBlock;116) PQfn always returns a valid PGresult*. The resultStatus should be checked before the result is used. The caller is responsible for freeing the PGresult with PQclear when it is no longer needed. PQfn は常に有効な PGresult ポインタを返します. 結果を使う前にはまず,resultStatus を調べておくべきでしょう. 結果が必要なくなった時点で, PQclear によって PGresult を開放するのは呼び出し側の責任です.