SPI_RETURNTUPLE(3)
π SPI_RETURNTUPLE(3) β PostgreSQL SPI but make it cute π
okay bestie, this is the SPI_RETURNTUPLE(3) page from the PostgreSQL 17.11 Documentation, and we're gonna get you comfy with it fr fr. It's giving βprepare to return a tuple as a Datumβ energy, and yes, every detail is staying. π
πΈ 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 β that's literally it, no extra steps, no cap.
This function can only be used while connected to SPI. Otherwise, it returns NULL and sets SPI_result to SPI_ERROR_UNCONNECTED β so yeah, vibe check the connection first. π
Also note: this is the one for functions 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, bestie.TupleDesc rowdescβ descriptor forrow(pass the same descriptor each time for most effective caching β¨).
π₯ RETURN VALUE π₯
A HeapTupleHeader pointing to the copied row, or NULL on error (see SPI_result for an error indication). Like, if it's NULL, go check SPI_result, iykyk. π
That's the whole page, mwah π β source/version: PostgreSQL 17.11, date: 2026 π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17-docs 17.11-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