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