From: David M. Calascibetta <david@calascibetta.com>
To: 'David G. Johnston' <david.g.johnston@gmail.com>
Cc: 'PostgreSQL mailing lists' <pgsql-bugs@lists.postgresql.org>
Subject: RE: FW: BUG #17258: Unexpected results in CHAR(1) data type
Date: Fri, 29 Oct 2021 16:06:02 -0500
Message-ID: <004b01d7cd08$c8f54a70$5adfdf50$@calascibetta.com> (raw)
In-Reply-To: <CAKFQuwYOB7u_OA41sVCjgmYsOb=BqjRXX6bz1TdpJ=NECa-7cA@mail.gmail.com>
References: <17258-a7c164c5fb955221@postgresql.org>
<19D58355-E7C3-47D7-9C87-51EC751AE2BB@enterprisedb.com>
<003701d7ccfb$c2a85bb0$47f91310$@calascibetta.com>
<CAKFQuwYOB7u_OA41sVCjgmYsOb=BqjRXX6bz1TdpJ=NECa-7cA@mail.gmail.com>
I disagree about it being a feature request.
I was only using substr to demonstrate the problem.
Here is the problem without using any functions:
create table x (a char(1));
insert into x values ('x');
insert into x values (' ');
select length(a) from x;
1
0
From: David G. Johnston <david.g.johnston@gmail.com>
Sent: Friday, October 29, 2021 3:40 PM
To: David@calascibetta.com
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: FW: BUG #17258: Unexpected results in CHAR(1) data type
On Fri, Oct 29, 2021 at 1:17 PM David M. Calascibetta <david@calascibetta.com <mailto:david@calascibetta.com> > wrote:
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.
This qualifies as a feature request, not a bug. One could write a version of substr that does what you expect (it probably wouldn't be named substr though) and takes in a character data type. It's just no one has, nor is likely to. Thus you are stuck using versions that take in text and you get the char-to-text casting side effects.
If you do octet_length(' ':: character(1)) it will return 1, not zero. So it indeed has a length one.
David J.
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, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: RE: FW: BUG #17258: Unexpected results in CHAR(1) data type
In-Reply-To: <004b01d7cd08$c8f54a70$5adfdf50$@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