Go to file
David Rowley d8a295389b Strip off ORDER BY/DISTINCT aggregate pathkeys in create_agg_path
1349d2790 added code to adjust the PlannerInfo.group_pathkeys so that
ORDER BY / DISTINCT aggregate functions could obtain pre-sorted inputs
to allow faster execution.  That commit forgot to adjust the pathkeys in
create_agg_path().  Some code in there assumed that it was always fine
to make the AggPath's pathkeys the same as its subpath's.  That seems to
have been ok up until 1349d2790, but since that commit adds pathkeys for
columns which are within the aggregate function, those columns won't be
available above the aggregate node.  This can result in "could not find
pathkey item to sort" during create_plan().

The fix here is to strip off the additional pathkeys added by
adjust_group_pathkeys_for_groupagg().  It seems that the pathkeys here
will only ever be group_pathkeys, so all we need to do is check if the
length of the pathkey list is longer than the num_groupby_pathkeys and
get rid of the additional ones only if we see extras.

Reported-by: Justin Pryzby
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/ZQhYYRhUxpW3PSf9%40telsasoft.com
Backpatch-through: 16, where 1349d2790 was introduced
2023-10-09 16:37:05 +13:00
config Use native CRC instructions on 64-bit LoongArch 2023-08-10 11:36:15 +07:00
contrib Constify crc32_sz 2023-10-05 08:53:21 +02:00
doc dblink: Replace WAIT_EVENT_EXTENSION with custom wait events 2023-10-05 10:23:22 +09:00
src Strip off ORDER BY/DISTINCT aggregate pathkeys in create_agg_path 2023-10-09 16:37:05 +13:00
.cirrus.star ci: Prepare to make compute resources for CI configurable 2023-08-23 15:15:28 -07:00
.cirrus.tasks.yml Use "template" data directory in tests 2023-08-24 14:38:02 -07:00
.cirrus.yml ci: Make compute resources for CI configurable 2023-08-23 15:15:28 -07:00
.dir-locals.el Make Emacs perl-mode indent more like perltidy. 2019-01-13 11:32:31 -08:00
.editorconfig Add .editorconfig 2019-12-18 09:13:13 +01:00
.git-blame-ignore-revs Add bc6041b61f to .git-blame-ignore-revs. 2023-08-30 16:06:12 +09:00
.gitattributes gitattributes: Ignore imported pg_bsd_indent code for whitespace checks 2023-02-22 09:00:28 +01:00
.gitignore Update top-level .gitignore. 2022-12-04 15:23:00 -05:00
COPYRIGHT Update copyright for 2023 2023-01-02 15:00:37 -05:00
GNUmakefile.in Integrate pg_bsd_indent into our build/test infrastructure. 2023-02-12 12:22:21 -05:00
HISTORY Canonicalize some URLs 2020-02-10 20:47:50 +01:00
Makefile Dynamically find correct installation docs in Makefile. 2022-01-19 14:48:25 +01:00
README Canonicalize some URLs 2020-02-10 20:47:50 +01:00
README.git Canonicalize some URLs 2020-02-10 20:47:50 +01:00
aclocal.m4 autoconf: Move export_dynamic determination to configure 2022-12-06 18:55:28 -08:00
configure Remove traces of Sun -lposix4. 2023-08-17 16:16:43 +12:00
configure.ac Remove traces of Sun -lposix4. 2023-08-17 16:16:43 +12:00
meson.build meson: macos: Correct -exported_symbols_list syntax for Sonoma compat 2023-09-30 12:10:47 -07:00
meson_options.txt meson: Attach colon to keyword argument 2023-06-29 12:53:41 +02:00

README

PostgreSQL Database Management System
=====================================

This directory contains the source code distribution of the PostgreSQL
database management system.

PostgreSQL is an advanced object-relational database management system
that supports an extended subset of the SQL standard, including
transactions, foreign keys, subqueries, triggers, user-defined types
and functions.  This distribution also contains C language bindings.

PostgreSQL has many language interfaces, many of which are listed here:

	https://www.postgresql.org/download/

See the file INSTALL for instructions on how to build and install
PostgreSQL.  That file also lists supported operating systems and
hardware platforms and contains information regarding any other
software packages that are required to build or run the PostgreSQL
system.  Copyright and license information can be found in the
file COPYRIGHT.  A comprehensive documentation set is included in this
distribution; it can be read as described in the installation
instructions.

The latest version of this software may be obtained at
https://www.postgresql.org/download/.  For more information look at our
web site located at https://www.postgresql.org/.