| From: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> | 
|---|---|
| To: | Leon <leon(at)udmnet(dot)ru> | 
| Cc: | "'pgsql-general(at)hub(dot)org'" <pgsql-general(at)postgreSQL(dot)org> | 
| Subject: | Re: [GENERAL] Weird behavior of 'default user' | 
| Date: | 1999-07-16 16:18:31 | 
| Message-ID: | 199907161618.MAA16449@candle.pha.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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(at)candle(dot)pha(dot)pa(dot)us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jason Landers | 1999-07-16 21:48:34 | cant get PostgreSQL to boot on RedHat 6.0... | 
| Previous Message | Michael Doornbos | 1999-07-16 14:51:26 | concurrent connections |