SPI_CURSOR_PARSE_OPEN(3)
π SPI_CURSOR_PARSE_OPEN π
okay so bestie, welcome to the manual page for SPI_cursor_parse_open β it's the PostgreSQL 18.6 one, and it's genuinely iconic. Let's get into it π«Ά
β¨ NAME β¨
SPI_cursor_parse_open β set up a cursor using a query string and parameters πΈ
β¨ SYNOPSIS β¨
Portal SPI_cursor_parse_open(const char *name,
const char *command,
const SPIParseOpenOptions * options)
no cap, that's the whole signature. three args, one Portal coming back π
β¨ DESCRIPTION β¨
So SPI_cursor_parse_open sets up a cursor (internally that's a portal, iykyk) that will execute the query string you hand it. Think of it as the glow-up version of SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist β except the parameter references inside the query string are handled entirely by supplying a ParamListInfo object. no extra steps, no drama β¨
For one-time query execution, this function should be preferred over SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist. But listen β if the same command is gonna be executed with many different parameters, either method might be faster. It literally depends on the cost of re-planning versus the benefit of custom plans. vibe check your use case, basically π
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. periodt.
Also very important: the passed-in parameter data will be copied into the cursor's portal, so it can be freed while the cursor still exists. you can let that memory go, she's safe π
β¨ ARGUMENTS β¨
const char * nameβ name for the portal, orNULLto let the system pick a name for you (main character energy, letting the system decide π )const char * commandβ the command stringconst 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 get added to the struct in future will be defined to behave backwards-compatibly if they are zero. zero it first, queen π
The currently available options fields are:
ParamListInfo paramsβ data structure containing query parameter types and values;NULLif noneint cursorOptionsβ integer bit mask of cursor options; zero produces default behaviorbool read_onlyβ true for read-only execution
β¨ RETURN VALUE β¨
Pointer to the portal containing the cursor. π
β οΈ heads up bestie: there is no error return convention here. any error will be reported via elog. so don't go checking for a NULL return like it's gonna tell you something β it won't π
okay that's the whole page, you ate it π stay slay, go set up those cursors.
PostgreSQL 18.6 π Β· dated 2026 Β· that's a wrap on SPI_CURSOR_PARSE_OPEN(3), mwah π
β¨
π¦ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 Β· PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 Β· PostgreSQL
- arch rolling: postgresql 18.6-4 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-doc-18 18.6-0ubuntu0.26.04.1 Β· PostgreSQL
- ubuntu stonking: postgresql-doc-18 18.6-3build2 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms