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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: vojtech(dot)benes(at)centrum(dot)cz
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type
Date: 2023-12-30 16:13:15
Message-ID: 3536307.1703952795@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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(at)postgresql(dot)org>
Date: Tue Aug 2 23:11:45 2022 +1200

Improve performance of ORDER BY / DISTINCT aggregates

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2023-12-31 03:24:54 Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type
Previous Message PG Bug reporting form 2023-12-30 10:17:40 BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type