Add the ability for the core grammar to have more than one parse target.
Tom Lane <tgl@sss.pgh.pa.us>
Add the ability for the core grammar to have more than one parse target. This patch essentially allows gram.y to implement a family of related syntax trees, rather than necessarily always parsing a list of SQL statements. raw_parser() gains a new argument, enum RawParseMode, to say what to do. As proof of concept, add a mode that just parses a TypeName without any other decoration, and use that to greatly simplify typeStringToTypeName(). In addition, invent a new SPI entry point SPI_prepare_extended() to allow SPI users (particularly plpgsql) to get at this new functionality. In hopes of making this the last variant of SPI_prepare(), set up its additional arguments as a struct rather than direct arguments, and promise that future additions to the struct can default to zero. SPI_prepare_cursor() and SPI_prepare_params() can perhaps go away at some point. Discussion: https://postgr.es/m/4165684.1607707277@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/spi.sgml | modified | +126 −0 |
| src/backend/commands/tablecmds.c | modified | +1 −1 |
| src/backend/executor/spi.c | modified | +49 −3 |
| src/backend/parser/gram.y | modified | +20 −2 |
| src/backend/parser/parse_coerce.c | modified | +3 −2 |
| src/backend/parser/parser.c | modified | +21 −6 |
| src/backend/parser/parse_type.c | modified | +5 −59 |
| src/backend/tcop/postgres.c | modified | +1 −1 |
| src/include/executor/spi.h | modified | +12 −1 |
| src/include/executor/spi_priv.h | modified | +1 −0 |
| src/include/parser/parser.h | modified | +19 −1 |
| src/interfaces/ecpg/preproc/parse.pl | modified | +1 −1 |
| src/pl/plpgsql/src/pl_exec.c | modified | +8 −5 |
| src/pl/plpgsql/src/pl_gram.y | modified | +1 −1 |
Documentation touched
Discussion
- Rethinking plpgsql's assignment implementation 21 messages · 2020-12-11 → 2021-01-20