pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: plpgsql: pure parser and reentrant scanner
Date: Wed, 08 Jan 2025 08:29:35 +0000
Message-ID: <E1tVRRX-000T72-25@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1tVRRX-000T72-25@gemulon.postgresql.org>
Permalink:  ../E1tVRRX-000T72-25@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tVRRX-000T72-25@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: plpgsql: pure parser and reentrant scanner
  In-Reply-To: <E1tVRRX-000T72-25@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox