aboutsummaryrefslogtreecommitdiff
path: root/src/tutorial/complex.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-12-13 13:20:16 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-12-13 13:20:16 -0500
commit997a2994eef372d06798d2f3409a76098c1590a1 (patch)
tree76de00cc84eeaeab71e9fd59c822ecddb0067050 /src/tutorial/complex.c
parentace0df9345c9fe61570348f2a5c3324a726fd4fa (diff)
downloadpostgresql-997a2994eef372d06798d2f3409a76098c1590a1.tar.gz
postgresql-997a2994eef372d06798d2f3409a76098c1590a1.zip
Prevent planagg.c from failing on queries containing CTEs.
The existing tests in preprocess_minmax_aggregates() usually prevent it from trying to do anything with queries containing CTEs, but there's an exception: a CTE could be present as a member of an appendrel, if we flattened a UNION ALL that contains CTE references. If it did try to generate an optimized path for a query using a CTE, it failed with "could not find plan for CTE", as reported by Torsten Förtsch. The proximate cause is an unwise decision in commit 3fc6e2d7f to clear subroot->cte_plan_ids in build_minmax_path(). That left the subroot's cte_plan_ids list out of step with its parse->cteList. Removing the "subroot->cte_plan_ids = NIL;" assignment is enough to let the case work again, but really it's pretty silly to be expending any cycles at all in this module when there are CTEs: we always treat their outputs as unordered so there's no way for the optimization to win. Hence, also add an early-exit test so we don't waste time like that. Back-patch to 9.6 where the misbehavior was introduced. Report: https://postgr.es/m/CAKkG4_=gjY5QiHtqSZyWMwDuTd_CftKoTaCqxjJ7uUz1-Gw=qw@mail.gmail.com
Diffstat (limited to 'src/tutorial/complex.c')
0 files changed, 0 insertions, 0 deletions