diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2024-02-09 12:56:26 +0200 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2024-02-09 12:56:54 +0200 |
commit | c01f6ef46c8f0ab3faa54e8f040da6e9ddc7fe5b (patch) | |
tree | d4754056f3d78f249135997e04d86d128a505369 /src/backend/utils/adt/jsonpath_exec.c | |
parent | 6743c5ae64e3c957ef8bd4f8a0daa2ba9959b0b3 (diff) | |
download | postgresql-c01f6ef46c8f0ab3faa54e8f040da6e9ddc7fe5b.tar.gz postgresql-c01f6ef46c8f0ab3faa54e8f040da6e9ddc7fe5b.zip |
Fix usage of aggregate pathkeys in group_keys_reorder_by_pathkeys()
group_keys_reorder_by_pathkeys() function searched for matching pathkeys
within root->group_pathkeys. That could lead to picking an aggregate pathkey
and using its pathkey->pk_eclass->ec_sortref as an argument of
get_sortgroupref_clause_noerr(). Given that ec_sortref of an aggregate pathkey
references aggregate targetlist not query targetlist, this leads to incorrect
query optimization.
Fix this by looking for matching pathkeys only within the first
num_groupby_pathkeys pathkeys.
Reported-by: David G. Johnston
Discussion: https://postgr.es/m/CAKFQuwY3Ek%3DcLThgd8FdaSc5JRDVt0FaV00gMcWra%2BTAR4gGUw%40mail.gmail.com
Author: Andrei Lepikhov, Alexander Korotkov
Diffstat (limited to 'src/backend/utils/adt/jsonpath_exec.c')
0 files changed, 0 insertions, 0 deletions