SPI_CURSOR_PARSE_OPEN(3pg16)
π SPI_CURSOR_PARSE_OPEN(3pg16) β PostgreSQL 16.15 docs, bestie π
Okay so welcome to the SPI_CURSOR_PARSE_OPEN(3pg16) page from the PostgreSQL 16.15 documentation. Itβs giving βset up a cursor with a query string and params,β and honestly? Iconic. π
πΈ NAME πΈ
SPI_cursor_parse_open β set up a cursor using a query string and parameters. Thatβs the whole vibe. β¨
β¨ SYNOPSIS β¨
Portal SPI_cursor_parse_open(const char *name,
const char *command,
const SPIParseOpenOptions * options)
π DESCRIPTION π
So SPI_cursor_parse_open sets up a cursor (internally, a portal, iykyk) that will execute the specified query string. π
Itβs comparable to SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist, except that parameter references within the query string are handled entirely by supplying a ParamListInfo object. No cap. π
For one-time query execution, this function should be preferred over SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist. But if the same command is to be executed with many different parameters, either method might be faster, depending on the cost of re-planning versus the benefit of custom plans. Itβs giving βit depends,β fr fr. π¦
The options->params object should normally mark each parameter with the PARAM_FLAG_CONST flag, since a one-shot plan is always used for the query. β
The passed-in parameter data will be copied into the cursorβs portal, so it can be freed while the cursor still exists. That part is lowkey reassuring. π«Ά
π ARGUMENTS π
const char * nameβ name for portal, orNULLto let the system select a name. Let the system pick? Main character energy, honestly. πconst char * commandβ command string. The actual query vibe. β¨const SPIParseOpenOptions * optionsβ struct containing optional arguments. Cute little options bag. π
Callers should always zero out the entire options struct, then fill whichever fields they want to set. This ensures forward compatibility of code, since any fields that are added to the struct in future will be defined to behave backwards-compatibly if they are zero. π«‘
Bestie, zero out the whole struct first. Future fields are literally relying on that zeroed-out energy. π
π currently available options fields π
ParamListInfo paramsβ data structure containing query parameter types and values;NULLif none. πint cursorOptionsβ integer bit mask of cursor options; zero produces default behavior. Slay, defaults. β¨bool read_onlyβtruefor read-only execution. π₯
π¦ RETURN VALUE π¦
Pointer to portal containing the cursor. π«
Note there is no error return convention; any error will be reported via elog. So yeah, itβs not doing a cute little error-code return β itβs going straight to elog. Periodt. π
Signing off with PostgreSQL 16.15, dated 2026, and the page tag SPI_CURSOR_PARSE_OPEN(3) β mwah! ππ
π¦ 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