syncrep parser: pure parser and reentrant scanner
Use the flex %option reentrant and the bison option %pure-parser to
make the generated scanner and parser pure, reentrant, and
thread-safe.
Make the generated scanner use palloc() etc. instead of malloc() etc.
Previously, we only used palloc() for the buffer, but flex would still
use malloc() for its internal structures. Now, all the memory is
under palloc() control.
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.
The previous code was necessary because we allocated the buffer with
palloc() and the rest of the state was handled by malloc(). But this
is no longer the case; everything is under palloc() now.
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@iki.fi>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Discussion: https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b@eisentraut.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/db6856c9913f1af08b5d7bde442fae362913190a
Modified Files
--------------
src/backend/nls.mk | 2 +-
src/backend/replication/syncrep.c | 7 +-
src/backend/replication/syncrep_gram.y | 12 ++--
src/backend/replication/syncrep_scanner.l | 105 +++++++++++++++++++-----------
src/include/replication/syncrep.h | 15 +++--
5 files changed, 90 insertions(+), 51 deletions(-)