Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation

Поиск
Список
Период
Сортировка
От Félix GERZAGUET
Тема Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
Дата
Msg-id CANVwZtvyiT3Vz-RB8V-nvzt4tjZ-C8ucaBpVZ77w5v_xMOFTVA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation  (Nicolas Gouteux <nicolas.gouteux@sonarsource.com>)
Список pgsql-bugs
Hello Nicolas,

On Wed, Aug 9, 2023 at 4:47 PM Nicolas Gouteux <nicolas.gouteux@sonarsource.com> wrote:
I was just trying to show more junior programmers the difference between the 'assumed' padded char and the more modern 'trimming' varchar
So imagine my surprise when both length() and concatenation() yielded the exactly opposite behavior than expected!

For such pedagogic purpose you can use:

select length(cast('A' as char(4))::bytea)

But you then have to explain the ::bytea trick :-)

Best Regards,

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

Предыдущее
От: Nicolas Gouteux
Дата:
Сообщение: Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
Следующее
От: David Rowley
Дата:
Сообщение: Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation