From 3e4bacb171001644583ac14e29ae1b09ce818c92 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 19 Dec 2024 15:37:44 +0100 Subject: bootstrap: 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. For the bootstrap scanner and parser, reentrancy and memory management aren't that important, but we make this change here anyway so that all the scanners and parsers in the backend use a similar set of options and APIs. Reviewed-by: Heikki Linnakangas Reviewed-by: Andreas Karlsson Discussion: https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b@eisentraut.org --- src/backend/bootstrap/bootstrap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/backend/bootstrap/bootstrap.c') diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index f3a7a007f77..d35ccab4873 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -202,6 +202,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) int flag; char *userDoption = NULL; uint32 bootstrap_data_checksum_version = 0; /* No checksum */ + yyscan_t scanner; Assert(!IsUnderPostmaster); @@ -378,11 +379,14 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) Nulls[i] = false; } + if (boot_yylex_init(&scanner) != 0) + elog(ERROR, "yylex_init() failed: %m"); + /* * Process bootstrap input. */ StartTransactionCommand(); - boot_yyparse(); + boot_yyparse(scanner); CommitTransactionCommand(); /* -- cgit v1.2.3