SPI_PREPARE_CURSOR(3)
πΈ 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
- opensuse-leap 16.0: postgresql16-docs 16.15-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