pgsql: plpgsql: pure parser and reentrant scanner - Mailing list pgsql-committers

From Peter Eisentraut
Subject pgsql: plpgsql: pure parser and reentrant scanner
Date
Msg-id E1tVRRX-000T72-25@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
plpgsql: pure parser and reentrant scanner

The plpgsql scanner is a wrapper around the core scanner, which
already uses the flex %option reentrant.  This patch only pushes up a
few levels the place where the scanner handle is allocated.  Before,
it was allocated in pl_scanner.c in a global variable, so to the
outside the scanner was not reentrant.  Now, it is allocated in
pl_comp.c and is passed as an argument to yyparse(), similar to how it
is handled in other reentrant scanners.

Also use flex yyextra to handle context information, instead of global
variables.  Again, this uses the existing yyextra support in the core
scanner.  This complements the other changes to make the scanner
reentrant.

The bison option %pure-parser is used to make the generated parser
pure.  This happens in the usual way, since plpgsql has its own bison
parser definition.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b@eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7b27f5fd36cb3270e8ac25aefd73b552663d1392

Modified Files
--------------
src/pl/plpgsql/src/nls.mk       |   2 +-
src/pl/plpgsql/src/pl_comp.c    |  47 ++-
src/pl/plpgsql/src/pl_gram.y    | 820 +++++++++++++++++++++-------------------
src/pl/plpgsql/src/pl_scanner.c | 233 ++++++------
src/pl/plpgsql/src/plpgsql.h    |  33 +-
5 files changed, 598 insertions(+), 537 deletions(-)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Remove useless function declaration
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Set exit status for pgindent if pg_bsd_indent fails