"Marcus Andree S. Magalhaes" <marcus.magalhaes@vlinfo.com.br> writes:
> If I understand correctly, this will lead to the following situation:
> CHAR_LENGTH('ABCD') == CHAR_LENGTH('ABCD ') == 4
> This will definitely break some of our applications.
If you think trailing spaces are semantically significant, you should be
using varchar or text fields to store them. In CHAR(n) fields they are
not significant, and we're doing our best to make that interpretation
consistent across all operations.
Just for the record, I get this with CVS tip:
regression=# select CHAR_LENGTH('ABCD ');
char_length
-------------
8
(1 row)
regression=# select CHAR_LENGTH('ABCD '::text);
char_length
-------------
8
(1 row)
regression=# select CHAR_LENGTH('ABCD '::varchar);
char_length
-------------
8
(1 row)
regression=# select CHAR_LENGTH('ABCD '::char(8));
char_length
-------------
4
(1 row)
(the first and second cases are in fact the same)
regards, tom lane