4 SPI_execute_extended — execute a command with out-of-line parameters
8 int SPI_execute_extended(const char *command,
9 const SPIExecuteOptions * options)
13 SPI_execute_extended executes a command that might include references
14 to externally supplied parameters. The command text refers to a
15 parameter as $n, and the options->params object (if supplied) provides
16 values and type information for each such symbol. Various execution
17 options can be specified in the options struct, too.
19 The options->params object should normally mark each parameter with the
20 PARAM_FLAG_CONST flag, since a one-shot plan is always used for the
23 If options->dest is not NULL, then result tuples are passed to that
24 object as they are generated by the executor, instead of being
25 accumulated in SPI_tuptable. Using a caller-supplied DestReceiver
26 object is particularly helpful for queries that might generate many
27 tuples, since the data can be processed on-the-fly instead of being
28 accumulated in memory.
35 const SPIExecuteOptions * options
36 struct containing optional arguments
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:
45 data structure containing query parameter types and values; NULL
49 true for read-only execution
52 true allows non-atomic execution of CALL and DO statements (but
53 this field is ignored unless the SPI_OPT_NONATOMIC flag was
54 passed to SPI_connect_ext)
56 bool must_return_tuples
57 if true, raise error if the query is not of a kind that returns
58 tuples (this does not forbid the case where it happens to return
62 maximum number of rows to return, or 0 for no limit
65 DestReceiver object that will receive any tuples emitted by the
66 query; if NULL, result tuples are accumulated into a
67 SPI_tuptable structure, as in SPI_execute
70 This field is present for consistency with
71 SPI_execute_plan_extended, but it is ignored, since the plan
72 used by SPI_execute_extended is never saved.
76 The return value is the same as for SPI_execute.
78 When options->dest is NULL, SPI_processed and SPI_tuptable are set as
79 in SPI_execute. When options->dest is not NULL, SPI_processed is set to
80 zero and SPI_tuptable is set to NULL. If a tuple count is required, the
81 caller's DestReceiver object must calculate it.