SPI_IS_CURSOR_PLAN(3)
β¨ 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 bySPI_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: afalseon its own doesn't mean "no cursor bestie", it might mean "I literally could not even tell you". checkSPI_resultbefore 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
- opensuse-leap 16.0: postgresql18-docs 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms