SPI_CURSOR_PARSE_OPEN(3pg14)
β¨ NAME β¨
okay bestie, welcome to the SPI_CURSOR_PARSE_OPEN(3) page from the PostgreSQL 14.24 Documentation β the icon of setting up a cursor using a query string and parameters. This is SPI_cursor_parse_open, and she is here to help π
.
πΈ SYNOPSIS πΈ
Portal SPI_cursor_parse_open(const char *name,
const char *command,
const SPIParseOpenOptions * options)
π¦ DESCRIPTION π¦
SPI_cursor_parse_open sets up a cursor (internally, a portal) that will execute the specified query string. This is 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. 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 "choose your fighter" energy βοΈ.
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. Lowkey important!
The passed-in parameter data will be copied into the cursor's portal, so it can be freed while the cursor still exists. Self-care for your memory management π«Ά
π ARGUMENTS π
const char * nameβ name for portal, orNULLto let the system select a name.const char * commandβ command string.const SPIParseOpenOptions * optionsβ struct containing optional arguments.
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. The currently available options fields are:
ParamListInfo paramsβ data structure containing query parameter types and values;NULLif none.int cursorOptionsβ integer bit mask of cursor options; zero produces default behavior.bool read_onlyβ true for 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 like, don't look for a fancy error code, bestie π.
byeee π this has been the SPI_CURSOR_PARSE_OPEN(3) page from PostgreSQL 14.24, dated 2026 β catch you in the docs, mwah β¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14-docs 14.24-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