OSDN Git Service

Avoid sharing subpath list structure when flattening nested AppendRels.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Sep 2010 19:34:56 +0000 (15:34 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 23 Sep 2010 19:34:56 +0000 (15:34 -0400)
commitee63981c1fe26299162b9c7f1218d7e3ef802409
treee2bac3a19ca08c466d92e9e722fe2e66a9b7261a
parent003788e81e7f72bc545b509e1517a672d891273b
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.
src/backend/optimizer/path/allpaths.c