"Andrus" <[EMAIL PROTECTED]> writes:
> 1. SQL assumes that CHARACTER(n) column is always padded with spaces in 
> right.
> So casting to text should preserve spaces.

No, it should not.  In CHAR(n), trailing spaces are semantically
insignificant; 'foo' and 'foo ' are considered equal.  In TEXT
they are just as significant as any other character, and those strings
are definitely not equal.  So 'foo ' as CHAR(4) and 'foo ' as TEXT
do not actually mean the same thing at all, and similarly ' ' means
two different things as CHAR(1) and as TEXT, even though they look
the same.

The SQL spec's definition of CHAR(n) behavior is really pretty broken
in my opinion; you're almost always better off using varchar.  In this
particular case, where you think that a space has semantic significance,
CHAR(n) is simply wrong.

                        regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to