From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Tao Ma" <feng_eden(at)163(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: question about deparsing const node and its typmod |
Date: | 2009-03-28 16:47:31 |
Message-ID: | 18655.1238258851@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"Tao Ma" <feng_eden(at)163(dot)com> writes:
> CREATE TABLE "t" (c1 CHAR(5) DEFAULT 'abc',
> c2 CHAR(5) DEFAULT 'abc'::CHAR(5));
> SELECT pg_get_expr(adbin, adrelid)
> FROM pg_attrdef
> WHERE adrelid = (SELECT oid FROM pg_class WHERE relname = 't');
> pg_get_expr
> ---------------------
> 'abc'::bpchar
> 'abc'::character(5)
> (2 rows)
> so I am courious about is there any possibility to make the default value
> for c1 look like the default value for c2.
That behavior is very carefully chosen to reproduce the actual semantics
of the expression in various contexts. We can't change it just to make
it "look prettier".
If you check the CVS history of ruleutils.c to see when that logic got
changed, you should be able to locate pgsql-hackers discussions that
worked out what the behavior has to be. I seem to remember that the
most recent iteration had to do with making sure that ALTER COLUMN TYPE
had unsurprising side-effects on the column's default.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-03-28 17:01:41 | Re: [COMMITTERS] pgsql: Temporarily (I hope) disable flattening of IN/EXISTS sublinks |
Previous Message | Tom Lane | 2009-03-28 16:25:16 | Re: 8.4 open items list |