1SPI_EXECUTE_WITH_ARGS(3) PostgreSQL 10.7 DocumentationSPI_EXECUTE_WITH_ARGS(3)
2
3
4
6 SPI_execute_with_args - execute a command with out-of-line parameters
7
9 int SPI_execute_with_args(const char *command,
10 int nargs, Oid *argtypes,
11 Datum *values, const char *nulls,
12 bool read_only, long count)
13
15 SPI_execute_with_args executes a command that might include references
16 to externally supplied parameters. The command text refers to a
17 parameter as $n, and the call specifies data types and values for each
18 such symbol. read_only and count have the same interpretation as in
19 SPI_execute.
20
21 The main advantage of this routine compared to SPI_execute is that data
22 values can be inserted into the command without tedious
23 quoting/escaping, and thus with much less risk of SQL-injection
24 attacks.
25
26 Similar results can be achieved with SPI_prepare followed by
27 SPI_execute_plan; however, when using this function the query plan is
28 always customized to the specific parameter values provided. For
29 one-time query execution, this function should be preferred. If the
30 same command is to be executed with many different parameters, either
31 method might be faster, depending on the cost of re-planning versus the
32 benefit of custom plans.
33
35 const char * command
36 command string
37
38 int nargs
39 number of input parameters ($1, $2, etc.)
40
41 Oid * argtypes
42 an array of length nargs, containing the OIDs of the data types of
43 the parameters
44
45 Datum * values
46 an array of length nargs, containing the actual parameter values
47
48 const char * nulls
49 an array of length nargs, describing which parameters are null
50
51 If nulls is NULL then SPI_execute_with_args assumes that no
52 parameters are null. Otherwise, each entry of the nulls array
53 should be ' ' if the corresponding parameter value is non-null, or
54 'n' if the corresponding parameter value is null. (In the latter
55 case, the actual value in the corresponding values entry doesn't
56 matter.) Note that nulls is not a text string, just an array: it
57 does not need a '\0' terminator.
58
59 bool read_only
60 true for read-only execution
61
62 long count
63 maximum number of rows to return, or 0 for no limit
64
66 The return value is the same as for SPI_execute.
67
68 SPI_processed and SPI_tuptable are set as in SPI_execute if successful.
69
70
71
72PostgreSQL 10.7 2019 SPI_EXECUTE_WITH_ARGS(3)