SPI_RETURNTUPLE(3)
β¨ SPI_RETURNTUPLE(3) β¨
okay so bestie, welcome to SPI_RETURNTUPLE(3) β thatβs the manual name, and this is the PostgreSQL 13.23 Documentation version. weβre about to make a tuple-returning Datum moment happen π
πΈ NAME πΈ
SPI_returntuple β prepare to return a tuple as a Datum. simple, iconic, does what it says π
π¦ SYNOPSIS π¦
HeapTupleHeader SPI_returntuple(HeapTuple row, TupleDesc rowdesc)
π DESCRIPTION π
SPI_returntuple makes a copy of a row in the upper executor context, and returns it in the form of a row type Datum. the returned pointer only needs to be converted to Datum via PointerGetDatum before returning. slay β¨
this function can only be used while connected to SPI. otherwise, it returns NULL and sets SPI_result to SPI_ERROR_UNCONNECTED. so yeah, no SPI connection = no tuple, bestie π
note that this should be used for functions that are declared to return composite types. it is not used for triggers; for returning a modified row in a trigger, use SPI_copytuple instead. important vibe check π«Ά
π ARGUMENTS π
HeapTuple rowβ the row to be copied. literally the row.TupleDesc rowdescβ descriptor forrow. pass the same descriptor each time for most effective caching. iykyk π
π RETURN VALUE π
HeapTupleHeader pointing to the copied row, or NULL on error. for an error indication, see SPI_result. thatβs the whole tea π
okay thatβs the page, bestie π«Ά stay connected to SPI, convert with PointerGetDatum, and donβt use this for triggers β use SPI_copytuple, periodt. xoxo, PostgreSQL 13.23, 2025 ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13-docs 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms