pgsql: jsonpath scanner: reentrant scanner

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: jsonpath scanner: reentrant scanner
Date: 2024-12-24 22:42:56
Message-ID: E1tQDc8-001Axi-Ea@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

jsonpath scanner: reentrant scanner

Use the flex %option reentrant to make the generated scanner
reentrant and thread-safe. Note: The parser was already pure.

Simplify flex scan buffer management: Instead of constructing the
buffer from pieces and then using yy_scan_buffer(), we can just use
yy_scan_string(), which does the same thing internally. (Actually, we
use yy_scan_bytes() here because we already have the length.)

Use flex yyextra to handle context information, instead of global
variables. This complements the other changes to make the scanner
reentrant.

Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Reviewed-by: Andreas Karlsson <andreas(at)proxel(dot)se>
Discussion: https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b(at)eisentraut(dot)org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2a7425d7eef9b4b848763fb920fefa23c3c43f31

Modified Files
--------------
src/backend/nls.mk | 2 +-
src/backend/utils/adt/jsonpath_gram.y | 2 +
src/backend/utils/adt/jsonpath_internal.h | 12 +-
src/backend/utils/adt/jsonpath_scan.l | 283 ++++++++++++++----------------
4 files changed, 145 insertions(+), 154 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2024-12-25 13:49:16 pgsql: guc: reentrant scanner
Previous Message Peter Geoghegan 2024-12-24 19:07:10 pgsql: Fix nbtree symbol name comment reference.