Re: BUG #17258: Unexpected results in CHAR(1) data type - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #17258: Unexpected results in CHAR(1) data type
Date
Msg-id CAKFQuwaiyVsPu0_z1sDQqVcFbKpLLzYuUnYca-fC+VdwN7OREg@mail.gmail.com
Whole thread Raw
In response to RE: BUG #17258: Unexpected results in CHAR(1) data type  ("David M. Calascibetta" <david@calascibetta.com>)
List pgsql-bugs
On Fri, Oct 29, 2021 at 2:59 PM David M. Calascibetta <david@calascibetta.com> wrote:
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.


As implemented it has no way to distinguish between user-added trailing whitespace and padding-added trailing whitespace.  So instead it just says "trailing whitespace is insignificant" and, further, insignificant whitespace is discarded when converting to a data type that doesn't have the concept of insignificant whitespace.

I don't necessarily agree with this either, but I'm in favor of the position that char is obsolete and should not be used in new development, nor should it be expected to be maintained.

David J.

pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: BUG #17245: Index corruption involving deduplicated entries
Next
From: Mark Dilger
Date:
Subject: Re: BUG #17258: Unexpected results in CHAR(1) data type