SPI_PREPARE_CURSOR(3)

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

🌸 NAME 🌸

okay so bestie, this is SPI_prepare_cursor (you'll see it as SPI_PREPARE_CURSOR(3) up top) β€” and its whole job is to prepare a statement, without executing it yet. πŸ’…βœ¨

πŸ“œ SYNOPSIS πŸ“œ

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

πŸ’– DESCRIPTION πŸ’–

SPI_prepare_cursor is identical to SPI_prepare, except that it also lets you specify the planner's β€œcursor options” parameter. Iconic. It's a bit mask, and the values are shown in nodes/parsenodes.h for the options field of DeclareCursorStmt. Meanwhile SPI_prepare always takes the cursor options as zero. no cap.

🚨 heads-up: this function is now deprecated in favor of SPI_prepare_extended. So like, it still exists, but don't make it your main character if you're writing new stuff.

πŸŽ€ 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. literally matching vibes. 🫢

⭐ NOTES ⭐

Useful bits to set in cursorOptions include:

  • CURSOR_OPT_SCROLL
  • CURSOR_OPT_NO_SCROLL
  • CURSOR_OPT_FAST_PLAN
  • CURSOR_OPT_GENERIC_PLAN
  • CURSOR_OPT_CUSTOM_PLAN

Note in particular that CURSOR_OPT_HOLD is ignored. πŸ™ˆ


okay that's the whole page, bestie β€” source/version PostgreSQL 15.19, date 2026. mwah πŸ’‹

πŸ“¦ where this page comes from