char() datatype looses strings of all spaces

Поиск
Список
Период
Сортировка
От Joe Conway
Тема char() datatype looses strings of all spaces
Дата
Msg-id 3F3F0D8B.4060802@joeconway.com
обсуждение исходный текст
Ответы Re: char() datatype looses strings of all spaces  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: char() datatype looses strings of all spaces  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-hackers
I stumbled across this behavior today and it seems strange if not a bug:

-- this seems wrong
vsconf=# create table foo (f1 char(1));
CREATE TABLE
vsconf=# insert into foo values(' ');
INSERT 9002011 1
vsconf=# select ascii(f1) from foo; ascii
-------     0
(1 row)

-- this is what I'd expect
vsconf=# create table foo2 (f1 varchar(1));
CREATE TABLE
vsconf=# insert into foo2 values(' ');
INSERT 9002015 1
vsconf=# select ascii(f1) from foo2; ascii
-------    32
(1 row)

-- this seems wrong
vsconf=# create table foo4 (f1 char(5));
CREATE TABLE
vsconf=# insert into foo4 values('     ');
INSERT 9002022 1
vsconf=# select ascii(f1) from foo4; ascii
-------     0
(1 row)

I looked for a few minutes at bpcharin(), but could not see exactly why 
this is happening. Am I missing something wrt the char() data type, or 
is this a bug?

Joe



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: "truncate all"?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Parsing speed (was Re: pgstats_initstats() cost)