2 .\" Title: SPI_execute_plan_extended
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "SPI_EXECUTE_PLAN_EXTENDED" "3" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 SPI_execute_plan_extended \- execute a statement prepared by \fBSPI_prepare\fR
35 int SPI_execute_plan_extended(SPIPlanPtr \fIplan\fR,
36 const SPIExecuteOptions * \fIoptions\fR)
40 \fBSPI_execute_plan_extended\fR
41 executes a statement prepared by
43 or one of its siblings\&. This function is equivalent to
44 \fBSPI_execute_plan\fR, except that information about the parameter values to be passed to the query is presented differently, and additional execution\-controlling options can be passed\&.
46 Query parameter values are represented by a
48 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
51 Also, instead of always accumulating the result tuples into a
53 structure, tuples can be passed to a caller\-supplied
55 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\&.
60 prepared statement (returned by
64 const SPIExecuteOptions * \fIoptions\fR
66 struct containing optional arguments
69 Callers should always zero out the entire
71 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
75 ParamListInfo \fIparams\fR
77 data structure containing query parameter types and values; NULL if none
83 for read\-only execution
86 bool \fIallow_nonatomic\fR
89 allows non\-atomic execution of CALL and DO statements (but this field is ignored unless the
92 \fBSPI_connect_ext\fR)
95 bool \fImust_return_tuples\fR
98 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)
103 maximum number of rows to return, or
108 DestReceiver * \fIdest\fR
111 object that will receive any tuples emitted by the query; if NULL, result tuples are accumulated into a
114 \fBSPI_execute_plan\fR
117 ResourceOwner \fIowner\fR
119 The resource owner that will hold a reference count on the plan while it is executed\&. If NULL, CurrentResourceOwner is used\&. Ignored for non\-saved plans, as SPI does not acquire reference counts on those\&.
123 The return value is the same as for
124 \fBSPI_execute_plan\fR\&.
133 \fBSPI_execute_plan\fR\&. When
139 is set to NULL\&. If a tuple count is required, the caller\*(Aqs
141 object must calculate it\&.