Thread: BUG #2820: "select" faling with "distinct" clause on a subquery

BUG #2820: "select" faling with "distinct" clause on a subquery

From
"trinchero"
Date:
The following bug has been logged online:

Bug reference:      2820
Logged by:          trinchero
Email address:      trinchero@gmail.com
PostgreSQL version: 8.2
Operating system:   Windows XP
Description:        "select" faling with "distinct" clause on a subquery
Details:

To reproduce:

1. create tables:

CREATE TABLE u_listino
(
  u_listino_id numeric(10) NOT NULL,
  u_tipolis_id numeric(10) NOT NULL
)
WITH OIDS;

CREATE TABLE u_tipolis
(
  u_tipolis_id numeric(10) NOT NULL
)
WITH OIDS;

2. run the query:

SELECT U_Listino.U_LISTINO_ID FROM U_Listino
 WHERE U_Listino.U_TIPOLIS_ID IN (SELECT DISTINCT U_TipoLis.U_TIPOLIS_ID
FROM U_TipoLis);

This give error:
could not find pathkey item to sort
sql state: XX000

Problem seen in a java application, and replicated using pg admin 3
(distributed with PostgresSQL 8.2)

If the same query is run without the DISTINCT, it gives no error.

Best regars.

Re: BUG #2820: "select" faling with "distinct" clause on a subquery

From
Tom Lane
Date:
"trinchero" <trinchero@gmail.com> writes:
> SELECT U_Listino.U_LISTINO_ID FROM U_Listino
>  WHERE U_Listino.U_TIPOLIS_ID IN (SELECT DISTINCT U_TipoLis.U_TIPOLIS_ID
> FROM U_TipoLis);

> This give error:
> could not find pathkey item to sort

This has already been reported and fixed, but thanks for letting us know!

            regards, tom lane