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

SPI_execute_plan_extended

SPI_execute_plan_extended <refpurpose>execute a statement prepared by <function>SPI_prepare</function></refpurpose> SPI_prepareで準備された文を実行する

概要

int SPI_execute_plan_extended(SPIPlanPtr plan,
                              const SPIExecuteOptions * options)

説明

<title>Description</title>

<function>SPI_execute_plan_extended</function> executes a statement prepared by <function>SPI_prepare</function> or one of its siblings. This function is equivalent to <function>SPI_execute_plan</function>, except that information about the parameter values to be passed to the query is presented differently, and additional execution-controlling options can be passed. SPI_execute_plan_extendedSPI_prepareもしくは類似の関数で準備された文を実行します。 この関数は、問い合わせに渡すパラメータ値に関する情報が異なる形で存在する点と追加の実行制御オプションを渡せる点を除いてSPI_execute_planと等価です。

Query parameter values are represented by a <literal>ParamListInfo</literal> struct, which is convenient for passing down values that are already available in that format. Dynamic parameter sets can also be used, via hook functions specified in <literal>ParamListInfo</literal>. 問い合わせパラメータ値はParamListInfo構造体で表現されていますので、既にその形で利用可能な値を渡すには便利です。 ParamListInfoで指定されたフック関数経由で、動的なパラメータ群も使うことができます。

Also, instead of always accumulating the result tuples into a <varname>SPI_tuptable</varname> structure, tuples can be passed to a caller-supplied <literal>DestReceiver</literal> object as they are generated by the executor. This is particularly helpful for queries that might generate many tuples, since the data can be processed on-the-fly instead of being accumulated in memory. また、結果タプルを必ずSPI_tuptable構造体に蓄積する代わりに、エグゼキュータにより生成された時にタプルを呼び出し元が提供するDestReceiverオブジェクトに渡すことができます。 データがメモリに蓄積される代わりにその場で処理されるので、多数のタプルを生成する問い合わせに対して特に有用です。

引数

<title>Arguments</title>
SPIPlanPtr plan

prepared statement (returned by <function>SPI_prepare</function>) SPI_prepareで返される)準備済み文

const SPIExecuteOptions * options

struct containing optional arguments オプションの引数を含む構造体

Callers should always zero out the entire <parameter>options</parameter> struct, then fill whichever fields they want to set. This ensures forward compatibility of code, since any fields that are added to the struct in future will be defined to behave backwards-compatibly if they are zero. The currently available <parameter>options</parameter> fields are: 呼び出し元は、必ずoptions構造体全体をゼロクリアしてから、設定したいフィールドを埋めるべきです。 構造体に将来追加されるフィールドは、ゼロであれば後方互換性があるように振る舞うよう定義されますので、これはコードの将来の互換性を確実にします。 現在利用可能なoptionsフィールドは以下の通りです。

ParamListInfo params

data structure containing query parameter types and values; NULL if none 問い合わせパラメータの型と値を含むデータ構造。なければNULL

bool read_only
<para><literal>true</literal> for read-only execution</para>

読み取りのみの実行の場合true

bool allow_nonatomic

<literal>true</literal> allows non-atomic execution of CALL and DO statements trueでCALLとDO文の非原子的実行を許可します

bool must_return_tuples

if <literal>true</literal>, raise error if the query is not of a kind that returns tuples (this does not forbid the case where it happens to return zero tuples) trueであれば、問い合わせがタプルを返す種類のものでない場合にエラーを発生します(これはたまたま0個のタプルを返す場合を禁止しません)

uint64 tcount

maximum number of rows to return, or <literal>0</literal> for no limit 返される行の最大数、無制限の場合には0

DestReceiver * dest

<literal>DestReceiver</literal> object that will receive any tuples emitted by the query; if NULL, result tuples are accumulated into a <varname>SPI_tuptable</varname> structure, as in <function>SPI_execute_plan</function> 問い合わせが出すタプルを受け取るDestReceiverオブジェクト。 NULLなら、SPI_execute_planのように、結果タプルはSPI_tuptable構造体に蓄積されます。

ResourceOwner owner

The resource owner that will hold a reference count on the plan while it is executed. If NULL, CurrentResourceOwner is used. Ignored for non-saved plans, as SPI does not acquire reference counts on those. 実行中、計画の参照カウントを保持するリソース所有者。 NULLならCurrentResourceOwnerが使われます。 SPIは保存されない計画の参照カウントを取得しませんので、保存されない計画に対しては無視されます。

戻り値

<title>Return Value</title>

The return value is the same as for <function>SPI_execute_plan</function>. 戻り値はSPI_execute_planと同じです。

When <parameter>options-&gt;dest</parameter> is NULL, <varname>SPI_processed</varname> and <varname>SPI_tuptable</varname> are set as in <function>SPI_execute_plan</function>. When <parameter>options-&gt;dest</parameter> is not NULL, <varname>SPI_processed</varname> is set to zero and <varname>SPI_tuptable</varname> is set to NULL. If a tuple count is required, the caller's <literal>DestReceiver</literal> object must calculate it. options->destがNULLであれば、SPI_processedSPI_tuptableSPI_execute_planと同様に設定されます。 options->destがNULLでなければ、SPI_processedはゼロに設定され、SPI_tuptableはNULLに設定されます。 タプルの集計が必要なら、呼び出し元のDestReceiverオブジェクトが計算しなければなりません。