SPI_CURS...WITH_ARGS(3)
π NAME π
okay bestie, welcome to the SPI_CURS...WITH_ARGS(3) page from the PostgreSQL 16.15 Documentation β this is literally the βset up a cursor using a query and parametersβ function, and yes weβre gonna cover every single detail. π
β¨
β¨ SYNOPSIS β¨
Portal SPI_cursor_open_with_args(const char *name,
const char *command,
int nargs, Oid *argtypes,
Datum *values, const char *nulls,
bool read_only, int cursorOptions)
π DESCRIPTION π
SPI_cursor_open_with_args sets up a cursor (internally, a portal) that will execute the specified query. Most of the parameters have the same meanings as the corresponding parameters to SPI_prepare_cursor and SPI_cursor_open. slay, thatβs the core vibe. π¦
For one-time query execution, this function should be preferred over SPI_prepare_cursor followed by SPI_cursor_open. 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. like, itβs a real trade-off bestie, not just vibes. π«
The passed-in parameter data will be copied into the cursorβs portal, so it can be freed while the cursor still exists. very convenient, no cap. π«Ά
π¨ deprecated alert: this function is now deprecated in favor of SPI_cursor_parse_open, which provides equivalent functionality using a more modern API for handling query parameters. so thatβs the official tea. π
π¦ ARGUMENTS π¦
const char * nameβ name for portal, orNULLto let the system select a name.const char * commandβ command string.int nargsβ number of input parameters ($1,$2, etc.).Oid * argtypesβ an array of lengthnargs, containing the OIDs of the data types of the parameters.Datum * valuesβ an array of lengthnargs, containing the actual parameter values.const char * nullsβ an array of lengthnargs, describing which parameters are null.
If nulls is NULL then SPI_cursor_open_with_args assumes that no parameters are null. Otherwise, each entry of the nulls array should be ' ' if the corresponding parameter value is non-null, or 'n' if the corresponding parameter value is null. (In the latter case, the actual value in the corresponding values entry doesnβt matter.) Note that nulls is not a text string, just an array: it does not need a '\0' terminator. read that twice, itβs giving important. π
bool read_onlyβtruefor read-only execution.int cursorOptionsβ integer bit mask of cursor options; zero produces default behavior.
πΈ RETURN VALUE πΈ
Pointer to portal containing the cursor. Note there is no error return convention; any error will be reported via elog. so like, errors go through elog, periodt. π
okay thatβs the whole page, bestie π«Ά β shoutout to the source/version PostgreSQL 16.15, the date 2026, and the SPI_CURS...WITH_ARGS(3) manual page. iconic, honestly. π
β¨
π¦ 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