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

pgsql: Avoid a premature coercion failure in transformSetOperationTree()

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid a premature coercion failure in transformSetOperationTree()
Date: 2009-12-16 22:24:13
Message-ID: 20091216222413.7CA43753FB7@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Avoid a premature coercion failure in transformSetOperationTree() when
presented with an UNKNOWN-type Var, which can happen in cases where an
unknown literal appeared in a subquery.  While many such cases will fail
later on anyway in the planner, there are some cases where the planner is
able to flatten the query and replace the Var by the constant before it has
to coerce the union column to the final type.  I had added this check in 8.4
to provide earlier/better error detection, but it causes a regression for
some cases that worked OK before.  Fix by not making the check if the input
node is UNKNOWN type and not a Const or Param.  If it isn't going to work,
it will fail anyway at plan time, with the only real loss being inability to
provide an error cursor.  Per gripe from Britt Piehler.

In passing, rename a couple of variables to remove confusion from an
inner scope masking the same variable names in an outer scope.

Modified Files:
--------------
    pgsql/src/backend/parser:
        analyze.c (r1.397 -> r1.398)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/analyze.c?r1=1.397&r2=1.398)
    pgsql/src/test/regress/expected:
        union.out (r1.14 -> r1.15)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/union.out?r1=1.14&r2=1.15)
    pgsql/src/test/regress/sql:
        union.sql (r1.8 -> r1.9)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/union.sql?r1=1.8&r2=1.9)

pgsql-committers by date

Next:From: Tom LaneDate: 2009-12-16 22:24:19
Subject: pgsql: Avoid a premature coercion failure in transformSetOperationTree()
Previous:From: Robert HaasDate: 2009-12-16 22:16:16
Subject: pgsql: Several fixes for EXPLAIN (FORMAT YAML), plus one for EXPLAIN

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