postgresql/src/backend
David Rowley a5a68dd6d5 Make truncate_useless_pathkeys() consider WindowFuncs
truncate_useless_pathkeys() seems to have neglected to account for
PathKeys that might be useful for WindowClause evaluation.  Modify it so
that it properly accounts for that.

Making this work required adjusting two things:

1. Change from checking query_pathkeys to check sort_pathkeys instead.
2. Add explicit check for window_pathkeys

For #1, query_pathkeys gets set in standard_qp_callback() according to the
sort order requirements for the first operation to be applied after the
join planner is finished, so this changes depending on which upper
planner operations a particular query needs.  If the query has window
functions and no GROUP BY, then query_pathkeys gets set to
window_pathkeys.  Before this change, this meant PathKeys useful for the
ORDER BY were not accounted for in queries with window functions.

Because of #1, #2 is now required so that we explicitly check to ensure
we don't truncate away PathKeys useful for window functions.

Author: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAApHDvrj3HTKmXoLMbUjTO=_MNMxM=cnuCSyBKidAVibmYPnrg@mail.gmail.com
2025-10-09 12:38:33 +13:00
..
access bufmgr: fewer calls to BufferDescriptorGetContentLock 2025-10-08 16:06:19 -04:00
archive Update copyright for 2025 2025-01-01 11:21:55 -05:00
backup Don't include access/htup_details.h in executor/tuptable.h 2025-10-05 18:00:38 +02:00
bootstrap Add new OID alias type regdatabase. 2025-06-30 15:38:54 -05:00
catalog Add mem_exceeded_count column to pg_stat_replication_slots. 2025-10-08 10:05:04 -07:00
commands Add ExplainState argument to pg_plan_query() and planner(). 2025-10-08 08:33:29 -04:00
executor Fix Coverity issues reported in commit 25a30bbd42. 2025-10-08 09:26:49 +09:00
foreign Track the number of presorted outer pathkeys in MergePath 2025-05-08 18:21:32 +09:00
jit jit: Fix type used for Datum values in LLVM IR. 2025-09-17 13:38:35 +12:00
lib Correct list of files in src/backend/lib/README 2025-06-27 09:31:23 +09:00
libpq Remove hbaPort type 2025-09-15 11:04:10 +02:00
main Force LC_COLLATE to C in postmaster. 2025-07-16 14:13:18 -07:00
nodes Do a tiny bit of header file maintenance 2025-09-30 12:28:29 +02:00
optimizer Make truncate_useless_pathkeys() consider WindowFuncs 2025-10-09 12:38:33 +13:00
parser Don't include access/htup_details.h in executor/tuptable.h 2025-10-05 18:00:38 +02:00
partitioning Avoid leakage of zero-length arrays in partition_bounds_copy(). 2025-08-02 21:59:46 -04:00
po Translation updates 2025-05-05 12:04:49 +02:00
port Remove traces of support for Sun Studio compiler 2025-09-12 07:39:05 +02:00
postmaster Create a separate file listing backend types 2025-09-26 15:21:49 +02:00
regex Control ctype behavior internally with a method table. 2025-07-01 07:44:47 -07:00
replication Add mem_exceeded_count column to pg_stat_replication_slots. 2025-10-08 10:05:04 -07:00
rewrite Don't generate fake "*TLOCRN*" or "*TROCRN*" aliases, either. 2025-09-08 12:58:07 -04:00
snowball Use PG_MODULE_MAGIC_EXT in our installable shared libraries. 2025-03-26 11:11:02 -04:00
statistics Avoid faulty alignment of Datums in build_sorted_items(). 2025-09-10 17:51:24 -04:00
storage bufmgr: Don't lock buffer header in StrategyGetBuffer() 2025-10-08 17:04:07 -04:00
tcop Add ExplainState argument to pg_plan_query() and planner(). 2025-10-08 08:33:29 -04:00
tsearch Track the maximum possible frequency of non-MCE array elements. 2025-09-20 14:48:16 -04:00
utils Add mem_exceeded_count column to pg_stat_replication_slots. 2025-10-08 10:05:04 -07:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile aio: Add liburing dependency 2025-03-26 19:45:32 -04:00
meson.build meson: add and use stamp files for generated headers 2025-08-11 15:18:23 -04:00
nls.mk Create a separate file listing backend types 2025-09-26 15:21:49 +02:00