]> begriffs open source - ai-pg/blob - full-docs/man3/SPI_cursor_parse_open.3
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man3 / SPI_cursor_parse_open.3
1 '\" t
2 .\"     Title: SPI_cursor_parse_open
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "SPI_CURSOR_PARSE_OPEN" "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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 SPI_cursor_parse_open \- set up a cursor using a query string and parameters
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 Portal SPI_cursor_parse_open(const char *\fIname\fR,
36                              const char *\fIcommand\fR,
37                              const SPIParseOpenOptions * \fIoptions\fR)
38 .fi
39 .SH "DESCRIPTION"
40 .PP
41 \fBSPI_cursor_parse_open\fR
42 sets up a cursor (internally, a portal) that will execute the specified query string\&. This is comparable to
43 \fBSPI_prepare_cursor\fR
44 followed by
45 \fBSPI_cursor_open_with_paramlist\fR, except that parameter references within the query string are handled entirely by supplying a
46 ParamListInfo
47 object\&.
48 .PP
49 For one\-time query execution, this function should be preferred over
50 \fBSPI_prepare_cursor\fR
51 followed by
52 \fBSPI_cursor_open_with_paramlist\fR\&. 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\&.
53 .PP
54 The
55 \fIoptions\->params\fR
56 object should normally mark each parameter with the
57 PARAM_FLAG_CONST
58 flag, since a one\-shot plan is always used for the query\&.
59 .PP
60 The passed\-in parameter data will be copied into the cursor\*(Aqs portal, so it can be freed while the cursor still exists\&.
61 .SH "ARGUMENTS"
62 .PP
63 const char * \fIname\fR
64 .RS 4
65 name for portal, or
66 NULL
67 to let the system select a name
68 .RE
69 .PP
70 const char * \fIcommand\fR
71 .RS 4
72 command string
73 .RE
74 .PP
75 const SPIParseOpenOptions * \fIoptions\fR
76 .RS 4
77 struct containing optional arguments
78 .RE
79 .PP
80 Callers should always zero out the entire
81 \fIoptions\fR
82 struct, then fill whichever fields they want to set\&. This ensures forward compatibility of code, since any fields that are added to the struct in future will be defined to behave backwards\-compatibly if they are zero\&. The currently available
83 \fIoptions\fR
84 fields are:
85 .PP
86 ParamListInfo \fIparams\fR
87 .RS 4
88 data structure containing query parameter types and values; NULL if none
89 .RE
90 .PP
91 int \fIcursorOptions\fR
92 .RS 4
93 integer bit mask of cursor options; zero produces default behavior
94 .RE
95 .PP
96 bool \fIread_only\fR
97 .RS 4
98 true
99 for read\-only execution
100 .RE
101 .SH "RETURN VALUE"
102 .PP
103 Pointer to portal containing the cursor\&. Note there is no error return convention; any error will be reported via
104 \fBelog\fR\&.