postgresql/contrib/cube
Peter Eisentraut 802fe923e3 cube: 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.  (Actually, we
use yy_scan_bytes() here because we already have the length.)

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
2024-12-18 08:47:34 +01:00
..
data Gene Selkov's CUBE datatype (GiST example code) 2000-12-11 20:39:15 +00:00
expected Rework pg_input_error_message(), now renamed pg_input_error_info() 2023-02-28 08:04:13 +09:00
sql Rework pg_input_error_message(), now renamed pg_input_error_info() 2023-02-28 08:04:13 +09:00
.gitignore Build all Flex files standalone 2022-09-04 12:09:01 +07:00
CHANGES Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
cube--1.0--1.1.sql Fix whitespace 2015-12-19 11:46:38 -05:00
cube--1.1--1.2.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
cube--1.2--1.3.sql Distinguish selectivity of < from <= and > from >=. 2017-09-13 11:12:39 -04:00
cube--1.2.sql Update extensions with GIN/GIST support for parallel query. 2016-06-14 13:34:37 -04:00
cube--1.3--1.4.sql Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
cube--1.4--1.5.sql Add binary I/O capability for cube datatype. 2021-03-06 12:04:05 -05:00
cube.c cube: pure parser and reentrant scanner 2024-12-18 08:47:34 +01:00
cube.control Remove deprecated containment operators for contrib types. 2021-03-05 10:45:41 -05:00
cubedata.h cube: pure parser and reentrant scanner 2024-12-18 08:47:34 +01:00
cubeparse.y cube: pure parser and reentrant scanner 2024-12-18 08:47:34 +01:00
cubescan.l cube: pure parser and reentrant scanner 2024-12-18 08:47:34 +01:00
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00