Re: question about deparsing const node and its typmod

Поиск
Список
Период
Сортировка
От Tao Ma
Тема Re: question about deparsing const node and its typmod
Дата
Msg-id gr1ahp$k63$1@news.hub.org
обсуждение исходный текст
Ответ на question about deparsing const node and its typmod  ("Tao Ma" <feng_eden@163.com>)
Ответы Re: question about deparsing const node and its typmod  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Thank you for your reply to the question. If it was chosen to reproduce the
actual semantics of the expression in various contexts, I think the bpchar
type of 'abc'::bpchar is surprised me. Is it really important to show the
'bpchar' if there is no any explicit casting for the column default value.

I searched for 'default' and 'bpchar' in CVS history and failed
to figure out the reason why the 'bpchar' need to be displayed. Maybe for
the CHECK expression or the default value including operator or function the
category type can be extremely usefuly to help us understand the type conversion
result.

Is it possible to omit the bpchar or something like it, if it is a const node
for the default value?


"Tom Lane" <tgl@sss.pgh.pa.us> writes:18655.1238258851@sss.pgh.pa.us...
> "Tao Ma" <feng_eden@163.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
>
> -- 
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
> 




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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: protect dll lib initialisation against any exception, for 8.5
Следующее
От: Tino Wildenhain
Дата:
Сообщение: Re: [GENERAL] string_to_array with empty input