Thread: default modifiers for 7.2b4
has the default clause been changed for 7.2b4 so as not use a statement as such:
create table news(
id serial,
date date DEFAULT 'select now()::date' NOT NULL,
topic varchar(256),
body text
);
the above query results in ERROR: Bad date external representation 'select now()::date', yet if I use this on a production 7.1.2 machine it works fine.
Mike
"mike" <matrix@vianet.ca> writes: > create table news( > id serial, > date date DEFAULT 'select now()::date' NOT NULL, > topic varchar(256), > body text > ); [ goggles ] > the above query results in ERROR: Bad date external representation 'select= > now()::date', yet if I use this on a production 7.1.2 machine it works fin= > e. Apparently the 7.1.* date parser was rather more forgiving than it should have been. You might care to contemplate the difference between select 'now'::date; and select 'select now()::date'::date; or just to make it crystal clear, select 'foo now#&%!@bar'::date; regards, tom lane
(cross posted to -hackers, just in case...) > or just to make it crystal clear, > select 'foo now#&%!@bar'::date; Oh yeah. From the 1.0x days of Postgres95 (and probably earlier) the date/time parser ignored any part of a date string it didn't understand. That has been the case, more or less, until select date 'now' ;) As you might imagine, that could lead to Really Bad Errors, such as ignoring mistyped time zones. So for 7.2 fields are not ignored, unless they are on the short list of strings which have been explicitly ignored forever. For example, 'abstime' can be inside a date string without trouble, to support compatibility with the argument 'Invalid Abstime', which apparently was actually emitted by Postgres or Postgres95 (or maybe someone thought it may be someday. Who knows??!). Anyway, the parsing has been tightened up a bit. btw, there are some new features in the parser in addition to this, such as supporting more varied forms of ISO-8601 dates and times. - Thomas