SPI_saveplan

Name

SPI_saveplan --  Saves a passed plan 渡された計画を保存します。

Synopsis

SPI_saveplan(plan)

入力

void *query

Passed plan

渡された計画。

出力

void *

Execution plan location. NULL if unsuccessful.

実行計画の保存場所。失敗の場合は NULL。

SPI_result

SPI_ERROR_ARGUMENT if plan is NULL
SPI_ERROR_ARGUMENT 引数 plan が NULL の場合。
SPI_ERROR_UNCONNECTED if procedure is un-connected
SPI_ERROR_UNCONNECTED 未接続プロシージャの場合。

説明

SPI_saveplan stores a plan prepared by SPI_prepare in safe memory protected from freeing by SPI_finish or the transaction manager.

SPI_saveplan は、SPI_prepare によって作成された計画を SPI_finish やトランザクションマネージャによっ て行なわれるメモリの開放の影響を受けない安全なメモリ領域に保存しま す。

In the current version of Postgres there is no ability to store prepared plans in the system catalog and fetch them from there for execution. This will be implemented in future versions. As an alternative, there is the ability to reuse prepared plans in the consequent invocations of your procedure in the current session. Use SPI_execp to execute this saved plan.

現状の Postgres では、準備済み計画をシス テムカタログに保存しておき、実行時にそれを取り出すといった機能はあり ません。この機能は将来実装されるでしょう。 代わりに、同じセッションの中で、後から起動されるプロシージャが準備済 み計画を再利用する機能はあります。この保存された計画を実行するには、 SPI_execp を使用して下さい。

使い方

SPI_saveplan saves a passed plan (prepared by SPI_prepare) in memory protected from freeing by SPI_finish and by the transaction manager and returns a pointer to the saved plan. You may save the pointer returned in a local variable. Always check if this pointer is NULL or not either when preparing a plan or using an already prepared plan in SPI_execp (see below).

SPI_saveplan は( SPI_prepare によって準備され)渡された計画を SPI_finish やトランザクションマネージャによっ て行なわれるメモリの開放の影響を受けない安全なメモリ領域に保存し、 その保存した計画を示すポインタを返します。返されたポインタをローカ ル変数に保存することもできます。計画を準備する時や(後述の) SPI_execp で既存の準備済み計画を使用する時は、常にこのポインタが NULL かどうかを点検して下さい。

Note: If one of the objects (a relation, function, etc.) referenced by the prepared plan is dropped during your session (by your backend or another process) then the results of SPI_execp for this plan will be unpredictable.

セッション中に準備済み計画が参照する(リレーション、関数などの)オブ ジェクトが 1 つでも(バックエンドや他のプロセスによって)削除されると、 この計画を使った SPI_execp の結果は予測できない ものになります。