postgresql/src/include/optimizer
Tom Lane eea6ada926 Fix SELECT DISTINCT with index-optimized MIN/MAX on inheritance trees.
In a query such as "SELECT DISTINCT min(x) FROM tab", the DISTINCT is
pretty useless (there being only one output row), but nonetheless it
shouldn't fail.  But it could fail if "tab" is an inheritance parent,
because planagg.c's code for fixing up equivalence classes after making the
index-optimized MIN/MAX transformation wasn't prepared to find child-table
versions of the aggregate expression.  The least ugly fix seems to be
to add an option to mutate_eclass_expressions() to skip child-table
equivalence class members, which aren't used anymore at this stage of
planning so it's not really necessary to fix them.  Since child members
are ignored in many cases already, it seems plausible for
mutate_eclass_expressions() to have an option to ignore them too.

Per bug #7703 from Maxim Boguk.

Back-patch to 9.1.  Although the same code exists before that, it cannot
encounter child-table aggregates AFAICS, because the index optimization
transformation cannot succeed on inheritance trees before 9.1 (for lack
of MergeAppend).
2012-11-26 12:58:08 -05:00
..
clauses.h Make equal() ignore CoercionForm fields for better planning with casts. 2012-10-12 12:10:55 -04:00
cost.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
geqo.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_copy.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_gene.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_misc.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_mutation.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_pool.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_random.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_recombination.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
geqo_selection.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
joininfo.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
pathnode.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
paths.h Fix SELECT DISTINCT with index-optimized MIN/MAX on inheritance trees. 2012-11-26 12:58:08 -05:00
placeholder.h Revisit handling of UNION ALL subqueries with non-Var output columns. 2012-03-16 13:11:55 -04:00
plancat.h Fix planner to pass correct collation to operator selectivity estimators. 2012-07-08 23:51:13 -04:00
planmain.h Fix planning of non-strict equivalence clauses above outer joins. 2012-10-18 12:30:25 -04:00
planner.h Account for SRFs in targetlists in planner rowcount estimates. 2012-07-21 17:45:15 -04:00
predtest.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
prep.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
restrictinfo.h Revise parameterized-path mechanism to fix assorted issues. 2012-04-19 15:53:47 -04:00
subselect.h Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
tlist.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
var.h Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00