Skip to content

Commit e2dc3f5

Browse files
committed
Get rid of redundant production in plpgsql grammar.
There may once have been a reason for the intermediate proc_stmts production in the plpgsql grammar, but it isn't doing anything useful anymore, so let's collapse it into proc_sect. Saves some code and probably a small number of nanoseconds per statement list. In passing, correctly alphabetize keyword lists to match pl_scanner.c; note that for "rowtype" vs "row_count", pl_scanner.c must sort on the basis of the lower-case spelling. Noted while fooling with a patch to de-reserve more plpgsql keywords.
1 parent 02d5ab6 commit e2dc3f5

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/pl/plpgsql/src/pl_gram.y

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt);
188188

189189
%type <str> any_identifier opt_block_label opt_label option_value
190190

191-
%type <list> proc_sect proc_stmts stmt_elsifs stmt_else
191+
%type <list> proc_sect stmt_elsifs stmt_else
192192
%type <loop_body> loop_body
193193
%type <stmt> proc_stmt pl_block
194194
%type <stmt> stmt_assign stmt_if stmt_loop stmt_while stmt_exit
@@ -318,8 +318,8 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt);
318318
%token <keyword> K_RETURN
319319
%token <keyword> K_RETURNED_SQLSTATE
320320
%token <keyword> K_REVERSE
321-
%token <keyword> K_ROWTYPE
322321
%token <keyword> K_ROW_COUNT
322+
%token <keyword> K_ROWTYPE
323323
%token <keyword> K_SCHEMA
324324
%token <keyword> K_SCHEMA_NAME
325325
%token <keyword> K_SCROLL
@@ -838,24 +838,14 @@ assign_operator : '='
838838

839839
proc_sect :
840840
{ $$ = NIL; }
841-
| proc_stmts
842-
{ $$ = $1; }
843-
;
844-
845-
proc_stmts : proc_stmts proc_stmt
846-
{
847-
if ($2 == NULL)
848-
$$ = $1;
849-
else
850-
$$ = lappend($1, $2);
851-
}
852-
| proc_stmt
853-
{
854-
if ($1 == NULL)
855-
$$ = NIL;
856-
else
857-
$$ = list_make1($1);
858-
}
841+
| proc_sect proc_stmt
842+
{
843+
/* don't bother linking null statements into list */
844+
if ($2 == NULL)
845+
$$ = $1;
846+
else
847+
$$ = lappend($1, $2);
848+
}
859849
;
860850

861851
proc_stmt : pl_block ';'
@@ -2356,8 +2346,8 @@ unreserved_keyword :
23562346
| K_PG_EXCEPTION_CONTEXT
23572347
| K_PG_EXCEPTION_DETAIL
23582348
| K_PG_EXCEPTION_HINT
2359-
| K_PRIOR
23602349
| K_PRINT_STRICT_PARAMS
2350+
| K_PRIOR
23612351
| K_QUERY
23622352
| K_RELATIVE
23632353
| K_RESULT_OID

0 commit comments

Comments
 (0)