pgsql: ecpg: improve preprocessor's memory management. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: ecpg: improve preprocessor's memory management.
Date
Msg-id E1t0PHs-000p5U-4k@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
ecpg: improve preprocessor's memory management.

Invent a notion of "local" storage that will automatically be
reclaimed at the end of each statement.  Use this for location
strings as well as other visibly short-lived data within the parser.

Also, make cat_str and make_str return local storage and not free
their inputs, which allows dispensing with a whole lot of retail
mm_strdup calls.  We do have to add some new ones in places where
a local-lifetime string needs to be added to a longer-lived data
structure, but on balance there are a lot less mm_strdup calls than
before.

In hopes of flushing out places where changes were necessary,
I changed YYLTYPE from "char *" to "const char *", which forced
const-ification of various function arguments that probably
should've been like that all along.

This still leaks somewhat more memory than v17, but that will be
cleaned up in future commits.

Discussion: https://postgr.es/m/2011420.1713493114@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1acd0f55274fab8c936779a0f2b738f6005cc48f

Modified Files
--------------
src/interfaces/ecpg/preproc/descriptor.c     |  32 +-
src/interfaces/ecpg/preproc/ecpg.addons      | 144 ++++---
src/interfaces/ecpg/preproc/ecpg.header      | 167 ++++----
src/interfaces/ecpg/preproc/ecpg.trailer     | 549 ++++++++++++++-------------
src/interfaces/ecpg/preproc/output.c         |   5 +-
src/interfaces/ecpg/preproc/parser.c         |   6 +-
src/interfaces/ecpg/preproc/preproc_extern.h |  36 +-
src/interfaces/ecpg/preproc/type.c           |   8 +-
src/interfaces/ecpg/preproc/type.h           |  30 +-
src/interfaces/ecpg/preproc/util.c           | 119 ++++--
src/interfaces/ecpg/preproc/variable.c       |  31 +-
src/tools/pgindent/typedefs.list             |   1 +
12 files changed, 599 insertions(+), 529 deletions(-)


pgsql-committers by date:

Previous
From: Masahiko Sawada
Date:
Subject: pgsql: Remove obsolete comment in reorderbuffer.h.
Next
From: Jeff Davis
Date:
Subject: pgsql: Move ICU-specific code from pg_locale.c into pg_locale_icu.c.