aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pg_locale.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-10-14 13:44:42 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2024-10-14 13:44:42 -0400
commita542d5614bdb6430094556162b9ca2f01d35f9dc (patch)
treea3171cd3c51af3c76b49c23876636dc601197bb0 /src/backend/utils/adt/pg_locale.c
parent6b005499447512abfa1e4add87dcf3e2859c4f9e (diff)
downloadpostgresql-a542d5614bdb6430094556162b9ca2f01d35f9dc.tar.gz
postgresql-a542d5614bdb6430094556162b9ca2f01d35f9dc.zip
ecpg: re-implement preprocessor's string management.
Most productions in the preprocessor grammar construct strings representing SQL or C statements or fragments thereof. Instead of returning these as <str> results of the productions, return them as "location" values, taking advantage of Bison's flexibility about what a location is. We aren't really giving up anything thereby, since ecpg's error reports have always just given line numbers, and that's tracked separately. The advantage of this is that a single instance of the YYLLOC_DEFAULT macro can perform all the work needed by the vast majority of productions, including all the ones made automatically by parse.pl. This avoids having large numbers of effectively-identical productions, which tickles an optimization inefficiency in recent versions of clang. (This patch reduces the compilation time for preproc.o by more than 100-fold with clang 16, and is visibly helpful with gcc too.) The compiled parser is noticeably smaller as well. A disadvantage of this approach is that YYLLOC_DEFAULT is applied before running the production's semantic action (if any). This means it cannot use the method favored by cat_str() of free'ing all the input strings; if the action needs to look at the input strings, it'd be looking at dangling storage. As this stands, therefore, it leaks memory like a sieve. This is already a big patch though, and fixing the memory management seems like a separable problem, so let's leave that for the next step. (This does remove some free() calls that I'd have had to touch anyway, in the expectation that the next step will manage memory reclamation quite differently.) Most of the changes here are mindless substitution of "@N" for "$N" in grammar rules; see the changes to README.parser for an explanation. Discussion: https://postgr.es/m/2011420.1713493114@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/adt/pg_locale.c')
0 files changed, 0 insertions, 0 deletions