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 1mgb0p-0004HP-5a for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 23:10:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgb0m-0005fy-RD for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 23:10:12 +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 1mgb0m-0005fR-6e for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 23:10:12 +0000 Received: from mail160c38.carrierzone.com ([66.175.56.190] helo=mail170c38.carrierzone.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgb0h-0008QF-De for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 23:10:10 +0000 X-Authenticated-User: david@calascibetta.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=carrierzone.com; s=mailmia; t=1635549003; bh=nrY8hPk9k4K1KsbU62ju+uyA+1kR0Wqi1VRkqg8D6Rk=; h=Reply-To:From:To:Cc:References:In-Reply-To:Subject:Date:From; b=aZvViiVG2Olk2EnOuwiRw6ljZSbzQE1+uE1WMz+Yn01zKxEjYxr9LLVNri0wLgG8i hXjG554gMFO25r5OScFtAu0nMYG0DinTSl67PTM7omQfzmSLePboETaCmse3uIBmSb 7E4R3qo+ue4NKEFUZ3snywUgTlhRjoNm7vpmQii4= Feedback-ID: david@calascibe Received: from Workstation (99-16-240-20.lightspeed.mrgvil.sbcglobal.net [99.16.240.20]) (authenticated bits=0) by mail170c38.carrierzone.com (8.14.9/8.13.1) with ESMTP id 19TNA0Wv009990; Fri, 29 Oct 2021 23:10:02 +0000 Reply-To: From: "David M. Calascibetta" To: "'Tom Lane'" , "'Mark Dilger'" Cc: 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> <758069.1635546207@sss.pgh.pa.us> In-Reply-To: <758069.1635546207@sss.pgh.pa.us> Subject: RE: BUG #17258: Unexpected results in CHAR(1) data type Date: Fri, 29 Oct 2021 18:10:00 -0500 Message-ID: <006c01d7cd1a$1a940130$4fbc0390$@calascibetta.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQLB1uYWs1aJVPkX1BZhIF63SkMLgwH/iU5GAnFecvcC9n3sDwIkuI8lAg+cjF8CAH1O9qmppDPw Content-Language: en-us X-CTCH-RefID: str=0001.0A742F1B.617C7F4B.000D:SCFSTAT57938998,ss=1,re=-4.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.4 cv=JajfEWGV c=1 sm=1 tr=0 ts=617c7f4b a=4+o7z3fL63oxpBr+4DDEQg==:117 a=4+o7z3fL63oxpBr+4DDEQg==:17 a=kj9zAlcOel0A:10 a=oa-xg8NNAAAA:8 a=pCOydsRIAAAA:8 a=epTmVMiNAAAA:8 a=uvWzfAzHz2HF-qrH6vsA:9 a=CjuIK1q_8ugA:10 a=MQ1BrC-N35uif390zSTS:22 a=4YKM6X3TZtkG47b_JkB7:22 a=ndEWmUVY6Yapc0oHF_P4:22 X-Origin-Country: US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I understand your position. I've been there myself. We will convert the CHAR(1) columns to VARCHAR and keep going. I just thought it was strange and you should know about it. Not a problem. Thanks for your attention. David -----Original Message----- From: Tom Lane Sent: Friday, October 29, 2021 5:23 PM To: Mark Dilger Cc: ; pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17258: Unexpected results in CHAR(1) data type 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 regard. 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