1SPI_CURSOR_PARSE_OPEN(3) PostgreSQL 14.3 DocumentationSPI_CURSOR_PARSE_OPEN(3)
2
3
4

NAME

6       SPI_cursor_parse_open - set up a cursor using a query string and
7       parameters
8

SYNOPSIS

10       Portal SPI_cursor_parse_open(const char *name,
11                                    const char *command,
12                                    const SPIParseOpenOptions * options)
13

DESCRIPTION

15       SPI_cursor_parse_open sets up a cursor (internally, a portal) that will
16       execute the specified query string. This is comparable to
17       SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist, except
18       that parameter references within the query string are handled entirely
19       by supplying a ParamListInfo object.
20
21       For one-time query execution, this function should be preferred over
22       SPI_prepare_cursor followed by SPI_cursor_open_with_paramlist. If the
23       same command is to be executed with many different parameters, either
24       method might be faster, depending on the cost of re-planning versus the
25       benefit of custom plans.
26
27       The options->params object should normally mark each parameter with the
28       PARAM_FLAG_CONST flag, since a one-shot plan is always used for the
29       query.
30
31       The passed-in parameter data will be copied into the cursor's portal,
32       so it can be freed while the cursor still exists.
33

ARGUMENTS

35       const char * name
36           name for portal, or NULL to let the system select a name
37
38       const char * command
39           command string
40
41       const SPIParseOpenOptions * options
42           struct containing optional arguments
43
44       Callers should always zero out the entire options struct, then fill
45       whichever fields they want to set. This ensures forward compatibility
46       of code, since any fields that are added to the struct in future will
47       be defined to behave backwards-compatibly if they are zero. The
48       currently available options fields are:
49
50       ParamListInfo params
51           data structure containing query parameter types and values; NULL if
52           none
53
54       int cursorOptions
55           integer bit mask of cursor options; zero produces default behavior
56
57       bool read_only
58           true for read-only execution
59

RETURN VALUE

61       Pointer to portal containing the cursor. Note there is no error return
62       convention; any error will be reported via elog.
63
64
65
66PostgreSQL 14.3                      2022             SPI_CURSOR_PARSE_OPEN(3)
Impressum