Re: char column with a single space as the default not working

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: char column with a single space as the default not working
Дата
Msg-id 507459.1701374156@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: char column with a single space as the default not working  (Peter Gram <peter.m.gram@gmail.com>)
Ответы Re: char column with a single space as the default not working  (Ron Johnson <ronljohnsonjr@gmail.com>)
Список pgsql-admin
Peter Gram <peter.m.gram@gmail.com> writes:
> I think it behaves as expected. Look at my select "select
> encode(charcol::bytea, 'hex') , intcol from z;" it returns 20 which is a
> space in hex

Yeah, the space is stored.  What is probably surprising the OP
is that applying the || operator involves a coercion from "char"
to "text", which strips the defined-to-be-insignificant trailing
space(s) of the "char" value.

As David said, you're best off not using the char type.
The semantics around trailing spaces are too squishy for
my taste, and there's no real advantage compared to varchar
or text.

            regards, tom lane



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

Предыдущее
От: Peter Gram
Дата:
Сообщение: Re: char column with a single space as the default not working
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: char column with a single space as the default not working