pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix planner failure in some cases of sorting by an aggregate. 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix planner failure in some cases of sorting by an aggregate. @ 2021-04-20 15:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-04-20 15:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7bfba4f1933003716d432d29d4d228bcf28e2e70 Modified Files -------------- src/backend/optimizer/path/equivclass.c | 255 ++++++++++++++++++++----- src/backend/optimizer/plan/createplan.c | 118 +----------- src/include/optimizer/paths.h | 8 + src/test/regress/expected/incremental_sort.out | 26 +++ src/test/regress/sql/incremental_sort.sql | 7 + 5 files changed, 262 insertions(+), 152 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix planner failure in some cases of sorting by an aggregate. @ 2021-04-20 15:37 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-04-20 15:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/375398244168add84a884347625d14581a421e71 Modified Files -------------- src/backend/optimizer/path/equivclass.c | 255 ++++++++++++++++++++----- src/backend/optimizer/plan/createplan.c | 118 +----------- src/backend/optimizer/util/tlist.c | 28 --- src/include/optimizer/paths.h | 8 + src/include/optimizer/tlist.h | 1 - src/test/regress/expected/incremental_sort.out | 26 +++ src/test/regress/sql/incremental_sort.sql | 7 + 7 files changed, 262 insertions(+), 181 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-04-20 15:37 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-04-20 15:37 pgsql: Fix planner failure in some cases of sorting by an aggregate. Tom Lane <tgl@sss.pgh.pa.us> 2021-04-20 15:37 pgsql: Fix planner failure in some cases of sorting by an aggregate. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox