SPI_RETURNTUPLE(3)
β¨ bestie's guide to SPI_RETURNTUPLE(3) β PostgreSQL 14.24 Documentation β¨
okay so you're looking at the SPI_RETURNTUPLE(3) page from the PostgreSQL 14.24 docs, and it's giving tiny but crucial C API moment. No cap, we're keeping every detail, every caveat, every crumb. π
π NAME π
SPI_returntupleβ prepare to return a tuple as aDatum.
π SYNOPSIS π
HeapTupleHeader SPI_returntuple(HeapTuple row, TupleDesc rowdesc)
π DESCRIPTION π
So here's the vibe: 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. That's it. That's the whole assignment. β¨
This function can only be used while connected to SPI. Otherwise, it returns NULL and sets SPI_result to SPI_ERROR_UNCONNECTED. Vibe check: connected or it ghosts you. π
π«Ά 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. Periodt.
π¦ 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 pointing to copied row, or NULL on error (see SPI_result for an error indication), bestie.
π That's the whole page, babe β brought to you by PostgreSQL 14.24, dated 2026, and filed under SPI_RETURNTUPLE(3). Mwah π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14-docs 14.24-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