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 1mgaHh-0002Pi-3G for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 22:23:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgaHf-0002N0-Ua for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 22:23:35 +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 1mgaHf-0002Mr-NJ for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 22:23:35 +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 1mgaHd-00081w-6P for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 22:23:35 +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 19TMNRIS758070; Fri, 29 Oct 2021 18:23:27 -0400 From: Tom Lane To: Mark Dilger cc: "" , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17258: Unexpected results in CHAR(1) data type In-reply-to: References: <17258-a7c164c5fb955221@postgresql.org> <19D58355-E7C3-47D7-9C87-51EC751AE2BB@enterprisedb.com> <003701d7ccfb$c2a85bb0$47f91310$@calascibetta.com> <0EE9669C-6E65-40E1-B492-F989F452DAC4@enterprisedb.com> <005501d7cd0b$9ba5d5f0$d2f181d0$@calascibetta.com> Comments: In-reply-to Mark Dilger message dated "Fri, 29 Oct 2021 14:36:08 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <758068.1635546207.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 29 Oct 2021 18:23:27 -0400 Message-ID: <758069.1635546207@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mark Dilger writes: > I haven't studied the behavior of char(n) on other RDBMS products. I'd = be curious if the SQL spec says anything that we're violating in this rega= rd. It's not a great approximation to the spec. Postgres views trailing spaces in a char(n) value as always being semantically insignificant, where I think the spec treats them as insignificant only for purposes of comparisons. Even more to the point, the spec considers that PAD SPACE is an attribute of *collations* not data types. Back in the day we didn't have collations, so the only way to even approximate that behavior was to make it a data type property. Now that we do have collations, it'd be conceivable to reimplement all this in something closer to the way the spec describes it. But it'd be a lot of work, and I'm not sure we'd accept such a patch even if somebody wrote it. It'd almost inevitably break applications that are relying on the existing behavior. > I tend to think of char(n) as a misfeature and avoid using it. Yeah, that. I haven't seen any reason to use char(n) rather than varchar(n) since punched cards stopped being a thing. So it's hard to summon the motivation to do a lot of work on that data type. Perhaps somebody else will feel more motivated, but nobody's stepped forward, and I wouldn't counsel holding your breath for it. regards, tom lane