SPI_finish

Name

SPI_finish --  Disconnects your procedure from the SPI manager. ユーザ定義のプロシージャを SPI マネージャから切断します。

Synopsis

SPI_finish(void)

入力

なし。

出力

int

SPI_OK_FINISH if properly disconnected 正常に切断された場合。
SPI_ERROR_UNCONNECTED if called from an un-connected procedure 未接続のプロシージャから呼び出された場合。

説明

SPI_finish closes an existing connection to the Postgres backend. You should call this function after completing operations through the SPI manager.

SPI_finish は既存の Postgres バックエンドへの接続を閉じます。 SPI マネージャを使った操作を終了した後にはこの関数を呼び出して下さい。

You may get the error return SPI_ERROR_UNCONNECTED if SPI_finish is called without having a current valid connection. There is no fundamental problem with this; it means that nothing was done by the SPI manager.

有効な接続が存在しない状態で SPI_finish が呼 び出された場合、SPI_ERROR_UNCONNECTED というエラーが返ります。このエラーコードについては特に問題はありま せん。これは SPI マネージャが何も行なわなかったということを意味し ています。

使い方

SPI_finish must be called as a final step by a connected procedure or you may get unpredictable results! Note that you can safely skip the call to SPI_finish if you abort the transaction (via elog(ERROR)).

SPI_finish必ず 接続し たプロシージャの最後の段階で呼び出されなければなりません。さもないと、 予測できない結果が起きるかもしれません!( elog(ERROR) を使って)ト ランザクションを中断した場合は、SPI_finish の呼 び出しを省略しても問題がないことに注意して下さい。

アルゴリズム

SPI_finish は以下を行ないます。

Disconnects your procedure from the SPI manager and frees all memory allocations made by your procedure via palloc since the SPI_connect. These allocations can't be used any more! See Memory management.

ユーザ定義のプロシージャを SPI マネージャから切断し、 SPI_connect を実行してからそのプロシージャが palloc を使用して獲得したメモリを全て開放しま す。このメモリはもはや使用できません!メモリ管理の項を参照して下さ い。