SPI_CURS...WITH_ARGS(3)

πŸ“¦ version 15.19, in opensuse-leap 16.0

πŸ’… 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, or NULL to 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 length nargs, containing the OIDs of the data types of the parameters.
  • Datum * values β€” an array of length nargs, containing the actual parameter values.
  • const char * nulls β€” an array of length nargs, 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.) wild but true.
    • Note that nulls is not a text string, just an array: it does not need a '\0' terminator. no cap.
  • bool read_only β€” true for 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