Обсуждение: pgsql: Improve handling of unknown-type literals in UNION/INTERSECT/EXC

Поиск
Список
Период
Сортировка

pgsql: Improve handling of unknown-type literals in UNION/INTERSECT/EXC

От
Tom Lane
Дата:
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/72cfc17aef4fc9aa2de1c82045b7d609c0f2c513

Modified Files
--------------
src/backend/parser/analyze.c |  150 +++++++++++++++++++++++++++---------------
1 files changed, 96 insertions(+), 54 deletions(-)