Re: [GENERAL] Weird behavior of 'default user'
От | Bruce Momjian |
---|---|
Тема | Re: [GENERAL] Weird behavior of 'default user' |
Дата | |
Msg-id | 199907161618.MAA16449@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Weird behavior of 'default user' (Leon <leon@udmnet.ru>) |
Список | pgsql-general |
> Hello! > > Look at this: > > ------------------ > adb=> create table hh (dd char(2) default user, ff int4); > CREATE > adb=> insert into hh (ff) values (5); > INSERT 572034 1 > adb=> select * from hh; > dd |ff > ----+-- > leon| 5 > (1 row) > ------------------ > > How can I understand that? Column dd is of type char(2), whereas > 'leon' is four characters! Even more, look here: > > ------------------ > adb=> insert into hh values (user, 7); > INSERT 572045 1 > adb=> select * from hh; > dd |ff > ----+-- > leon| 5 > le | 7 > (2 rows) > ------------------ > > This absolutely beyond my mind. This means that user, being > inserted explicitly, is correctly truncated. If it is inserted > by default, it is wider than column! Seems something very strange > is going on here. > Yes, this is a known problem. If the default were a fixed string: test=> create table hh2 (dd char(2) default 'fred', ff int4); it works, but 'user' is system variable, and not auto-converted. Tom Lane pointed this out as a problem before, but it was too close to 6.5 to fix. Added to TODO: * CREATE TABLE test(col char(2) DEFAULT user) fails in length restriction -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
В списке pgsql-general по дате отправления: