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 1mgZx4-0001T4-Kt for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 22:02:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgZx2-0007x0-P8 for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 22:02:16 +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 1mgZnw-0007MX-0j for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 21:52:52 +0000 Received: from mail246c38.carrierzone.com ([66.175.56.246] helo=mail155c38.carrierzone.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgZns-0007SM-ON for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 21:52:50 +0000 X-Authenticated-User: david@calascibetta.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=carrierzone.com; s=mailmia; t=1635544367; bh=4/j/92JMF63yq2Nl5k6op3J/fJDF00ANDccM/eQly54=; h=Reply-To:From:To:Cc:References:In-Reply-To:Subject:Date:From; b=Fs1t1FZ5MJr6eUM/EG/I4UuOe7GrWDD1msWZKerQG/XES6j/DweZMVFfXOkFlZlTL nGr2xCcg7kH2igWRbo9njhXynxExF/em0DKgSnJSzMecyeLMLScMlO++EisluF12OE 17WxM16BUB7fh8alkIE1mtWIVO3nH4ILQcWvnXZg= Feedback-ID: david@calascibe Received: from Workstation (99-16-240-20.lightspeed.mrgvil.sbcglobal.net [99.16.240.20]) (authenticated bits=0) by mail155c38.carrierzone.com (8.14.9/8.13.1) with ESMTP id 19TLqjgk009101; Fri, 29 Oct 2021 21:52:46 +0000 Reply-To: From: "David M. Calascibetta" To: "'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> In-Reply-To: Subject: RE: BUG #17258: Unexpected results in CHAR(1) data type Date: Fri, 29 Oct 2021 16:52:46 -0500 Message-ID: <005901d7cd0f$500f1c10$f02d5430$@calascibetta.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQLB1uYWs1aJVPkX1BZhIF63SkMLgwH/iU5GAnFecvcC9n3sDwIkuI8lAg+cjF+puZGT0A== Content-Language: en-us X-CTCH-RefID: str=0001.0A742F17.617C6D2F.0027: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=OqAsdwzt c=1 sm=1 tr=0 ts=617c6d2f a=4+o7z3fL63oxpBr+4DDEQg==:117 a=4+o7z3fL63oxpBr+4DDEQg==:17 a=IkcTkHD0fZMA:10 a=8oRFvH3FJKojJeQlcbUA:9 a=QEXdDO2ut3YA:10 X-Origin-Country: US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > I agree, the behavior is nuts, and is inconsistent with every other = RDBMS out there. 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. If so, we should at least have a warning in the docs about = that. (We already have a warning about how char(n) behaves, but nothing = I see about the behavior being non-compliant.) But I'm wondering if = other RDBMS products really differ in this regard? Are you perhaps = thinking about how varchar(n) works?=20 In every other rdbms, if it's fixed length character, values will always = be that fixed length. PG behaves that way unless the value is blank. I believe this is in = violation of the spec, which is why I reported it. Even the PG doc says it will pad with = blanks. It does not give an exception for blank values. > I was only reporting it to improve the product, but if you think this=20 > is appropriate behavior, I'm good with it. I tend to think of char(n) as a misfeature and avoid using it. Based on = your experience with other RDBMSs, would you expect char(n) and = varchar(n) to behave the same or to behave differently? In postgres, = they are different, and varchar(n) would behave more like you seem to = want. They should behave the same, in that if I insert a blank into a char(1) = column, it should store a blank value. If I insert a blank into a varchar(1) column, it should store a blank = value. Fixed length characters would pad on the right, but it should not distort the value I entered in any other = way. In this case, I enter a blank value and PG removes it. That is not appropriate behavior.