SPI_IS_CURSOR_PLAN(3)
π SPI_IS_CURSOR_PLAN(3) β the PostgreSQL 15.19 glow-up π
okay so bestie, welcome to SPI_IS_CURSOR_PLAN(3), straight out of the PostgreSQL 15.19 Documentation β¨ this one's a lil vibe-check function and honestly she's serving main character energy for like three lines of C. let's get into it π¦
β¨ 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 SPI_is_cursor_plan returns true when a statement prepared by SPI_prepare can be passed as an argument to SPI_cursor_open, and false when it literally cannot, no cap π that's the whole deal.
the criteria, bestie, are these two iconic requirements:
- the plan represents one single command (one, singular, not a whole group chat of commands) π
- that command returns tuples to the caller β like, it actually gives you rows back π
examples so you get the vibe:
SELECTis allowed unless it contains anINTOclauseUPDATEis allowed only if it contains aRETURNINGclause
ikyk β it's giving "does this plan even produce output," and that's the entire test π
π«Ά ARGUMENTS π«Ά
SPIPlanPtr planβ the prepared statement, as returned bySPI_prepare. that's your girl π
β RETURN VALUE β
returns true or false to indicate whether the plan can produce a cursor or not β and when it does, SPI_result is set to zero π―
but listen, and this is the important part: if it's not possible to determine the answer β for example, if the plan is NULL or invalid, or if it's called when you're not connected to SPI β then SPI_result is set to a suitable error code and false is returned π so like, false is doing double duty here and you gotta check SPI_result to know which situation you're in. no cap, that's the tea π
heads up fr fr: afalsedoesn't automatically mean "nope, can't do it" β it can also mean "bestie I literally cannot tell you." always peek atSPI_resultbefore you spiral π
π§ sign-off π§
and that's the page!! π this lil icon lives in the PostgreSQL 15.19 docs and was dated 2026 when it got its moment in the sun β go forth and cursor responsibly, bestie ππβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15-docs 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms