• Tom Lane's avatar
    Improve handling of unknown-type literals in UNION/INTERSECT/EXCEPT. · 72cfc17a
    Tom Lane authored
    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.
    72cfc17a
analyze.c 71.9 KB