SPI_PREPARE_CURSOR(3)
π 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
- opensuse-leap 16.0: postgresql17-docs 17.11-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