diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-12 11:20:18 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-12 11:20:18 -0400 |
commit | 5ee190f8ec37c1bbfb3061e18304e155d600bc8e (patch) | |
tree | 5767a0de205205f91373bd5645f9c09bd046b0cf /src/backend/optimizer/util/tlist.c | |
parent | 251c8e39bc6b0a3ff1620d9ac10888a7660e6b88 (diff) |
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
Diffstat (limited to 'src/backend/optimizer/util/tlist.c')
-rw-r--r-- | src/backend/optimizer/util/tlist.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index 7ccb10e4e1b..d75796ac8b9 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -665,9 +665,8 @@ make_tlist_from_pathtarget(PathTarget *target) * copy_pathtarget * Copy a PathTarget. * - * The new PathTarget has its own List cells, but shares the underlying - * target expression trees with the old one. We duplicate the List cells - * so that items can be added to one target without damaging the other. + * The new PathTarget has its own exprs List, but shares the underlying + * target expression trees with the old one. */ PathTarget * copy_pathtarget(PathTarget *src) |