1SPI_EXECUTE_PLAN_EXTENDED(P3o)stgreSQL 15.4 DocumentatSiPoIn_EXECUTE_PLAN_EXTENDED(3)
2
3
4
6 SPI_execute_plan_extended - execute a statement prepared by SPI_prepare
7
9 int SPI_execute_plan_extended(SPIPlanPtr plan,
10 const SPIExecuteOptions * options)
11
13 SPI_execute_plan_extended executes a statement prepared by SPI_prepare
14 or one of its siblings. This function is equivalent to
15 SPI_execute_plan, except that information about the parameter values to
16 be passed to the query is presented differently, and additional
17 execution-controlling options can be passed.
18
19 Query parameter values are represented by a ParamListInfo struct, which
20 is convenient for passing down values that are already available in
21 that format. Dynamic parameter sets can also be used, via hook
22 functions specified in ParamListInfo.
23
24 Also, instead of always accumulating the result tuples into a
25 SPI_tuptable structure, tuples can be passed to a caller-supplied
26 DestReceiver object as they are generated by the executor. This is
27 particularly helpful for queries that might generate many tuples, since
28 the data can be processed on-the-fly instead of being accumulated in
29 memory.
30
32 SPIPlanPtr plan
33 prepared statement (returned by SPI_prepare)
34
35 const SPIExecuteOptions * options
36 struct containing optional arguments
37
38 Callers should always zero out the entire options struct, then fill
39 whichever fields they want to set. This ensures forward compatibility
40 of code, since any fields that are added to the struct in future will
41 be defined to behave backwards-compatibly if they are zero. The
42 currently available options fields are:
43
44 ParamListInfo params
45 data structure containing query parameter types and values; NULL if
46 none
47
48 bool read_only
49 true for read-only execution
50
51 bool allow_nonatomic
52 true allows non-atomic execution of CALL and DO statements
53
54 bool must_return_tuples
55 if true, raise error if the query is not of a kind that returns
56 tuples (this does not forbid the case where it happens to return
57 zero tuples)
58
59 uint64 tcount
60 maximum number of rows to return, or 0 for no limit
61
62 DestReceiver * dest
63 DestReceiver object that will receive any tuples emitted by the
64 query; if NULL, result tuples are accumulated into a SPI_tuptable
65 structure, as in SPI_execute_plan
66
67 ResourceOwner owner
68 The resource owner that will hold a reference count on the plan
69 while it is executed. If NULL, CurrentResourceOwner is used.
70 Ignored for non-saved plans, as SPI does not acquire reference
71 counts on those.
72
74 The return value is the same as for SPI_execute_plan.
75
76 When options->dest is NULL, SPI_processed and SPI_tuptable are set as
77 in SPI_execute_plan. When options->dest is not NULL, SPI_processed is
78 set to zero and SPI_tuptable is set to NULL. If a tuple count is
79 required, the caller's DestReceiver object must calculate it.
80
81
82
83PostgreSQL 15.4 2023 SPI_EXECUTE_PLAN_EXTENDED(3)