SPI_RETURNTUPLE(3)
π SPI_RETURNTUPLE(3) π
okay so bestie, this is the PostgreSQL 15.19 Documentation page for SPI_returntuple, and we're about to make returning a tuple as a Datum make sense. no cap. β¨
π NAME π
SPI_returntuple β prepare to return a tuple as a Datum
β¨ SYNOPSIS β¨
HeapTupleHeader SPI_returntuple(HeapTuple row, TupleDesc rowdesc)
π DESCRIPTION π
So 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. literally that's the whole vibe. π¦
Important vibe check: this function can only be used while connected to SPI. Otherwise, it returns NULL and sets SPI_result to SPI_ERROR_UNCONNECTED. not me finding out the hard way π
Also note: 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. periodt. π
πΈ ARGUMENTS πΈ
HeapTuple rowβ the row to be copied. yes bestie, that row right there.TupleDesc rowdescβ descriptor forrow(pass the same descriptor each time for most effective caching). lowkey important for that caching slay. π
π«Ά RETURN VALUE π«Ά
A HeapTupleHeader pointing to the copied row, or NULL on error (see SPI_result for an error indication). if it's NULL, go check SPI_result, iykyk. π
π xoxo, your PostgreSQL 15.19 bestie β page dated 2026, signing off with SPI_RETURNTUPLE(3) energy. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15-docs 15.19-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