From: David M. Calascibetta <david@calascibetta.com>
To: pgsql-bugs@lists.postgresql.org
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> (raw)
References: <17258-a7c164c5fb955221@postgresql.org>
<19D58355-E7C3-47D7-9C87-51EC751AE2BB@enterprisedb.com>
-----Original Message-----
From: David M. Calascibetta <david@calascibetta.com>
Sent: Friday, October 29, 2021 2:04 PM
To: 'Mark Dilger' <mark.dilger@enterprisedb.com>
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 <mark.dilger@enterprisedb.com>
Sent: Friday, October 29, 2021 1:58 PM
To: david@calascibetta.com; PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17258: Unexpected results in CHAR(1) data type
> On Oct 29, 2021, at 11:14 AM, PG Bug reporting form <noreply@postgresql.org> wrote:
>
> select length(substr(' '::varchar,1,1)), ascii(substr('
> '::varchar,1,1));
> produces==> 1 32 (as expected)
>
> select length(substr(' '::char,1,1)), ascii(substr(' '::char,1,1));
> produces==> 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.
—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: david@calascibetta.com, pgsql-bugs@lists.postgresql.org
Subject: Re: FW: BUG #17258: Unexpected results in CHAR(1) data type
In-Reply-To: <003701d7ccfb$c2a85bb0$47f91310$@calascibetta.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox