SPI_IS_CURSOR_PLAN(3)

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

πŸŽ€ NAME πŸŽ€

okay so bestie, this is the SPI_IS_CURSOR_PLAN(3) page from the PostgreSQL 17.11 docs ✨ β€” the actual name is SPI_is_cursor_plan, and it returns true if a statement prepared by SPI_prepare can be used with SPI_cursor_open. πŸ’…

🌸 SYNOPSIS 🌸

bool SPI_is_cursor_plan(SPIPlanPtr plan)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: SPI_is_cursor_plan returns true if a statement prepared by SPI_prepare can be passed as an argument to SPI_cursor_open, or false if that is not the case. πŸ’–

the criteria are literally:

  • the plan represents one single command, and
  • that command returns tuples to the caller.

for example, SELECT is allowed unless it contains an INTO clause, and UPDATE is allowed only if it contains a RETURNING clause. no cap. πŸ‘‘

🧚 ARGUMENTS 🧚

  • SPIPlanPtr plan β€” the prepared statement (returned by SPI_prepare). 🫢

⭐ RETURN VALUE ⭐

true or false to indicate if the plan can produce a cursor or not, with SPI_result set to zero. βœ…

if it is not possible to determine the answer (for example, if the plan is NULL or invalid, or if called when not connected to SPI), then SPI_result is set to a suitable error code and false is returned. 😭

lowkey important: that NULL/invalid/not-connected-to-SPI case is the "can't even tell" vibe, and it still comes back false β€” with SPI_result carrying the error code. πŸ’€

okay bestie, that's the whole page β€” from the PostgreSQL 17.11 docs, dated 2026, manual page SPI_IS_CURSOR_PLAN(3). slay, go open some cursors responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from