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