postgresql/src/include/optimizer
Tom Lane fcf9ecad57 In locate_grouping_columns(), don't expect an exact match of Var typmods.
It's possible that inlining of SQL functions (or perhaps other changes?)
has exposed typmod information not known at parse time.  In such cases,
Vars generated by query_planner might have valid typmod values while the
original grouping columns only have typmod -1.  This isn't a semantic
problem since the behavior of grouping only depends on type not typmod,
but it breaks locate_grouping_columns' use of tlist_member to locate the
matching entry in query_planner's result tlist.

We can fix this without an excessive amount of new code or complexity by
relying on the fact that locate_grouping_columns only gets called when
make_subplanTargetList has set need_tlist_eval == false, and that can only
happen if all the grouping columns are simple Vars.  Therefore we only need
to search the sub_tlist for a matching Var, and we can reasonably define a
"match" as being a match of the Var identity fields
varno/varattno/varlevelsup.  The code still Asserts that vartype matches,
but ignores vartypmod.

Per bug #8393 from Evan Martin.  The added regression test case is
basically the same as his example.  This has been broken for a very long
time, so back-patch to all supported branches.
2013-08-23 17:30:53 -04:00
..
clauses.h Move strip_implicit_coercions() from optimizer to nodeFuncs.c. 2013-07-23 18:21:19 -04:00
cost.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_copy.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_gene.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_misc.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_mutation.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_pool.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_random.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_recombination.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
geqo_selection.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
joininfo.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pathnode.h Simplify query_planner's API by having it return the top-level RelOptInfo. 2013-08-05 15:01:09 -04:00
paths.h Postpone creation of pathkeys lists to fix bug #8049. 2013-04-29 14:50:03 -04:00
placeholder.h Remove ph_may_need from PlaceHolderInfo, with attendant simplifications. 2013-08-14 18:38:47 -04:00
plancat.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
planmain.h Simplify query_planner's API by having it return the top-level RelOptInfo. 2013-08-05 15:01:09 -04:00
planner.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
predtest.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
prep.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
restrictinfo.h Fix planner problems with LATERAL references in PlaceHolderVars. 2013-08-17 20:22:37 -04:00
subselect.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
tlist.h In locate_grouping_columns(), don't expect an exact match of Var typmods. 2013-08-23 17:30:53 -04:00
var.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00