aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-09-23 19:34:56 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-09-23 19:40:34 +0000
commitcd198f81f31ad169627645a13c201b95ad881867 (patch)
tree8902f90c7ef4e4bde517b28d4f48a23bb9e29a40 /src
parentbe622060ddecdbdebb8fb8e438e70a5bb51d186c (diff)
downloadpostgresql-cd198f81f31ad169627645a13c201b95ad881867.tar.gz
postgresql-cd198f81f31ad169627645a13c201b95ad881867.zip
Avoid sharing subpath list structure when flattening nested AppendRels.
In some situations the original coding led to corrupting the child AppendRel's subpaths list, effectively adding other members of the parent's list to it. This was usually masked because we never made any further use of the child's list, but given the right combination of circumstances, we could do so. The visible symptom would be a relation getting scanned twice, as in bug #5673 from David Schmitt. Backpatch to 8.2, which is as far back as the risky coding appears. The example submitted by David only fails in 8.4 and later, but I'm not convinced that there aren't any even-more-obscure cases where 8.2 and 8.3 would fail.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/path/allpaths.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index cd15054a314..7704091db23 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -425,7 +425,7 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
childpath = childrel->cheapest_total_path;
if (IsA(childpath, AppendPath))
subpaths = list_concat(subpaths,
- ((AppendPath *) childpath)->subpaths);
+ list_copy(((AppendPath *) childpath)->subpaths));
else
subpaths = lappend(subpaths, childpath);