Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type
Date
Msg-id 3536307.1703952795@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> One particular query outputs unexpected error instead of result data. This
> behaviour is strange while change of order of columns seems to avoid issue.
> Also removing DINSTINCT keyword in first column or WHERE statement in second
> column also somehow avoid issue. I was able to isolate part that causes
> problems and write following test case: 

> SELECT
> string_agg(DISTINCT 'a', ', ') agg,
> sum(
>   (
>     SELECT sum(1)
>     FROM (SELECT id FROM unnest(array[1]) id) B
>     WHERE  A.id = B.id
>   )
> ) sum
> FROM (SELECT id FROM unnest(array[1]) id) A;

> Both psql and pgadmin outputs this:
> ERROR:  attribute 1 of type record has wrong type
> SQL status: 42804
> Detail: Table has type text, but query expects integer.

Thanks for the report!  Bisecting shows it broke at

1349d2790bf48a4de072931c722f39337e72055e is the first bad commit
commit 1349d2790bf48a4de072931c722f39337e72055e
Author: David Rowley <drowley@postgresql.org>
Date:   Tue Aug 2 23:11:45 2022 +1200

    Improve performance of ORDER BY / DISTINCT aggregates

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type
Next
From: David Rowley
Date:
Subject: Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type