pgsql: Fix set_subquery_pathlist() to copy the RTE's subquery before it

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix set_subquery_pathlist() to copy the RTE's subquery before it
Date: 2009-03-10 20:58:41
Message-ID: 20090310205841.AE64A754AD4@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix set_subquery_pathlist() to copy the RTE's subquery before it gets mangled
by the planning process. This prevents the "failed to locate grouping columns"
error recently reported by Dickson Guedes. That happens because planning
replaces SubLinks by SubPlans in the subquery's targetlist, and exprTypmod()
is smarter about the former than the latter, causing the apparent type of
the subquery's output columns to change. This seems to be a deficiency we
should fix in exprTypmod(), but that will be a much more invasive patch
with possible side-effects elsewhere, so I'll do that only in HEAD.

Back-patch to 8.3. Arguably the lack of a copying step is broken/dangerous
all the way back, but in the absence of known problems I'll refrain from
making the older branches pay the extra cost. (The reason this particular
symptom didn't appear before is that exprTypmod() wasn't smart about SubLinks
either, until 8.3.)

Tags:
----
REL8_3_STABLE

Modified Files:
--------------
pgsql/src/backend/optimizer/path:
allpaths.c (r1.168.2.3 -> r1.168.2.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/allpaths.c?r1=1.168.2.3&r2=1.168.2.4)
pgsql/src/test/regress/expected:
subselect.out (r1.16.2.2 -> r1.16.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/subselect.out?r1=1.16.2.2&r2=1.16.2.3)
pgsql/src/test/regress/sql:
subselect.sql (r1.11.2.2 -> r1.11.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/subselect.sql?r1=1.11.2.2&r2=1.11.2.3)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2009-03-10 22:09:26 pgsql: Make SubPlan nodes carry the result's typmod as well as datatype
Previous Message Tom Lane 2009-03-10 20:58:26 pgsql: Fix set_subquery_pathlist() to copy the RTE's subquery before it