pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: seg: pure parser and reentrant scanner
3+ messages / 2 participants
[nested] [flat]
* pgsql: seg: pure parser and reentrant scanner
@ 2024-12-18 07:57 Peter Eisentraut <peter@eisentraut.org>
2024-12-18 16:57 ` Re: pgsql: seg: pure parser and reentrant scanner Melanie Plageman <melanieplageman@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Eisentraut @ 2024-12-18 07:57 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
seg: 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. As a result, there could be
some small memory leaks in case of uncaught errors. (We do catch
normal syntax errors as soft errors.) Now, all the memory is under
palloc() control, so there are no more such issues.
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.
(We could even get rid of the yylex_destroy() call and just let the
memory context cleanup handle everything. But for now, we preserve
the existing behavior.)
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/1f0de66ea2a5549a3768c67434e28a136c280571
Modified Files
--------------
contrib/seg/seg.c | 9 ++---
contrib/seg/segdata.h | 13 +++++---
contrib/seg/segparse.y | 9 ++---
contrib/seg/segscan.l | 90 +++++++++++++++++++++++++++++---------------------
4 files changed, 72 insertions(+), 49 deletions(-)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: seg: pure parser and reentrant scanner
2024-12-18 07:57 pgsql: seg: pure parser and reentrant scanner Peter Eisentraut <peter@eisentraut.org>
@ 2024-12-18 16:57 ` Melanie Plageman <melanieplageman@gmail.com>
2024-12-19 11:09 ` Re: pgsql: seg: pure parser and reentrant scanner Peter Eisentraut <peter@eisentraut.org>
0 siblings, 1 reply; 3+ messages in thread
From: Melanie Plageman @ 2024-12-18 16:57 UTC (permalink / raw)
To: Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-committers@lists.postgresql.org
On Wed, Dec 18, 2024 at 2:57 AM Peter Eisentraut <peter@eisentraut.org> wrote:
>
> seg: pure parser and reentrant scanner
sifaka is failing [1] with
cubescan.c:348:15: error: redefinition of typedef 'yyscan_t' is a C11
feature [-Werror,-Wtypedef-redefinition]
348 | typedef void* yyscan_t;
| ^
./cubedata.h:65:15: note: previous definition is here
65 | typedef void *yyscan_t;
| ^
1 error generated.
[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sifaka&dt=2024-12-18%2007%3A58%3A13
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pgsql: seg: pure parser and reentrant scanner
2024-12-18 07:57 pgsql: seg: pure parser and reentrant scanner Peter Eisentraut <peter@eisentraut.org>
2024-12-18 16:57 ` Re: pgsql: seg: pure parser and reentrant scanner Melanie Plageman <melanieplageman@gmail.com>
@ 2024-12-19 11:09 ` Peter Eisentraut <peter@eisentraut.org>
0 siblings, 0 replies; 3+ messages in thread
From: Peter Eisentraut @ 2024-12-19 11:09 UTC (permalink / raw)
To: Melanie Plageman <melanieplageman@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org
On 18.12.24 17:57, Melanie Plageman wrote:
> On Wed, Dec 18, 2024 at 2:57 AM Peter Eisentraut <peter@eisentraut.org> wrote:
>>
>> seg: pure parser and reentrant scanner
>
> sifaka is failing [1] with
>
> cubescan.c:348:15: error: redefinition of typedef 'yyscan_t' is a C11
> feature [-Werror,-Wtypedef-redefinition]
> 348 | typedef void* yyscan_t;
> | ^
> ./cubedata.h:65:15: note: previous definition is here
> 65 | typedef void *yyscan_t;
> | ^
> 1 error generated.
>
>
> [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sifaka&dt=2024-12-18%2007%3A58%3A13
Thanks, this is being fixed.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-12-19 11:09 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-18 07:57 pgsql: seg: pure parser and reentrant scanner Peter Eisentraut <peter@eisentraut.org>
2024-12-18 16:57 ` Melanie Plageman <melanieplageman@gmail.com>
2024-12-19 11:09 ` Peter Eisentraut <peter@eisentraut.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox