diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-26 16:37:12 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-26 16:37:12 -0500 |
commit | d5a83d79c9f9b660a6a5a77afafe146d3c8c6f46 (patch) | |
tree | e0c3626c5bd5369cf1433a42a1db1d9df9dd53ba /src/include/executor | |
parent | 7292fd8f1c781278021407276474d9188845113d (diff) | |
download | postgresql-d5a83d79c9f9b660a6a5a77afafe146d3c8c6f46.tar.gz postgresql-d5a83d79c9f9b660a6a5a77afafe146d3c8c6f46.zip |
Rethink recently-added SPI interfaces.
SPI_execute_with_receiver and SPI_cursor_parse_open_with_paramlist are
new in v14 (cf. commit 2f48ede08). Before they can get out the door,
let's change their APIs to follow the practice recently established by
SPI_prepare_extended etc: shove all optional arguments into a struct
that callers are supposed to pre-zero. The hope is to allow future
addition of more options without either API breakage or a continuing
proliferation of new SPI entry points. With that in mind, choose
slightly more generic names for them: SPI_execute_extended and
SPI_cursor_parse_open respectively.
Discussion: https://postgr.es/m/CAFj8pRCLPdDAETvR7Po7gC5y_ibkn_-bOzbeJb39WHms01194Q@mail.gmail.com
Diffstat (limited to 'src/include/executor')
-rw-r--r-- | src/include/executor/spi.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index 5740f8956e5..6455d100f50 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -42,7 +42,7 @@ typedef struct SPIPrepareOptions int cursorOptions; } SPIPrepareOptions; -/* Optional arguments for SPI_execute_plan_extended */ +/* Optional arguments for SPI_execute[_plan]_extended */ typedef struct SPIExecuteOptions { ParamListInfo params; @@ -53,6 +53,14 @@ typedef struct SPIExecuteOptions ResourceOwner owner; } SPIExecuteOptions; +/* Optional arguments for SPI_cursor_parse_open */ +typedef struct SPIParseOpenOptions +{ + ParamListInfo params; + int cursorOptions; + bool read_only; +} SPIParseOpenOptions; + /* Plans are opaque structs for standard users of SPI */ typedef struct _SPI_plan *SPIPlanPtr; @@ -105,6 +113,8 @@ extern int SPI_connect(void); extern int SPI_connect_ext(int options); extern int SPI_finish(void); extern int SPI_execute(const char *src, bool read_only, long tcount); +extern int SPI_execute_extended(const char *src, + const SPIExecuteOptions *options); extern int SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls, bool read_only, long tcount); extern int SPI_execute_plan_extended(SPIPlanPtr plan, @@ -124,10 +134,6 @@ extern int SPI_execute_with_args(const char *src, int nargs, Oid *argtypes, Datum *Values, const char *Nulls, bool read_only, long tcount); -extern int SPI_execute_with_receiver(const char *src, - ParamListInfo params, - bool read_only, long tcount, - DestReceiver *dest); extern SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes); extern SPIPlanPtr SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes, int cursorOptions); @@ -178,11 +184,9 @@ extern Portal SPI_cursor_open_with_args(const char *name, bool read_only, int cursorOptions); extern Portal SPI_cursor_open_with_paramlist(const char *name, SPIPlanPtr plan, ParamListInfo params, bool read_only); -extern Portal SPI_cursor_parse_open_with_paramlist(const char *name, - const char *src, - ParamListInfo params, - bool read_only, - int cursorOptions); +extern Portal SPI_cursor_parse_open(const char *name, + const char *src, + const SPIParseOpenOptions *options); extern Portal SPI_cursor_find(const char *name); extern void SPI_cursor_fetch(Portal portal, bool forward, long count); extern void SPI_cursor_move(Portal portal, bool forward, long count); |