SPI_PREPARE_CURSOR(3)
hii bestie, you're looking at SPI_PREPARE_CURSOR(3) from the PostgreSQL 13.23 docs, and tbh it's lowkey a glow-up for prepared statements π
β¨
π 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 lets you specify the planner's cursor options parameter. icon behavior fr fr.
That parameter is a bit mask, and its values are shown in nodes/parsenodes.h for the options field of DeclareCursorStmt. Meanwhile, plain old SPI_prepare always takes the cursor options as zero β no extra flair there, bestie.
π ARGUMENTS π
const char * commandβ the command string, aka the actual SQL vibe you're preparing π«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 cap, it keeps that same energy.
π₯ NOTES π₯
Useful bits to set in cursorOptions include:
CURSOR_OPT_SCROLLCURSOR_OPT_NO_SCROLLCURSOR_OPT_FAST_PLANCURSOR_OPT_GENERIC_PLANCURSOR_OPT_CUSTOM_PLAN
bestie, note in particular that CURSOR_OPT_HOLD is ignored π like it did not make the cut.
big kiss from the PostgreSQL 13.23 docs, dated 2025 β mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13-docs 13.23-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