]> granicus.if.org Git - postgresql/commit
Improve handling of unknown-type literals in UNION/INTERSECT/EXCEPT.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Mar 2011 01:51:36 +0000 (21:51 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Mar 2011 01:52:10 +0000 (21:52 -0400)
commit72cfc17aef4fc9aa2de1c82045b7d609c0f2c513
tree280dcc2e9b885f7632b5bbdb1bf06204b6ebd1b4
parent898a14e1a0ba845c957f42f205495af932fcf017
Improve handling of unknown-type literals in UNION/INTERSECT/EXCEPT.

This patch causes unknown-type Consts to be coerced to the resolved output
type of the set operation at parse time.  Formerly such Consts were left
alone until late in the planning stage.  The disadvantage of that approach
is that it disables some optimizations, because the planner sees the set-op
leaf query as having different output column types than the overall set-op.
We saw an example of that in a recent performance gripe from Claudio
Freire.

Fixing such a Const requires scribbling on the leaf query in
transformSetOperationTree, but that should be all right since if the leaf
query's semantics depended on that output column, it would already have
resolved the unknown to something else.

Most of the bulk of this patch is a simple adjustment of
transformSetOperationTree's API so that upper levels can get at the
TargetEntry containing a Const to be replaced: it now returns a list of
TargetEntries, instead of just the bare expressions.
src/backend/parser/analyze.c