2 .\" Title: SPI_execute_with_args
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_WITH_ARGS" "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_with_args \- execute a command with out\-of\-line parameters
35 int SPI_execute_with_args(const char *\fIcommand\fR,
36 int \fInargs\fR, Oid *\fIargtypes\fR,
37 Datum *\fIvalues\fR, const char *\fInulls\fR,
38 bool \fIread_only\fR, long \fIcount\fR)
42 \fBSPI_execute_with_args\fR
43 executes a command that might include references to externally supplied parameters\&. The command text refers to a parameter as
44 $\fIn\fR, and the call specifies data types and values for each such symbol\&.
48 have the same interpretation as in
51 The main advantage of this routine compared to
53 is that data values can be inserted into the command without tedious quoting/escaping, and thus with much less risk of SQL\-injection attacks\&.
55 Similar results can be achieved with
58 \fBSPI_execute_plan\fR; however, when using this function the query plan is always customized to the specific parameter values provided\&. For one\-time query execution, this function should be preferred\&. If the same command is to be executed with many different parameters, either method might be faster, depending on the cost of re\-planning versus the benefit of custom plans\&.
61 const char * \fIcommand\fR
68 number of input parameters ($1,
75 \fInargs\fR, containing the
76 OIDs of the data types of the parameters
82 \fInargs\fR, containing the actual parameter values
85 const char * \fInulls\fR
88 \fInargs\fR, describing which parameters are null
95 \fBSPI_execute_with_args\fR
96 assumes that no parameters are null\&. Otherwise, each entry of the
100 if the corresponding parameter value is non\-null, or
102 if the corresponding parameter value is null\&. (In the latter case, the actual value in the corresponding
104 entry doesn\*(Aqt matter\&.) Note that
106 is not a text string, just an array: it does not need a
114 for read\-only execution
119 maximum number of rows to return, or
125 The return value is the same as for