SPI_EXEC..._EXTENDED(3)
β¨ NAME β¨
okay bestie, welcome to SPI_EXEC..._EXTENDED(3) β straight from the PostgreSQL 14.24 docs π
SPI_execute_plan_extended β execute a statement prepared by SPI_prepare
πΈ SYNOPSIS πΈ
int SPI_execute_plan_extended(SPIPlanPtr plan,
const SPIExecuteOptions * options)
π¦ DESCRIPTION π¦
SPI_execute_plan_extended executes a statement prepared by SPI_prepare or one of its siblings. Itβs equivalent to SPI_execute_plan, except that the info about the parameter values being passed to the query is presented differently, and you can pass additional execution-controlling options. lowkey iconic behavior.
Query parameter values are represented by a ParamListInfo struct, which is 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. slay.
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. itβs giving efficiency π
π 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. real talk: zero it out first, bestie π«Ά
The currently available options fields are:
ParamListInfo paramsβ data structure containing query parameter types and values;NULLif nonebool read_onlyβtruefor read-only executionbool allow_nonatomicβtrueallows non-atomic execution ofCALLandDOstatements (but this field is ignored unless theSPI_OPT_NONATOMICflag was passed toSPI_connect_ext)bool must_return_tuplesβ iftrue, 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.
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.
π later, bestie β this page is from PostgreSQL 14.24, dated 2026, and itβs literally SPI_EXEC..._EXTENDED(3). periodt π
β¨
π¦ 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