public inbox for [email protected]
help / color / mirror / Atom feedFrom: Sergei Katkovsky <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Jeff Davis <[email protected]>
Cc: [email protected]
Subject: Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
Date: Fri, 17 Oct 2025 18:18:08 +0400
Message-ID: <CAAf8JyLJDtbBnx7zc_oPb=16YAHH0PyAh5H_GtZ7R0QJPqthNQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
On Fri, Oct 17, 2025 at 4:49 PM Laurenz Albe <[email protected]> wrote:
> "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.
Unfortunately, BPCHAR and VARCHAR are not identical in other contexts.
The situation is not the same as with BCHAR(n), which is just an alias
for CHAR(n).
SELECT BPCHAR 'x' = VARCHAR 'x ', VARCHAR 'x' = BPCHAR 'x ',
VARCHAR 'x' = VARCHAR 'x ';
true true false
For comparison with BPCHAR trailing blanks are insignificant, but when
we have VARCHAR on both sides, they matter.
With best regards,
Sergei Katkovskii
reply
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: BPCHAR description in 8.3. Character Types is misleading and incomplete
In-Reply-To: <CAAf8JyLJDtbBnx7zc_oPb=16YAHH0PyAh5H_GtZ7R0QJPqthNQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox