Re: why do i get 2 as answer for select length('aa '::char(6));

Поиск
Список
Период
Сортировка
От john snow
Тема Re: why do i get 2 as answer for select length('aa '::char(6));
Дата
Msg-id CAE67tvWV2GpkGr6hUHfWVrHzn71HDqaxyiojxWyR6gCB2gWJ0g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: why do i get 2 as answer for select length('aa '::char(6));  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: why do i get 2 as answer for select length('aa '::char(6));
Список pgsql-novice
when you say char-type values, do you include varchar? if so, the other results (see later post from first post) i get are inconsistent with the assertion that length() disregards trailing spaces in char-type values, and i don't understand why it's inconsistent. i hope i'm not becoming annoying :-)

On Wed, Jan 17, 2018 at 11:09 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
john snow <ofbizfanster@gmail.com> writes:
> as well as select length('aa'::char(6));
> i thought if the string to be stored is shorter than specified length , it
> will be padded with spaces?

It *is* padded, as you can verify with other functions such as
octet_length or pg_column_size.  But length() disregards trailing
spaces in char-type values, on the theory that they're semantically
insignificant.

                        regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: why do i get 2 as answer for select length('aa '::char(6));
Следующее
От: Tom Lane
Дата:
Сообщение: Re: why do i get 2 as answer for select length('aa '::char(6));