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 1msrkE-0000YM-93 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Dec 2021 19:27:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1msrkC-0004DP-H3 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Dec 2021 19:27:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msrkC-0004DG-8f for pgsql-bugs@lists.postgresql.org; Thu, 02 Dec 2021 19:27:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1msrkA-0007rY-3g for pgsql-bugs@lists.postgresql.org; Thu, 02 Dec 2021 19:27:47 +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 1B2JRhcS2120117; Thu, 2 Dec 2021 14:27:44 -0500 From: Tom Lane To: "Ian R. Campbell" cc: pgsql-bugs@lists.postgresql.org Subject: Re: Inconsistent cast to "char" In-reply-to: References: <2117701.1638471036@sss.pgh.pa.us> Comments: In-reply-to "Ian R. Campbell" message dated "Thu, 02 Dec 2021 20:53:55 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2120115.1638473263.1@sss.pgh.pa.us> Date: Thu, 02 Dec 2021 14:27:43 -0500 Message-ID: <2120116.1638473263@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Ian R. Campbell" writes: > It makes sense that "char" is not part of the string family. After all, > "char" != char. If it allowed more than one byte, maybe you could call it a "string", but it seems hard to justify without that. > In the scenarios I give, one would expect the same output for all integer > width casting inputs, so you have my vote on the change you suggested. 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"; ^ regards, tom lane