| From: | Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> |
|---|---|
| To: | Sergei Katkovsky <skatkovsky(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 |
| Subject: | Re: BPCHAR description in 8.3. Character Types is misleading and incomplete |
| Date: | 2025-10-17 22:36:02 |
| Message-ID: | ced31f50b2e55502bd2ed739dd48cfc1316ddb35.camel@cybertec.at |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-docs |
On Fri, 2025-10-17 at 18:18 +0400, Sergei Katkovsky wrote:
> On Fri, Oct 17, 2025 at 4:49 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> 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.
They are stored identically, but behave differently, so I shouldn't have
said that they *are* identical.
Still, they all are variable-length strings, so we could list them together.
But perhaps it is really better to leave things as they are now, perhaps
replacing "blank-trimming", perhaps as "variable-length string that ignores
training blanks".
Yours,
Laurenz Albe
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sergei Katkovsky | 2025-10-20 12:42:30 | Re: BPCHAR description in 8.3. Character Types is misleading and incomplete |
| Previous Message | Sergei Katkovsky | 2025-10-17 14:25:35 | Re: BPCHAR description in 8.3. Character Types is misleading and incomplete |