Re: BUG #3561: CHAR(x) blank stripped. Server or documentation bug?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Alexander Kirpa" <postgres(at)bilteks(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #3561: CHAR(x) blank stripped. Server or documentation bug?
Date: 2007-08-21 11:04:51
Message-ID: 87zm0lb12k.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Alexander Kirpa" <postgres(at)bilteks(dot)com> writes:

> select '['||a||']' as aa,'['||b||']' as bb from test1;
> aa | bb
> ----------+----------
> [ok] | [ok]
> [ bad] | [ bad ]
> [ poor] | [ poor]
> (3 rows)
> It is easy to see that char(x) field really blank stripped.
> This is bug of server or documentation?

From the documentation:

> Values of type character are physically padded with spaces to the specified
> width 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 character, and they will be removed when
> converting a character value to one of the other string types. Note that
> trailing spaces are semantically significant in character varying and text
> values.

Concatenation is an example of an operation where the padding spaces are
treated as semantically insignificant, so they get removed before the
concatenation.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Randolf Richardson 2007-08-21 23:53:32 BUG #3563: DATESTYLE feature suggestion
Previous Message Alexander Kirpa 2007-08-21 08:57:05 BUG #3561: CHAR(x) blank stripped. Server or documentation bug?