]> begriffs open source - ai-pg/blob - full-docs/txt/spi-spi-execute-extended.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / spi-spi-execute-extended.txt
1
2 SPI_execute_extended
3
4    SPI_execute_extended — execute a command with out-of-line parameters
5
6 Synopsis
7
8 int SPI_execute_extended(const char *command,
9                          const SPIExecuteOptions * options)
10
11 Description
12
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.
18
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
21    query.
22
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.
29
30 Arguments
31
32    const char * command
33           command string
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
46           if 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 (but
53           this field is ignored unless the SPI_OPT_NONATOMIC flag was
54           passed to SPI_connect_ext)
55
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
59           zero tuples)
60
61    uint64 tcount
62           maximum number of rows to return, or 0 for no limit
63
64    DestReceiver * dest
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
68
69    ResourceOwner owner
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.
73
74 Return Value
75
76    The return value is the same as for SPI_execute.
77
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.