pure parsers and reentrant scanners
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-12-02T09:46:00Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Return yyparse() result not via global variable
- 473a575e0597 18.0 landed
-
Remove flex version checks
- 0869ea43e9c2 18.0 landed
-
Drop warning-free support for Flex 2.5.35
- 6fdd5d956343 18.0 landed
-
plpgsql: pure parser and reentrant scanner
- 7b27f5fd36cb 18.0 landed
-
flex code modernization: Replace YY_EXTRA_TYPE define with flex option
- b1ef48980ddd 18.0 landed
-
guc: reentrant scanner
- d663f150b5ed 18.0 landed
-
jsonpath scanner: reentrant scanner
- 2a7425d7eef9 18.0 landed
-
syncrep parser: pure parser and reentrant scanner
- db6856c9913f 18.0 landed
-
replication parser: pure parser and reentrant scanner
- e4a8fb8fefb9 18.0 landed
-
bootstrap: pure parser and reentrant scanner
- 3e4bacb17100 18.0 landed
-
Small whitespace improvement
- 399d0f1e11b5 18.0 landed
-
Prevent redeclaration of typedef yyscan_t
- 382092a0cd2c 18.0 landed
-
seg: pure parser and reentrant scanner
- 1f0de66ea2a5 18.0 landed
-
cube: pure parser and reentrant scanner
- 802fe923e3cd 18.0 landed
Attachments
- v0-0001-cube-pure-parser-and-reentrant-scanner.patch (text/plain) patch v0-0001
- v0-0002-cube-Use-palloc-instead-of-malloc-for-flex.patch (text/plain) patch v0-0002
- v0-0003-cube-Simplify-flex-scan-buffer-management.patch (text/plain) patch v0-0003
- v0-0004-seg-pure-parser-and-reentrant-scanner.patch (text/plain) patch v0-0004
- v0-0005-seg-Use-palloc-instead-of-malloc-for-flex.patch (text/plain) patch v0-0005
- v0-0006-seg-Simplify-flex-scan-buffer-management.patch (text/plain) patch v0-0006
- v0-0007-replication-parser-pure-parser-and-reentrant-scan.patch (text/plain) patch v0-0007
- v0-0008-replication-parser-Use-palloc-instead-of-malloc-f.patch (text/plain) patch v0-0008
- v0-0009-replication-parser-Simplify-flex-scan-buffer-mana.patch (text/plain) patch v0-0009
- v0-0010-syncrep-parser-pure-parser-and-reentrant-scanner.patch (text/plain) patch v0-0010
- v0-0011-syncrep-parser-Use-palloc-instead-of-malloc-for-f.patch (text/plain) patch v0-0011
- v0-0012-syncrep-parser-Simplify-flex-scan-buffer-manageme.patch (text/plain) patch v0-0012
- v0-0013-syncrep-parser-Use-flex-yyextra.patch (text/plain) patch v0-0013
- v0-0014-jsonpath-scanner-reentrant-scanner.patch (text/plain) patch v0-0014
- v0-0015-jsonpath-scanner-Use-flex-yyextra.patch (text/plain) patch v0-0015
This patch series changes several parsers in the backend and contrib modules to use bison pure parsers and flex reentrant scanners. This is ultimately toward thread-safety, but I think it's also just nicer in general, and it might also fix a few possible small memory leaks. I organized this patch series into very small incremental changes so that it's easier to follow. The final commits should probably combined a bit more (e.g., one per module). In this patch series I have so far dealt with * contrib/cube/ * contrib/seg/ * src/backend/replication/repl_* * src/backend/replication/syncrep_* These four needed the whole treatment: pure parser, reentrant scanner, and updated memory handling. Also: * src/backend/utils/adt/jsonpath_scan.l This one already had a pure parser and palloc-based memory handling, but not a reentrant scanner, so I just did that. The above are all pretty similar, so it was relatively easy to work through them once I had the first one figured out. A couple of things that are still missing in the above: * For repl_scanner.l, I want to use yyextra to deal with the static variables marked /*FIXME*/, but somehow I made that buggy, I'll need to take another look later. * For both the replication parser and the syncrep parser, get rid of the global variables to pass back the results. Again, here I need another look later. I confused either myself or the compiler on these. cube, seg, and jsonpath are about as done as I would want them to be. Not done yet: * src/backend/utils/misc/guc-file.l * src/pl/plpgsql/src/pl_gram.y These have quite different structures and requirements, so I plan to deal with them separately. Not relevant for backend thread-safety: * src/backend/bootstrap/ It might make sense to eventually covert that one as well, just so that the APIs are kept similar. But that could be for later. Note that the core scanner and parser are already reentrant+pure. Also, there are various other scanners and parsers in frontends (psql, pgbench, ecpg) that are not relevant for this. (Again, it might make sense to convert some of them later, and some of them are already done.) AFAICT, all the options and coding techniques used here are already in use elsewhere in the tree, so there shouldn't be any concerns about bison or flex version compatibility.