]> granicus.if.org Git - postgresql/commit
Avoid a premature coercion failure in transformSetOperationTree() when
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Dec 2009 22:24:19 +0000 (22:24 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Dec 2009 22:24:19 +0000 (22:24 +0000)
commit7826bd450b84bfc2fff7ed76895e7d53ce726766
tree7df488993fbb16c5f02e069577262790078ab625
parente5fddc52902f565f55f68df9f08ad0c1f62e8190
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.
src/backend/parser/analyze.c
src/test/regress/expected/union.out
src/test/regress/sql/union.sql