From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Rationalize use of list_concat + list_copy combinations.
Date: Mon, 12 Aug 2019 15:20:27 +0000
Message-ID: <E1hxC7X-0003GP-DX@gemulon.postgresql.org> (raw)
Rationalize use of list_concat + list_copy combinations.
In the wake of commit 1cff1b95a, the result of list_concat no longer
shares the ListCells of the second input. Therefore, we can replace
"list_concat(x, list_copy(y))" with just "list_concat(x, y)".
To improve call sites that were list_copy'ing the first argument,
or both arguments, invent "list_concat_copy()" which produces a new
list sharing no ListCells with either input. (This is a bit faster
than "list_concat(list_copy(x), y)" because it makes the result list
the right size to start with.)
In call sites that were not list_copy'ing the second argument, the new
semantics mean that we are usually leaking the second List's storage,
since typically there is no remaining pointer to it. We considered
inventing another list_copy variant that would list_free the second
input, but concluded that for most call sites it isn't worth worrying
about, given the relative compactness of the new List representation.
(Note that in cases where such leakage would happen, the old code
already leaked the second List's header; so we're only discussing
the size of the leak not whether there is one. I did adjust two or
three places that had been troubling to free that header so that
they manually free the whole second List.)
Patch by me; thanks to David Rowley for review.
Discussion: https://postgr.es/m/11587.1550975080@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/5ee190f8ec37c1bbfb3061e18304e155d600bc8e
Modified Files
--------------
contrib/postgres_fdw/deparse.c | 2 +-
contrib/postgres_fdw/postgres_fdw.c | 14 ++++----
src/backend/commands/indexcmds.c | 4 +--
src/backend/executor/functions.c | 3 +-
src/backend/nodes/list.c | 50 ++++++++++++++++++++++++----
src/backend/optimizer/path/allpaths.c | 13 +++-----
src/backend/optimizer/path/costsize.c | 3 +-
src/backend/optimizer/path/indxpath.c | 18 ++++-------
src/backend/optimizer/plan/createplan.c | 4 +--
src/backend/optimizer/plan/initsplan.c | 1 -
src/backend/optimizer/plan/planner.c | 13 +++-----
src/backend/optimizer/plan/setrefs.c | 2 +-
src/backend/optimizer/prep/prepjointree.c | 1 -
src/backend/optimizer/prep/prepqual.c | 12 -------
src/backend/optimizer/util/clauses.c | 54 ++++++++++++-------------------
src/backend/optimizer/util/orclauses.c | 2 +-
src/backend/optimizer/util/relnode.c | 34 +++++++++----------
src/backend/optimizer/util/tlist.c | 5 ++-
src/backend/parser/parse_agg.c | 12 +++----
src/backend/parser/parse_clause.c | 5 ---
src/backend/partitioning/partprune.c | 8 ++---
src/backend/replication/syncrep.c | 5 +--
src/backend/rewrite/rewriteHandler.c | 8 ++---
src/backend/utils/adt/ruleutils.c | 2 +-
src/backend/utils/adt/selfuncs.c | 1 -
src/include/nodes/pg_list.h | 2 ++
26 files changed, 130 insertions(+), 148 deletions(-)
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: Rationalize use of list_concat + list_copy combinations.
In-Reply-To: <E1hxC7X-0003GP-DX@gemulon.postgresql.org>
References: <E1hxC7X-0003GP-DX@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