SPI_CURS...WITH_ARGS(3)
π SPI_CURS...WITH_ARGS(3) π
okay bestie, welcome to the SPI_CURS...WITH_ARGS(3) page from the PostgreSQL 15.19 Documentation. This is the whole vibe, no cap. β¨
πΈ NAME πΈ
SPI_cursor_open_with_args β set up a cursor using a query and parameters. periodt.
β¨ 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 π¦
okay so SPI_cursor_open_with_args sets up a cursor β internally, a portal β that will execute the query you hand it. Most of the parameters mean exactly the same thing as the matching parameters on 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 youβre gonna run the same command with many different parameters, either method might be faster β it depends on the cost of re-planning versus the benefit of custom plans. iykyk.
The passed-in parameter data gets copied into the cursorβs portal, so it can be freed while the cursor still exists. cute and convenient.
Deprecation tea β: 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. Use the glow-up.
π ARGUMENTS π
const char * nameβ the name for the portal, orNULLto let the system pick a name for you. ty bestie.const char * commandβ the command string. the actual query vibe.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.) wild but true. - Note that
nullsis not a text string, just an array: it does not need a'\0'terminator. no cap.
- If
bool read_onlyβtruefor read-only execution.int cursorOptionsβ integer bit mask of cursor options; zero produces default behavior.
π₯ RETURN VALUE π₯
You get back a pointer to the portal containing the cursor. Important: there is no error return convention; any error will be reported via elog.
π Mwah! Thatβs the page, bestie. Source/version: PostgreSQL 15.19; date: 2026. Stay slaying. ππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15-docs 15.19-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