SPI_RETURNTUPLE(3)
π SPI_RETURNTUPLE(3) π
okay bestie, so this is a page from the PostgreSQL 18.6 Documentation, and today's main character is SPI_returntuple β the girl who preps your tuple so it can go out into the world as a Datum. slay. let's get into it. π
β¨ NAME β¨
SPI_returntuple β get ready to return a tuple as a Datum π
πΈ SYNOPSIS πΈ
HeapTupleHeader SPI_returntuple(HeapTuple row, TupleDesc rowdesc)
π¦ DESCRIPTION π¦
so basically, SPI_returntuple makes a copy of a row over in the upper executor context, and hands it back to you in the form of a row type Datum. the returned pointer? you literally only need to convert it to Datum via PointerGetDatum before returning it. that's it. that's the whole vibe. β¨
π¨ important: this function can only be used while you're connected to SPI. if you're not connected, it returnsNULLand setsSPI_resulttoSPI_ERROR_UNCONNECTED. so, like, vibe check first, okay? π
also, heads up: this one is meant for functions that are declared to return composite types. it is not used for triggers β if you're returning a modified row in a trigger, use SPI_copytuple instead. different girl, different job, no cap. π
π ARGUMENTS π
HeapTuple rowβ the row you want copied. just, like, hand her the row. π«ΆTupleDesc rowdescβ the descriptor for the row. and fr fr, pass the same descriptor every time if you want the most effective caching. consistency is iconic. β
π RETURN VALUE π
a HeapTupleHeader pointing to the copied row β or NULL if something went wrong (peep SPI_result for the error indication, she'll tell you what happened). π
π SEE ALSO π
okay so the original page didn't list any SEE ALSO references β nothing else to link, bestie, that's the whole list. π
and that's the page!! this one came from the PostgreSQL 18.6 docs, dated 2026, filed under SPI_RETURNTUPLE(3). go forth and return your tuples, queen. πβ¨π¦
π¦ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 Β· PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 Β· PostgreSQL
- arch rolling: postgresql 18.6-4 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-doc-18 18.6-0ubuntu0.26.04.1 Β· PostgreSQL
- ubuntu stonking: postgresql-doc-18 18.6-3build2 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms