Re: BPCHAR description in 8.3. Character Types is misleading and incomplete - Mailing list pgsql-docs

From Laurenz Albe
Subject Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Date
Msg-id 92151c4debb48bbbaed4db81c79d73c36f619858.camel@cybertec.at
Whole thread Raw
In response to Re: BPCHAR description in 8.3. Character Types is misleading and incomplete  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
List pgsql-docs
On Wed, 2025-10-15 at 15:29 -0400, Tom Lane wrote:
> Jeff Davis <pgsql@j-davis.com> writes:
> > Please take a look at the attached patch. If you'd like your name
> > included in the commit, please send it as you'd like it to appear.
>
> I don't understand why any of these variants are better than the
> original wording "blank-padded".  That has the non-negligible
> advantage of corresponding to the type name, and furthermore
> appears in many other places in our docs and source code.
>
> There may be some other wording improvements we could make here,
> but I think b69db5173 was fundamentally misguided in this respect.

My suggestion is to just remove the "blank-trimmed" from the documentation.

"bpchar" and "varchar", when used without type modifier, are actually
identical:

SELECT octet_length(BPCHAR 'x   '),
       octet_length(VARCHAR 'x   '),
       octet_length(TEXT 'x   ');

 octet_length │ octet_length │ octet_length
══════════════╪══════════════╪══════════════
            4 │            4 │            4

The blank-trimming only occurs when a "bpchar" is converted to "text",
for example when used with the concatenation operator.

I suggest the following simplification:

diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index b81d89e2608..05edab3bd33 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1177,11 +1177,7 @@ SELECT '52093.89'::money::numeric::float8;
         <entry>fixed-length, blank-padded</entry>
        </row>
        <row>
-        <entry><type>bpchar</type></entry>
-        <entry>variable unlimited length, blank-trimmed</entry>
-       </row>
-       <row>
-        <entry><type>text</type></entry>
+        <entry><type>text</type>, <type>varchar</type>, <type>bpchar</type></entry>
         <entry>variable unlimited length</entry>
        </row>
      </tbody>

Yours,
Laurenz Albe



pgsql-docs by date:

Previous
From: Sergei Katkovsky
Date:
Subject: Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Next
From: "David G. Johnston"
Date:
Subject: Re: BPCHAR description in 8.3. Character Types is misleading and incomplete