BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Date: 2024-10-09T21:00:01Z
Lists: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 18652
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 17.0
Operating system: Ubuntu 22.04
Description:
The following query:
CREATE TABLE t(i int, j int);
CREATE INDEX idx on t((i + 0));
SELECT * FROM t,
(SELECT i + 0 AS i FROM
(SELECT i FROM t UNION ALL SELECT i + 1 FROM t) AS t1
) AS t2
WHERE t2.i = t.j;
fails with:
ERROR: XX000: could not find pathkey item to sort
LOCATION: prepare_sort_from_pathkeys, createplan.c:6350
The error occurs only when the expression in SELECT i + 0 AS i FROM
matches the expression in an index.
Reproduced on REL_10_STABLE .. master.
Commits
-
Correctly identify which EC members are computable at a plan node.
- 9f954177b1eb 18.0 landed
- 76de4b182cad 13.17 landed
- 64635c8af92d 16.5 landed
- 54889ea64baa 17.1 landed
- 4f3bccbaaeb4 15.9 landed
- 4ca708eb3588 14.14 landed
-
Support MergeAppend plans, to allow sorted output from append relations.
- 11cad29c9152 9.1.0 cited