SPI_IS_CURSOR_PLAN(3)

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

πŸ’… 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:

  • SELECT is allowed unless it contains an INTO clause
  • UPDATE is allowed only if it contains a RETURNING clause

ikyk β€” it's giving "does this plan even produce output," and that's the entire test πŸ’…


🫢 ARGUMENTS 🫢

  • SPIPlanPtr plan β€” the prepared statement, as returned by SPI_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: a false doesn't automatically mean "nope, can't do it" β€” it can also mean "bestie I literally cannot tell you." always peek at SPI_result before 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