Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mstgU-0003Ix-8Z for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Dec 2021 21:32:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mstgS-0001Vb-Ki for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Dec 2021 21:32:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mstfq-0005vc-Ll for pgsql-bugs@lists.postgresql.org; Thu, 02 Dec 2021 21:31:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mstfo-0000EX-BV for pgsql-bugs@lists.postgresql.org; Thu, 02 Dec 2021 21:31:25 +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 1B2LVNG62216961; Thu, 2 Dec 2021 16:31:23 -0500 From: Tom Lane To: "Ian R. Campbell" cc: pgsql-bugs@lists.postgresql.org Subject: Re: Inconsistent cast to "char" In-reply-to: <2120116.1638473263@sss.pgh.pa.us> References: <2117701.1638471036@sss.pgh.pa.us> <2120116.1638473263@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 02 Dec 2021 14:27:43 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2216959.1638480683.1@sss.pgh.pa.us> Date: Thu, 02 Dec 2021 16:31:23 -0500 Message-ID: <2216960.1638480683@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > To be clear, the change I'm thinking of would result in errors, not in > silently applying the int4 cast. As a quick-n-dirty test: > regression=# update pg_type set typcategory = 'x' where typname = 'char'; > UPDATE 1 > regression=# select 1::int8::"char", 1::int4::"char", 1::int2::"char"; > ERROR: cannot cast type bigint to "char" > LINE 1: select 1::int8::"char", 1::int4::"char", 1::int2::"char"; > ^ It turns out that changing the typcategory does have some undesirable side-effects, but I found another possible workaround. Patch posted at [1]. regards, tom lane [1] https://www.postgresql.org/message-id/2216388.1638480141%40sss.pgh.pa.us