Re: [HACKERS] Why DEFAULT text 'now' does not work for TIMESTAMP columns

Поиск
Список
Период
Сортировка
От Ross J. Reedstrom
Тема Re: [HACKERS] Why DEFAULT text 'now' does not work for TIMESTAMP columns
Дата
Msg-id 19990718204807.A18807@wallace.ece.rice.edu
обсуждение исходный текст
Ответ на Why DEFAULT text 'now' does not work for TIMESTAMP columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Sun, Jul 18, 1999 at 06:19:41PM -0400, Tom Lane wrote:
<excellent problem analysis snipped>
> 
> I am about to commit parser fixes that ensure a DEFAULT value is
> correctly coerced to the column type when it is used (that is,
> transformInsertStatement now does a coerce_type rather than just
> assuming what is in pg_attrdef is the right type).  So, one possible
> approach is to remove the coercion code from StoreAttrDefault
> altogether.  That would mean that
>         field1 datetime 'now'
> would start acting the same as
>         field1 datetime text 'now'
> currently does: both of them would be coerced to datetime at runtime,
> not when the constraint expression is created.  Given the frequency
> with which newbies complain about the current behavior, I think that
> that might be a Good Thing.  But it would be a change in behavior,
> and I suppose there are scenarios where you'd like to be able to get
> the old behavior.
> 
> Comments?

My only comment: it seems to me that after your fix, one could still get the
old behavior via something like:              field1 datetime now()
or perhaps:              field1 datetime 'now'::datetime
correct? And the default behavior will now be what most naive users
expect.  As long as a workaround exists for the cases where someone cares
about the table definition time, I wouldn't worry about staying 'bug'
(or misfeature?) compatible, unless it's an official, committee backed
SQL standard misfeature, of course. ;-) Sounds good to me.

Ross
-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Why DEFAULT text 'now' does not work for TIMESTAMP columns
Следующее
От: Vadim Mikheev
Дата:
Сообщение: Re: [HACKERS] Fix up for BTP_CHAIN problems