pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: ecpg: improve preprocessor's memory management.
Date: Mon, 14 Oct 2024 17:55:19 +0000
Message-ID: <E1t0PHs-000p5U-4k@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1t0PHs-000p5U-4k@gemulon.postgresql.org>
Permalink:  ../E1t0PHs-000p5U-4k@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1t0PHs-000p5U-4k@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: ecpg: improve preprocessor's memory management.
  In-Reply-To: <E1t0PHs-000p5U-4k@gemulon.postgresql.org>
  References: <E1t0PHs-000p5U-4k@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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