Re: BPCHAR description in 8.3. Character Types is misleading and incomplete

From: Sergei Katkovsky <skatkovsky(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Davis <pgsql(at)j-davis(dot)com>, "pgsql-docs(at)lists(dot)postgresql(dot)org" <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Date: 2025-10-16 19:00:04
Message-ID: CAAf8JyK7qVbCw0Lrk3NCCe9zgnt5856zjBULetA9zP13hGn+Lw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Oct 16, 2025 at 10:11 PM David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> The spaces added to the end of a bpchar manually can and are considered “padding” - or “present but lack semantic/value significance”. The reason they are not padding for varchar is that such spaces are considered part of the stored value from a semantic perspective.
>
> Think of padding as a noun, not a verb. “The value contains padding”. Not, “ I am padding the value”.

The value may sometimes contain padding. And sometimes not. But we are
talking about the type, not value. The value 'abc'::bpchar does not
contain any blanks. But it's still a BPCHAR value. And it is not
padded, despite that its type is BPCHAR.

> And yes, this is intended as a way to make the name of the type and its behavior consistent.

The behavior of 'abc'::BPCHAR is, for example, the following:
length('abc'::BPCHAR) = 3
CONCAT('abc::BPCHAR, 'def') = 'abcdef'.
What of the above is consistent with the notion of being 'blank-padded'?

And, the proposal is not to change the name of the type. The proposal
is to change the wording 'blank-trimming' to something more
appropriate.

> You sorta have to want it to work/make sense; not fight it on minor nuance.

The sole reason that I am here is that recently I came across a
(year-old) question on stackoverflow where some person was curious why
the actual behavior of BPCHAR was inconsistent with the documentation.
What is worse is that the question was answered, but answered
incorrectly. So, I doubt that it is just a minor nuance. Probably, not
just one person tried to use BPCHAR as a 'blank-trimming' type.

With best regards,
Sergei Katkovskii

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2025-10-16 19:18:52 Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Previous Message David G. Johnston 2025-10-16 18:40:36 Re: BPCHAR description in 8.3. Character Types is misleading and incomplete