Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
SPI_modifytuple
Prev Up45.3. Memory ManagementHome Next

SPI_modifytuple

SPI_modifytuple — create a row by replacing selected fields of a given row

Synopsis

HeapTuple SPI_modifytuple(Relationrel, HeapTuplerow, intncols,                          int *colnum, Datum *values, const char *nulls)

Description

SPI_modifytuple 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.

This function can only be used while connected to SPI. Otherwise, it returns NULL and setsSPI_result toSPI_ERROR_UNCONNECTED.

Arguments

Relationrel

Used only as the source of the row descriptor for the row. (Passing a relation rather than a row descriptor is a misfeature.)

HeapTuplerow

row to be modified

intncols

number of columns to be changed

int *colnum

an array of lengthncols, containing the numbers of the columns that are to be changed (column numbers start at 1)

Datum *values

an array of lengthncols, containing the new values for the specified columns

const char *nulls

an array of lengthncols, describing which new values are null

Ifnulls isNULL thenSPI_modifytuple assumes that no new values are null. Otherwise, each entry of thenulls array should be' ' if the corresponding new value is non-null, or'n' if the corresponding new value is null. (In the latter case, the actual value in the correspondingvalues entry doesn't matter.) Note thatnulls is not a text string, just an array: it does not need a'\0' terminator.

Return Value

new row with modifications, allocated in the upper executor context, orNULL on error (seeSPI_result for an error indication)

On error,SPI_result is set as follows:

SPI_ERROR_ARGUMENT

ifrel isNULL, or ifrow isNULL, or ifncols is less than or equal to 0, or ifcolnum isNULL, or ifvalues isNULL.

SPI_ERROR_NOATTRIBUTE

ifcolnum contains an invalid column number (less than or equal to 0 or greater than the number of columns inrow)

SPI_ERROR_UNCONNECTED

if SPI is not active


Prev Up Next
SPI_returntuple Home SPI_freetuple
pdfepub
Go to PostgreSQL 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp