summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-02-01 06:27:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-02-01 06:27:48 +0000
commitf27976c85b1fb9002727cce65b9f9567e158f754 (patch)
treea9f1424789b87795a21f0ae3453f49915c274681 /doc/src
parent08b0e605636d52bb8b2168dded694fe86f1acbea (diff)
Make length() disregard trailing spaces in char(n) values, per discussion
some time ago and recent patch from Gavin Sherry. Update documentation to point out that trailing spaces are insignificant in char(n).
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/datatype.sgml20
1 files changed, 18 insertions, 2 deletions
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 7bbe676a9a1..bcfe1690588 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.140 2004/01/20 22:46:06 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.141 2004/02/01 06:27:48 tgl Exp $
-->
<chapter id="datatype">
@@ -902,6 +902,18 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
</para>
<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
+ 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.
+ </para>
+
+ <para>
The storage requirement for data of these types is 4 bytes plus the
actual string, and in case of <type>character</type> plus the
padding. Long strings are compressed by the system automatically, so
@@ -922,7 +934,11 @@ CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
<para>
There are no performance differences between these three types,
apart from the increased storage size when using the blank-padded
- type.
+ type. While <type>character(<replaceable>n</>)</type> has performance
+ advantages in some other database systems, it has no such advantages in
+ <productname>PostgreSQL</productname>. In most situations
+ <type>text</type> or <type>character varying</type> should be used
+ instead.
</para>
</tip>