bpchar datatype is not equal to character(1) data type

From: "yanliang lei" <msdnchina(at)163(dot)com>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: bpchar datatype is not equal to character(1) data type
Date: 2023-06-06 14:30:56
Message-ID: 5ec1dd7b.54a7.188911e35c3.Coremail.msdnchina@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

in the documents (https://www.postgresql.org/docs/current/typeconv-query.html),there is the following descrition:

“blank-padded char”, the internal name of the character data type.

===>>so bpchar datatype is equal to character data type

in the documents (https://www.postgresql.org/docs/15/datatype-character.html),there is the following descrition:

character without length specifier is equivalent to character(1).

===>>so character data type is equal to character(1) data type

Based on the above description, there is a deduction as follows:

bpchar datatype is equal to character(1) data type

but the following test tells us that: bpchar datatype is not equal to character(1) data type.
I want to know why? Maybe the document has error? and I want to know that: bpchar datatype is equal to which datatype?

postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 15.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)

postgres=# create table xxx2(c1 char,c2 int);
CREATE TABLE
postgres=# insert into xxx2 values('aaaaa',1);
ERROR: value too long for type character(1) <<<<----please note this error!
postgres=# \d+ xxx2;
Table "public.xxx2"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+--------------+-----------+----------+---------+----------+-------------+--------------+-------------
c1 | character(1) | | | | extended | | |
c2 | integer | | | | plain | | |
Access method: heap

postgres=# create table xxx3(c1 bpchar,c2 int);
CREATE TABLE
postgres=# insert into xxx3 values('aaaaa',1);
INSERT 0 1
postgres=# \d+ xxx3;
Table "public.xxx3"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
--------+---------+-----------+----------+---------+----------+-------------+--------------+-------------
c1 | bpchar | | | | extended | | |
c2 | integer | | | | plain | | |
Access method: heap

postgres=# select * from xxx3; <<<<----please note this result.
c1 | c2
-------+----
aaaaa | 1
(1 row)

postgres=#

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Laurenz Albe 2023-06-06 16:45:37 Re: bpchar datatype is not equal to character(1) data type
Previous Message Jonathan S. Katz 2023-06-06 13:58:14 clarifying trigger/rule behavior on logical replication subscribers