From 83981bcbace1e0eac599cdac196213e78f6d545a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 31 Oct 2023 10:13:11 -0400 Subject: [PATCH] doc: improve bpchar and character type length details Reported-by: Jeff Davis Discussion: https://postgr.es/m/32a9b8357e8e29b04f395f92c53b64e015a4caf1.camel@j-davis.com Author: Jeff Davis, adjustments by me Backpatch-through: 16 --- doc/src/sgml/datatype.sgml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 5d23765705..5a6cfbd94d 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1174,7 +1174,11 @@ SELECT '52093.89'::money::numeric::float8; character(n), char(n), bpchar(n) - fixed-length, blank padded + fixed-length, blank-padded + + + bpchar + variable unlimited length, blank-trimmed text @@ -1230,19 +1234,22 @@ SELECT '52093.89'::money::numeric::float8; The type name varchar is an alias for character - varying, while char and bpchar are - aliases for character. - The varchar and char aliases are defined in - the SQL standard, but bpchar is - a PostgreSQL extension. + varying, while bpchar (with length specifier) and + char are aliases for character. The + varchar and char aliases are defined in the + SQL standard; bpchar is a + PostgreSQL extension. If specified, the length n must be greater - than zero and cannot exceed 10485760. - character without length specifier is equivalent to - character(1). If character varying is used - without length specifier, the type accepts strings of any size. + than zero and cannot exceed 10,485,760. If character + varying (or varchar) is used without + length specifier, the type accepts strings of any length. If + bpchar lacks a length specifier, it also accepts strings + of any length, but trailing spaces are semantically insignificant. + If character (or char) lacks a specifier, + it is equivalent to character(1).