SPI_PREPARE_CURSOR(3)

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

🌸 NAME 🌸

Okay so bestie, this is SPI_prepare_cursor(3): it prepares a statement, without executing it yet. Iconic little setup step, no execution yet πŸ’….

✨ SYNOPSIS ✨

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

πŸ’– DESCRIPTION πŸ’–

SPI_prepare_cursor is literally identical to SPI_prepare, with one extra little slay: it also lets you specify the planner's β€œcursor options” parameter. That parameter is a bit mask, and its values are shown in nodes/parsenodes.h for the options field of DeclareCursorStmt. Meanwhile, SPI_prepare always takes the cursor options as zero.

Ngl, this function is now deprecated in favor of SPI_prepare_extended πŸ’€. Not the vibe, but that's the note.

πŸŽ€ ARGUMENTS πŸŽ€

  • const char * command β€” the command string.
  • int nargs β€” number of input parameters ($1, $2, etc.).
  • Oid * argtypes β€” pointer to an array containing the OIDs of the data types of the parameters.
  • int cursorOptions β€” integer bit mask of cursor options; zero produces default behavior.

πŸ¦‹ RETURN VALUE πŸ¦‹

SPI_prepare_cursor has the same return conventions as SPI_prepare. No new return-value lore, bestie 🫢.

🌈 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 that CURSOR_OPT_HOLD is ignored β€” yes, ignored, so don't come for it πŸ™ˆ.


okay bye bestie πŸ’– β€” this page is from PostgreSQL 16.15, dated 2026, and it's the SPI_PREPARE_CURSOR(3) manual page. periodt ✨

πŸ“¦ where this page comes from