Re: CHAR(n) always trims trailing spaces in 7.4

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CHAR(n) always trims trailing spaces in 7.4
Дата
Msg-id 19236.1077063947@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: CHAR(n) always trims trailing spaces in 7.4  ("scott.marlowe" <scott.marlowe@ihs.com>)
Ответы Re: CHAR(n) always trims trailing spaces in 7.4  (Richard Huxton <dev@archonet.com>)
Список pgsql-sql
"scott.marlowe" <scott.marlowe@ihs.com> writes:
> But then this:
> select 'x'||' '||'x'
> should produce xx, but it produces x x.

No, because the imputed type of those literals is text.  You'd have to
cast the middle guy to char(n) explicitly to make its trailing spaces go
away when it's reconverted to text.

The real issue here is that trailing spaces in char(n) are semantically
insignificant according to the SQL spec.  The spec is pretty vague about
which operations should actually honor that insignificance --- it's
clear that comparisons should, less clear about other things.  I think
the 7.4 behavior is more consistent than what we had before, but I'm
willing to be persuaded to change it again if someone can give an
alternate definition that's more workable than this one.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: CHAR(n) always trims trailing spaces in 7.4
Следующее
От:
Дата:
Сообщение: Re: CHAR(n) always trims trailing spaces in 7.4