1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-27 21:43:08 +03:00

psql: Refine lexing of BEGIN...END blocks in CREATE FUNCTION statements

Only track BEGIN...END blocks if they are in a CREATE [OR REPLACE]
{FUNCTION|PROCEDURE} statement.  Ignore if in parentheses.

Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://www.postgresql.org/message-id/cee01d26fe55bc086b3bcf10bfe4e8d450e2f608.camel@cybertec.at
This commit is contained in:
Peter Eisentraut
2021-04-16 11:46:01 +02:00
parent 25593d7d33
commit 029c5ac03d
2 changed files with 52 additions and 9 deletions

View File

@@ -114,8 +114,14 @@ typedef struct PsqlScanStateData
int paren_depth; /* depth of nesting in parentheses */
int xcdepth; /* depth of nesting in slash-star comments */
char *dolqstart; /* current $foo$ quote start string */
/*
* State to track boundaries of BEGIN ... END blocks in function
* definitions, so that semicolons do not send query too early.
*/
int identifier_count; /* identifiers since start of statement */
int begin_depth; /* depth of begin/end routine body blocks */
char identifiers[4]; /* records the first few identifiers */
int begin_depth; /* depth of begin/end pairs */
/*
* Callback functions provided by the program making use of the lexer,