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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve handling of unknown-type literals in UNION/INTERSECT/EXC
Date: 2011-03-16 01:52:22
Message-ID: E1PzfuQ-0001gR-2x@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2011-03-16 07:29:50 Re: Re: [COMMITTERS] pgsql: Basic Recovery Control functions for use in Hot Standby. Pause,
Previous Message Bruce Momjian 2011-03-16 00:53:04 pgsql: Remove unused copy_dir() function from pg_upgrade.