Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rJbxr-00ERI9-E6 for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Dec 2023 16:13:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rJbxo-0013fY-6f for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Dec 2023 16:13:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rJbxn-0013fQ-UE for pgsql-bugs@lists.postgresql.org; Sat, 30 Dec 2023 16:13:27 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rJbxj-00Efzt-7R for pgsql-bugs@lists.postgresql.org; Sat, 30 Dec 2023 16:13:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3BUGDFG43536308; Sat, 30 Dec 2023 11:13:16 -0500 From: Tom Lane To: vojtech.benes@centrum.cz cc: pgsql-bugs@lists.postgresql.org, David Rowley Subject: Re: BUG #18264: Table has type text, but query expects integer.attribute 1 of type record has wrong type In-reply-to: <18264-e363593d7e9feb7d@postgresql.org> References: <18264-e363593d7e9feb7d@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sat, 30 Dec 2023 10:17:40 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3536306.1703952795.1@sss.pgh.pa.us> Date: Sat, 30 Dec 2023 11:13:15 -0500 Message-ID: <3536307.1703952795@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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 Date: Tue Aug 2 23:11:45 2022 +1200 Improve performance of ORDER BY / DISTINCT aggregates regards, tom lane