Postgresql 中文操作指南

SPI_returntuple

SPI_returntuple - 准备将元组作为 Datum 返回

SPI_returntuple — prepare to return a tuple as a Datum

Synopsis

HeapTupleHeader SPI_returntuple(HeapTuple row, TupleDesc rowdesc)

Description

SPI_returntuple 复制上层执行程序上下文中的行,以行类型 Datum 的形式返回它。无需转换返回的指针,只要通过 PointerGetDatum 将其转换为 Datum ,然后返回即可。

SPI_returntuple makes a copy of a row in the upper executor context, returning it in the form of a row type Datum. The returned pointer need only be converted to Datum via PointerGetDatum before returning.

此函数只能在连接到 SPI 时使用。否则,返回 NULL,并将 SPI_result 设置为 SPI_ERROR_UNCONNECTED

This function can only be used while connected to SPI. Otherwise, it returns NULL and sets SPI_result to SPI_ERROR_UNCONNECTED.

请注意,此操作应用于声明为返回复合类型的功能。它不用于触发器;对于在触发器中返回已修改的行,请使用 SPI_copytuple

Note that this should be used for functions that are declared to return composite types. It is not used for triggers; use SPI_copytuple for returning a modified row in a trigger.

Arguments

  • HeapTuple _row_

    • row to be copied

  • TupleDesc _rowdesc_

    • descriptor for row (pass the same descriptor each time for most effective caching)

Return Value

HeapTupleHeader 指向已复制的行,或在出错时指向 NULL (请参见 SPI_result 以获取错误指示)

HeapTupleHeader pointing to copied row, or NULL on error (see SPI_result for an error indication)