diff options
| author | Peter Eisentraut | 2024-12-02 09:35:37 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2024-12-24 17:05:06 +0000 |
| commit | db6856c9913f1af08b5d7bde442fae362913190a (patch) | |
| tree | e14b8b098387555ada5ba2534606c02c0ca14104 /src/include | |
| parent | e4a8fb8fefb903fe601f7415098a4fe39a14069a (diff) | |
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
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/replication/syncrep.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/include/replication/syncrep.h b/src/include/replication/syncrep.h index ea439e6da60..3fe44a880cf 100644 --- a/src/include/replication/syncrep.h +++ b/src/include/replication/syncrep.h @@ -100,10 +100,15 @@ extern void SyncRepUpdateSyncStandbysDefined(void); * Internal functions for parsing synchronous_standby_names grammar, * in syncrep_gram.y and syncrep_scanner.l */ -extern int syncrep_yyparse(void); -extern int syncrep_yylex(void); -extern void syncrep_yyerror(const char *str); -extern void syncrep_scanner_init(const char *str); -extern void syncrep_scanner_finish(void); +union YYSTYPE; +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void *yyscan_t; +#endif +extern int syncrep_yyparse(yyscan_t yyscanner); +extern int syncrep_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner); +extern void syncrep_yyerror(yyscan_t yyscanner, const char *str); +extern void syncrep_scanner_init(const char *str, yyscan_t *yyscannerp); +extern void syncrep_scanner_finish(yyscan_t yyscanner); #endif /* _SYNCREP_H */ |
