SPI_EXEC..._EXTENDED(3)
okay so bestie, welcome to the SPI_EXEC..._EXTENDED(3) page π
this is the one where we execute a statement prepared by SPI_prepare, and honestly the vibe is very "pass the options struct, get the tuples, live your truth."
πΈ NAME πΈ
SPI_execute_plan_extended β execute a statement prepared by SPI_prepare β¨
β¨ SYNOPSIS β¨
int SPI_execute_plan_extended(SPIPlanPtr plan,
const SPIExecuteOptions * options)
π DESCRIPTION π
Okay so SPI_execute_plan_extended executes a statement prepared by SPI_prepare or one of its siblings. This function is equivalent to SPI_execute_plan, except that information about the parameter values to be passed to the query is presented differently, and additional execution-controlling options can be passed. slay.
Query parameter values are represented by a ParamListInfo struct, which is lowkey convenient for passing down values that are already available in that format. Dynamic parameter sets can also be used, via hook functions specified in ParamListInfo. iykyk π§
Also, instead of always accumulating the result tuples into a SPI_tuptable structure, tuples can be passed to a caller-supplied DestReceiver object as they are generated by the executor. This is particularly helpful for queries that might generate many tuples, since the data can be processed on-the-fly instead of being accumulated in memory. That is main character energy right there π₯.
π ARGUMENTS π
SPIPlanPtr planβ prepared statement (returned bySPI_prepare) πconst SPIExecuteOptions * 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 are added to the struct in future will be defined to behave backwards-compatibly if they are zero. The currently available options fields are:
bestie, do not skip the zeroing step β zero out the entire options struct first, then fill whichever fields you want to set. That is the whole forward-compat ritual π
ParamListInfo paramsβ data structure containing query parameter types and values;NULLif nonebool read_onlyβ true for read-only executionbool allow_nonatomicβ true allows non-atomic execution ofCALLandDOstatements (but this field is ignored unless theSPI_OPT_NONATOMICflag was passed toSPI_connect_ext)bool must_return_tuplesβ if true, raise error if the query is not of a kind that returns tuples (this does not forbid the case where it happens to return zero tuples)uint64 tcountβ maximum number of rows to return, or0for no limitDestReceiver * destβDestReceiverobject that will receive any tuples emitted by the query; ifNULL, result tuples are accumulated into aSPI_tuptablestructure, as inSPI_execute_planResourceOwner ownerβ The resource owner that will hold a reference count on the plan while it is executed. IfNULL,CurrentResourceOwneris used. Ignored for non-saved plans, as SPI does not acquire reference counts on those.
π¦ RETURN VALUE π¦
The return value is the same as for SPI_execute_plan. fr fr.
When options->dest is NULL, SPI_processed and SPI_tuptable are set as in SPI_execute_plan. When options->dest is not NULL, SPI_processed is set to zero and SPI_tuptable is set to NULL. If a tuple count is required, the caller's DestReceiver object must calculate it. no cap π
mwah π that is the whole vibe. This page is from PostgreSQL 15.19, dated 2026, and it is the SPI_EXEC..._EXTENDED(3) manual page. periodt π«Ά
π¦ 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