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
This commit is contained in:
Bruce Momjian 2023-10-31 10:13:11 -04:00
parent 04e5b1d586
commit 83981bcbac
1 changed files with 17 additions and 10 deletions

View File

@ -1174,7 +1174,11 @@ SELECT '52093.89'::money::numeric::float8;
</row> </row>
<row> <row>
<entry><type>character(<replaceable>n</replaceable>)</type>, <type>char(<replaceable>n</replaceable>)</type>, <type>bpchar(<replaceable>n</replaceable>)</type></entry> <entry><type>character(<replaceable>n</replaceable>)</type>, <type>char(<replaceable>n</replaceable>)</type>, <type>bpchar(<replaceable>n</replaceable>)</type></entry>
<entry>fixed-length, blank padded</entry> <entry>fixed-length, blank-padded</entry>
</row>
<row>
<entry><type>bpchar</type></entry>
<entry>variable unlimited length, blank-trimmed</entry>
</row> </row>
<row> <row>
<entry><type>text</type></entry> <entry><type>text</type></entry>
@ -1230,19 +1234,22 @@ SELECT '52093.89'::money::numeric::float8;
<para> <para>
The type name <type>varchar</type> is an alias for <type>character The type name <type>varchar</type> is an alias for <type>character
varying</type>, while <type>char</type> and <type>bpchar</type> are varying</type>, while <type>bpchar</type> (with length specifier) and
aliases for <type>character</type>. <type>char</type> are aliases for <type>character</type>. The
The <type>varchar</type> and <type>char</type> aliases are defined in <type>varchar</type> and <type>char</type> aliases are defined in the
the <acronym>SQL</acronym> standard, but <type>bpchar</type> is <acronym>SQL</acronym> standard; <type>bpchar</type> is a
a <productname>PostgreSQL</productname> extension. <productname>PostgreSQL</productname> extension.
</para> </para>
<para> <para>
If specified, the length <replaceable>n</replaceable> must be greater If specified, the length <replaceable>n</replaceable> must be greater
than zero and cannot exceed 10485760. than zero and cannot exceed 10,485,760. If <type>character
<type>character</type> without length specifier is equivalent to varying</type> (or <type>varchar</type>) is used without
<type>character(1)</type>. If <type>character varying</type> is used length specifier, the type accepts strings of any length. If
without length specifier, the type accepts strings of any size. <type>bpchar</type> lacks a length specifier, it also accepts strings
of any length, but trailing spaces are semantically insignificant.
If <type>character</type> (or <type>char</type>) lacks a specifier,
it is equivalent to <type>character(1)</type>.
</para> </para>
<para> <para>