Re: zero char is returned as space - Mailing list pgsql-hackers

From Konstantin Izmailov
Subject Re: zero char is returned as space
Date
Msg-id CAAw-MsdCAPCz07UZcL-bCV=Whcww5oS2E5Sqoju0qeuty65fJw@mail.gmail.com
Whole thread Raw
In response to Re: zero char is returned as space  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom,
thank you very much! It makes sense now.

K

On Tue, Apr 5, 2022 at 10:08 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Konstantin Izmailov <pgfizm@gmail.com> writes:
> could you help me understand if this is an intended behaviour, or I'm
> incorrectly querying a "char" field?

We do not support '\0' as an element of a string value.  You didn't
show how you're trying to insert this value, but I suspect that
Postgres saw it as an empty string which it then space-padded to
length 1 because that's what char(1) does.

Don't use a string field to store an integer.  What with the need
for a length header, you wouldn't be saving any space compared to
"smallint" even if there weren't any semantic issues.

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Perform streaming logical transactions by background workers and parallel apply
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: API stability