1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

docs: document behavior of CHAR() comparisons with chars < space

Space trimming rather than space-padding causes unusual behavior, which
might not be standards-compliant.

Also remove recently-added now-redundant C comment.
This commit is contained in:
Bruce Momjian
2014-02-24 12:09:23 -05:00
parent 6615e77439
commit 8457d0beca
2 changed files with 7 additions and 16 deletions

View File

@ -1078,10 +1078,13 @@ SELECT '52093.89'::money::numeric::float8;
<para>
Values of type <type>character</type> are physically padded
with spaces to the specified width <replaceable>n</>, and are
stored and displayed that way. However, the padding spaces are
treated as semantically insignificant. Trailing spaces are
disregarded when comparing two values of type <type>character</type>,
and they will be removed when converting a <type>character</type> value
stored and displayed that way. However, trailing spaces are treated as
semantically insignificant and disregarded when comparing two values
of type <type>character</type>. In collations where whitespace
is significant, this behavior can produce unexpected results,
e.g. <command>SELECT 'a '::CHAR(2) collate "C" < 'a\n'::CHAR(2)
returns true.
Trailing spaces are removed when converting a <type>character</type> value
to one of the other string types. Note that trailing spaces
<emphasis>are</> semantically significant in
<type>character varying</type> and <type>text</type> values, and