SPI_CURS...WITH_ARGS(3)
๐ NAME ๐
SPI_cursor_open_with_args โ set up a cursor using a query and parameters.
okay so bestie, this is the SPI_CURS...WITH_ARGS(3) page from the PostgreSQL 14.24 Documentation, and we are literally about to open a cursor with args. no cap. ๐
๐ 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.
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.
The passed-in parameter data will be copied into the cursor's portal, so it can be freed while the cursor still exists.
โ ๏ธ bestie, heads up: 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.
โจ 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
nullsisNULLthenSPI_cursor_open_with_argsassumes that no parameters are null. Otherwise, each entry of thenullsarray 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 correspondingvaluesentry doesn't matter.) Note thatnullsis not a text string, just an array: it does not need a'\0'terminator.
- If
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.
xoxo, bestie โ this page is from PostgreSQL 14.24, dated 2026, and Iโm obsessed you read the whole thing ๐๐ซถ๐
๐ฆ 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