SPI_RETURNTUPLE(3)

πŸ“¦ version 17.11, in opensuse-leap 16.0

πŸ’– 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 for row (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