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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
Дата
Msg-id CAKFQuwaGDMzxhifyQjAStjP-_e+cRJj=2hZ0Bbynrn9DjHTjSw@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #18051: char(N) and varchar(N) behave opposite to the documentation  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #18051: char(N) and varchar(N) behave opposite to the documentation  (Nicolas Gouteux <nicolas.gouteux@sonarsource.com>)
Список pgsql-bugs
On Wednesday, August 9, 2023, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18051
Logged by:          Nicolas Gouteux
Email address:      nicolas.gouteux@sonarsource.com
PostgreSQL version: 13.7
Operating system:   Linux
Description:       

create table if not exists ngx_char  (
   charcol char(10) not null,
   varcharcol varchar(10) not null
 );
truncate table ngx_char;
insert into ngx_char (charcol, varcharcol) values ('A', 'A');
insert into ngx_char (charcol, varcharcol) values ('A    ', 'A   ');
select charcol || 'B', varcharcol || 'C' from ngx_char;
select * from ngx_char where charcol = varcharcol;

Output:

?column?,?column?
AB,AC
AB,A   C

This is very strange! Is it me?

This is working as designed and documented.  The concatenation to text removes the insignificant white space in char.  There is no manipulation of content for varchar.

Just don’t use char.  There is no good reason to deal with its implicit behaviors.

David J.
 

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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #18051: char(N) and varchar(N) behave opposite to the documentation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_restore 14 skips ACL COLUMN when --schema is used