SPI_PREPARE_CURSOR(3)
πΈ 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_SCROLLCURSOR_OPT_NO_SCROLLCURSOR_OPT_FAST_PLANCURSOR_OPT_GENERIC_PLANCURSOR_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
- 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