varchar() troubles

Поиск
Список
Период
Сортировка
От Thomas G. Lockhart
Тема varchar() troubles
Дата
Msg-id 34BA2DF8.84496BD1@alumni.caltech.edu
обсуждение исходный текст
Ответы Re: varchar() troubles  (Bruce Momjian <maillist@candle.pha.pa.us>)
Список pgsql-hackers
I've been seeing trouble with varchar() columns for a little while, and
since it is still there with a fresh install of the development tree
it's time to report it:

postgres=> create table t (v varchar(80),i int);
CREATE
postgres=> insert into t values ('hi',1);
INSERT 18122 1
postgres=> select * from t;
v |i
--+-
hi|0
(1 row)

As you can see, the varchar() column apparently trashes the subsequent
column. I ran across it trying to verify the tutorial examples for the
documentation. If the varchar() is the last column in the table, the
problem does not crop up, at least in the simplest case:

postgres=> create table t2 (i int, v varchar(80));
CREATE
postgres=> insert into t2 values (2,'hi');
INSERT 18133 1
postgres=> select * from t2;
i|v
-+--
2|hi
(1 row)

Also, I believe that if the varchar() field is substantially shorter the
problem does not manifest itself:

postgres=> create table t4 (v varchar(4), i int);
CREATE
postgres=> insert into t4 values ('hi',4);
INSERT 18156 1
postgres=> select * from t4;
v |i
--+-
hi|4
(1 row)

but varchar(10) still shows the problem:

postgres=> create table t3 (v varchar(10), i int);
CREATE
postgres=> insert into t3 values ('hi',3);
INSERT 18145 1
postgres=> select * from t3;
v |i
--+-
hi|0
(1 row)

This is from the development source as of around 1998-01-12 14:30 GMT

                                                                    -
Tom


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

Предыдущее
От: Andrew Martin
Дата:
Сообщение: Compression (was Re: [HACKERS] varchar/char size)
Следующее
От: Andrew Martin
Дата:
Сообщение: Re: [HACKERS] PSQL man page patch