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 1mgYJK-0006Me-Tm for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 20:17:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgYJJ-0006Nc-Pv for pgsql-bugs@arkaria.postgresql.org; Fri, 29 Oct 2021 20:17:09 +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 1mgXcd-0006A4-Gz for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 19:33:03 +0000 Received: from mail132c38.carrierzone.com ([66.175.56.162] helo=mail149c38.carrierzone.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgXcT-0006cI-Jg for pgsql-bugs@lists.postgresql.org; Fri, 29 Oct 2021 19:33:01 +0000 X-Authenticated-User: david@calascibetta.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=carrierzone.com; s=mailmia; t=1635535969; bh=+C45WYafuZybZhOJTPnK8O5vnruv6ZYiTSHclgquF5w=; h=Reply-To:From:To:References:In-Reply-To:Subject:Date:From; b=MTS9ppahluKKgdq2osxI3cEVjksGEjTGHbtZOHMQYVCTAZgTX/KWclZDHT6Yh7Bpj krv6V7D6NVsYZK8kEcwrtSSVdcVqKMikhtf9MBowlO8MtgGYqlZBRfd1OOMqqcwVPV ij9eFMq8G+WCg93O510h+dkOzpXwwkPc8dx0pPKg= Feedback-ID: david@calascibe Received: from Workstation (99-16-240-20.lightspeed.mrgvil.sbcglobal.net [99.16.240.20]) (authenticated bits=0) by mail149c38.carrierzone.com (8.14.9/8.13.1) with ESMTP id 19TJWlob032275 for ; Fri, 29 Oct 2021 19:32:49 +0000 Reply-To: From: "David M. Calascibetta" To: References: <17258-a7c164c5fb955221@postgresql.org> <19D58355-E7C3-47D7-9C87-51EC751AE2BB@enterprisedb.com> In-Reply-To: Subject: FW: BUG #17258: Unexpected results in CHAR(1) data type Date: Fri, 29 Oct 2021 14:32:48 -0500 Message-ID: <003701d7ccfb$c2a85bb0$47f91310$@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/iU5GqgZE2iCAAAh38A== Content-Language: en-us X-CTCH-RefID: str=0001.0A742F2A.617C4C61.0050: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=d9mWdTvE c=1 sm=1 tr=0 ts=617c4c61 a=4+o7z3fL63oxpBr+4DDEQg==:117 a=4+o7z3fL63oxpBr+4DDEQg==:17 a=IkcTkHD0fZMA:10 a=pCOydsRIAAAA:8 a=oa-xg8NNAAAA:8 a=epTmVMiNAAAA:8 a=dhvpqj97lAQBKnbR1TEA:9 a=QEXdDO2ut3YA:10 a=4YKM6X3TZtkG47b_JkB7:22 a=MQ1BrC-N35uif390zSTS: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 -----Original Message----- From: David M. Calascibetta =20 Sent: Friday, October 29, 2021 2:04 PM To: 'Mark Dilger' Subject: RE: BUG #17258: Unexpected results in CHAR(1) data type Ok, but my example was just a simplified version of what is going on. The actual problem stems from a CHAR(1) column data type that is = behaving the same way. I was just trying to create a super-simple example of the problem. It still seems to me that a CHAR(1) should never be zero length, = regardless of how it's implemented. -----Original Message----- From: Mark Dilger =20 Sent: Friday, October 29, 2021 1:58 PM To: david@calascibetta.com; PostgreSQL mailing lists = Subject: Re: BUG #17258: Unexpected results in CHAR(1) data type > On Oct 29, 2021, at 11:14 AM, PG Bug reporting form = wrote: >=20 > select length(substr(' '::varchar,1,1)), ascii(substr(' =20 > '::varchar,1,1)); > produces=3D=3D> 1 32 (as expected) >=20 > select length(substr(' '::char,1,1)), ascii(substr(' = '::char,1,1)); > produces=3D=3D> 0 0 (not as expected) There are four substr() functions defined in the standard distribution. = They are: substr(text, int4, int4) substr(text, int4) substr(bytea, int4, int4) substr(bytea, int4) There is none defined directly for char(n). Since "text" is the = preferred type (not "bytea"), I expect a cast of your ' '::char to text = before entry to the function. So the question is why casting ' '::char = to text is different than ' '::text. The answer is that cast is = implemented using rtrim1, which trims trailing space. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL = Company