SPI_IS_CURSOR_PLAN(3)

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

✨ SPI_IS_CURSOR_PLAN(3) ✨

okay bestie so we're in the PostgreSQL 18.6 Documentation and today's main character is SPI_is_cursor_plan πŸ’– she's a lil function from the SPI world and she's here to answer ONE very important question for you. no cap.


πŸŽ€ NAME πŸŽ€

SPI_is_cursor_plan β€” 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 πŸ’…

so like, 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. it's giving vibe check for your plan πŸ”₯

the criteria are, and hear me out:

  • the plan represents one single command β€” just one, not a whole group chat of them πŸ™ˆ
  • 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. the way that RETURNING is the whole personality of an UPDATE here... iconic behavior honestly πŸ‘‘


⭐ ARGUMENTS ⭐

  • SPIPlanPtr plan β€” the prepared statement, i.e. the lil guy that got 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 ✨

but okay so 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. 😭 so like, always peek at SPI_result, that's the real tea.

fr fr: a false on its own doesn't mean "no cursor bestie", it might mean "I literally could not even tell you". check SPI_result before you make it a whole thing πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

hmm, this page doesn't list any SEE ALSO refs, so consider this your moment to go read up on SPI_prepare and SPI_cursor_open on your own time, iykyk 🌈


that's the whole page, no notes. this was PostgreSQL 18.6, dated 2026, and yes the version number and the date are literally in the footer like a little signature β€” so here's your cute sign-off: stay hydrated, keep your SPI_result checked, and slay πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ‘‘πŸŒˆβ­

πŸ“¦ where this page comes from