postgresql/src/include/optimizer
Tom Lane 7bfba4f193 Fix planner failure in some cases of sorting by an aggregate.
An oversight introduced by the incremental-sort patches caused
"could not find pathkey item to sort" errors in some situations
where a sort key involves an aggregate or window function.

The basic problem here is that find_em_expr_usable_for_sorting_rel
isn't properly modeling what prepare_sort_from_pathkeys will do
later.  Rather than hoping we can keep those functions in sync,
let's refactor so that they actually share the code for
identifying a suitable sort expression.

With this refactoring, tlist.c's tlist_member_ignore_relabel
is unused.  I removed it in HEAD but left it in place in v13,
in case any extensions are using it.

Per report from Luc Vlaming.  Back-patch to v13 where the
problem arose.

James Coleman and Tom Lane

Discussion: https://postgr.es/m/91f3ec99-85a4-fa55-ea74-33f85a5c651f@swarm64.com
2021-04-20 11:32:02 -04:00
..
appendinfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
clauses.h Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar. 2021-01-21 15:37:23 -05:00
cost.h Remove hashagg_avoid_disk_plan GUC. 2020-07-27 17:53:17 -07:00
geqo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_copy.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_gene.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_misc.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_mutation.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_pool.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_random.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_recombination.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
geqo_selection.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
inherit.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
joininfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
optimizer.h Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar. 2021-01-21 15:37:23 -05:00
orclauses.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
paramassign.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pathnode.h Fix missing outfuncs.c support for IncrementalSortPath. 2020-11-30 16:33:09 -05:00
paths.h Fix planner failure in some cases of sorting by an aggregate. 2021-04-20 11:32:02 -04:00
placeholder.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
plancat.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
planmain.h Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar. 2021-01-21 15:37:23 -05:00
planner.h Allow the planner-related functions and hook to accept the query string. 2020-03-30 13:51:05 +09:00
prep.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
restrictinfo.h Fix pull_varnos' miscomputation of relids set for a PlaceHolderVar. 2021-01-21 15:37:23 -05:00
subselect.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
tlist.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00