SPI_modifytuple <refpurpose>create a row by replacing selected fields of a given row</refpurpose> — 与えられた行の選択フィールドを置き換えた行を作成する
HeapTuple SPI_modifytuple(Relationrel, HeapTuplerow, intncols, int *colnum, Datum *values, const char *nulls)
<function>SPI_modifytuple</function> creates a new row by
substituting new values for selected columns, copying the original
row's columns at other positions. The input row is not modified.
The new row is returned in the upper executor context.
SPI_modifytupleは、選択された列は新しい値で置き換え、その他の位置は元の行の列をコピーした、新しい行を作成します。
入力行は変更されません。
新しい行は上位エグゼキュータコンテキスト内に返されます。
This function can only be used while connected to SPI.
Otherwise, it returns NULL and sets <varname>SPI_result</varname> to
<symbol>SPI_ERROR_UNCONNECTED</symbol>.
この関数はSPIに接続されている間にのみ使うことができます。
それ以外の場合はNULLを返し、SPI_resultをSPI_ERROR_UNCONNECTEDにセットします。
Relation relUsed only as the source of the row descriptor for the row. (Passing a relation rather than a row descriptor is a misfeature.) 行の行記述子のソースとしてのみ使用されます。 (行記述子ではなくリレーションを渡すことは設計ミスです。)
HeapTuple rowrow to be modified 変更される行
int ncolsnumber of columns to be changed 変更された列数
int * colnum
an array of length <parameter>ncols</parameter>, containing the numbers
of the columns that are to be changed (column numbers start at 1)
変更される列番号を含む、ncols長の配列(列番号は1から始まります)
Datum * values
an array of length <parameter>ncols</parameter>, containing the
new values for the specified columns
指定された列の新しい値を含む、ncols長の配列
const char * nulls
an array of length <parameter>ncols</parameter>, describing which
new values are null
新しい値のどれがNULLかを記述する、ncols長の配列
If <parameter>nulls</parameter> is <symbol>NULL</symbol> then
<function>SPI_modifytuple</function> assumes that no new values
are null. Otherwise, each entry of the <parameter>nulls</parameter>
array should be <literal>' '</literal> if the corresponding new value is
non-null, or <literal>'n'</literal> if the corresponding new value is
null. (In the latter case, the actual value in the corresponding
<parameter>values</parameter> entry doesn't matter.) Note that
<parameter>nulls</parameter> is not a text string, just an array: it
does not need a <literal>'\0'</literal> terminator.
nullsがNULLであれば、SPI_modifytupleはどの新しい値もnullでないとみなします。
さもなければ、nulls配列の各項目は、対応するパラメータが非NULLならば' '、対応するパラメータがNULLならば'n'です。
(後者の場合、values内の対応する値は注意されません。)
nullsはテキスト文字列ではなく単なる配列であることに注意してください。
'\0'終端は必要ありません。
new row with modifications, allocated in the upper executor
context, or <symbol>NULL</symbol> on error
(see <varname>SPI_result</varname> for an error indication)
変更された新しい行。上位エグゼキュータコンテキストに割り当てられます。
エラー時はNULLです。
(エラーの表示についてはSPI_resultを参照してください)
On error, <varname>SPI_result</varname> is set as follows:
エラー時、SPI_resultが以下のように設定されます。
SPI_ERROR_ARGUMENT
if <parameter>rel</parameter> is <symbol>NULL</symbol>, or if
<parameter>row</parameter> is <symbol>NULL</symbol>, or if <parameter>ncols</parameter>
is less than or equal to 0, or if <parameter>colnum</parameter> is
<symbol>NULL</symbol>, or if <parameter>values</parameter> is <symbol>NULL</symbol>.
relがNULLの場合、rowがNULLの場合、ncolsが0以下の場合、colnumがNULLの場合、valuesがNULLの場合。
SPI_ERROR_NOATTRIBUTE
if <parameter>colnum</parameter> contains an invalid column number (less
than or equal to 0 or greater than the number of columns in
<parameter>row</parameter>)
colnumが無効な列番号を持つ場合
(0以下、rowの列数以上)
SPI_ERROR_UNCONNECTEDif SPI is not active SPIが動作していない場合