pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Subject: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
Date: Wed, 09 Oct 2024 21:00:01 +0000
Message-ID: <18652-deaa782ebcca85d1@postgresql.org> (raw)

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.



view thread (18+ messages)  latest in thread

Message-ID: <18652-deaa782ebcca85d1@postgresql.org>
Permalink:  ../18652-deaa782ebcca85d1@postgresql.org/
Also on:    postgresql.org/message-id/18652-deaa782ebcca85d1@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, exclusion@gmail.com
  Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index
  In-Reply-To: <18652-deaa782ebcca85d1@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox