Skip site navigation (1) Skip section navigation (2)

pgsql: Fix the handling of sub-SELECTs appearing in the arguments of an

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix the handling of sub-SELECTs appearing in the arguments of an
Date: 2009-04-25 16:45:34
Message-ID: 20090425164534.18DE27540A1@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Fix the handling of sub-SELECTs appearing in the arguments of an outer-level
aggregate function.  By definition, such a sub-SELECT cannot reference any
variables of query levels between itself and the aggregate's semantic level
(else the aggregate would've been assigned to that lower level instead).
So the correct, most efficient implementation is to treat the sub-SELECT as
being a sub-select of that outer query level, not the level the aggregate
syntactically appears in.  Not doing so also confuses the heck out of our
parameter-passing logic, as illustrated in bug report from Daniel Grace.

Fortunately, we were already copying the whole Aggref expression up to the
outer query level, so all that's needed is to delay SS_process_sublinks
processing of the sub-SELECT until control returns to the outer level.

This has been broken since we introduced spec-compliant treatment of
outer aggregates in 7.4; so patch all the way back.

Tags:
----
REL7_4_STABLE

Modified Files:
--------------
    pgsql/src/backend/optimizer/plan:
        subselect.c (r1.83.2.2 -> r1.83.2.3)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/subselect.c?r1=1.83.2.2&r2=1.83.2.3)
    pgsql/src/test/regress/expected:
        aggregates.out (r1.10 -> r1.10.4.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/aggregates.out?r1=1.10&r2=1.10.4.1)
    pgsql/src/test/regress/sql:
        aggregates.sql (r1.8 -> r1.8.4.1)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/aggregates.sql?r1=1.8&r2=1.8.4.1)

pgsql-committers by date

Next:From: User GsmetDate: 2009-04-25 17:07:58
Subject: pgfouine - pgfouine: set the garbage collection timeout to 60 seconds
Previous:From: Tom LaneDate: 2009-04-25 16:45:25
Subject: pgsql: Fix the handling of sub-SELECTs appearing in the arguments of an

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group