SPI_PREPARE_CURSOR(3)

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

πŸ’… SPI_PREPARE_CURSOR(3) β€” prepare a statement, without executing it yet ✨

🏷️ NAME

SPI_prepare_cursor β€” prepare a statement, without executing it yet.

πŸ“œ SYNOPSIS

       SPIPlanPtr SPI_prepare_cursor(const char * command, int nargs,
                                     Oid * argtypes, int cursorOptions)

🌸 DESCRIPTION

okay so SPI_prepare_cursor is literally identical to SPI_prepare, except it also allows specification of the planner's β€œcursor options” parameter. Cute extra dial, bestie. πŸŽ›οΈ

That parameter is a bit mask, and it has the values shown in nodes/parsenodes.h for the options field of DeclareCursorStmt. SPI_prepare always takes the cursor options as zero β€” no extra options, just default energy. πŸŽ€

🚨 Heads up: this function is now deprecated in favor of SPI_prepare_extended. It still exists, but it's giving legacy, bestie. πŸ’…

🧾 ARGUMENTS

  • const char * command β€” command string. Like, the actual statement text goes here. πŸ“
  • int nargs β€” number of input parameters ($1, $2, etc.). Count them, don't guess. πŸ”’
  • Oid * argtypes β€” pointer to an array containing the OIDs of the data types of the parameters. Type info lives here. 🫢
  • int cursorOptions β€” integer bit mask of cursor options; zero produces default behavior. Default vibes are at zero. πŸŽ€

πŸ” RETURN VALUE

SPI_prepare_cursor has the same return conventions as SPI_prepare. No plot twist β€” same rules, same energy. πŸ’–

πŸ“ NOTES

Useful bits to set in cursorOptions include CURSOR_OPT_SCROLL, CURSOR_OPT_NO_SCROLL, CURSOR_OPT_FAST_PLAN, CURSOR_OPT_GENERIC_PLAN, and CURSOR_OPT_CUSTOM_PLAN.

🚨 Note in particular: CURSOR_OPT_HOLD is ignored. Like, it does not do the thing here. Do not pass it expecting magic, bestie. πŸ’€

πŸ’Œ That’s the page, bestie β€” sourced from PostgreSQL 17.11, dated 2026, and filed under SPI_PREPARE_CURSOR(3). Mwah! πŸ’‹

πŸ“¦ where this page comes from