BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date: 2024-10-09 21:00:01
Message-ID: 18652-deaa782ebcca85d1@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18652
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-10-09 21:43:03 Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Previous Message Thomas Munro 2024-10-09 19:54:41 Re: Reference to - BUG #18349: ERROR: invalid DSA memory alloc request size 1811939328, CONTEXT: parallel worker