mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
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
This commit is contained in:
@@ -18,6 +18,24 @@
|
||||
#include "nodes/parsenodes.h"
|
||||
|
||||
|
||||
/*
|
||||
* RawParseMode determines the form of the string that raw_parser() accepts:
|
||||
*
|
||||
* RAW_PARSE_DEFAULT: parse a semicolon-separated list of SQL commands,
|
||||
* and return a List of RawStmt nodes.
|
||||
*
|
||||
* RAW_PARSE_TYPE_NAME: parse a type name, and return a one-element List
|
||||
* containing a TypeName node.
|
||||
*
|
||||
* ... more to come ...
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RAW_PARSE_DEFAULT = 0,
|
||||
RAW_PARSE_TYPE_NAME
|
||||
} RawParseMode;
|
||||
|
||||
/* Values for the backslash_quote GUC */
|
||||
typedef enum
|
||||
{
|
||||
BACKSLASH_QUOTE_OFF,
|
||||
@@ -32,7 +50,7 @@ extern PGDLLIMPORT bool standard_conforming_strings;
|
||||
|
||||
|
||||
/* Primary entry point for the raw parsing functions */
|
||||
extern List *raw_parser(const char *str);
|
||||
extern List *raw_parser(const char *str, RawParseMode mode);
|
||||
|
||||
/* Utility functions exported by gram.y (perhaps these should be elsewhere) */
|
||||
extern List *SystemFuncName(char *name);
|
||||
|
||||
Reference in New Issue
Block a user