Thread: Time as keyword
Did time become a keyword in 7.2? 7.1.3 allowed it as a column name... 7.2 rejects it. Tks
Dwayne Miller <dwayne-miller@home.com> writes: > Did time become a keyword in 7.2? 7.1.3 allowed it as a column name... > 7.2 rejects it. It's always been a keyword, but it is "more reserved" than it used to be. See http://developer.postgresql.org/docs/postgres/sql-keywords-appendix.html However, according to that list TIME is still allowed as a column name, and indeed I get: regression=# create table foo (f1 time, time time); CREATE So I'm not sure what you did. regards, tom lane
On Thu, Jan 03, 2002 at 10:20:21PM -0500, Dwayne Miller wrote: > Did time become a keyword in 7.2? $ grep TIME src/backend/parser/keywords.c {"current_time", CURRENT_TIME},{"current_timestamp", CURRENT_TIMESTAMP},{"time",TIME},{"timestamp", TIMESTAMP}, -- Holger Krug hkrug@rationalizer.com
> Did time become a keyword in 7.2? 7.1.3 allowed it as a column name... > 7.2 rejects it. Yes. We now support SQL99 time and timestamp precision, which require that TIME(p) be a type specification. So there are parts of the grammar which cannot easily fit "time" anymore. You could/should use the SQL99 list of reserved words as a guide for which keywords to *not* use, even though some of them are currently accepted as, for example, column names. In the meantime, you can double-quote the column name if you really need it to stay "time". - Thomas
> > Did time become a keyword in 7.2? 7.1.3 allowed it as a column name... > > 7.2 rejects it. > > Yes. We now support SQL99 time and timestamp precision, which require > that TIME(p) be a type specification. So there are parts of the grammar > which cannot easily fit "time" anymore. Isn't the grammar explicit enough to distinguish a value (in this case function call) from a type name ? It seems a type name will only appear in very specific contexts. Imho it would be nice if we could allow "select timestamp(xxx);", and this has been the umpteenth request in this regard, and 7.2 is not even released yet. Andreas
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes: > Imho it would be nice if we could allow "select timestamp(xxx);", > and this has been the umpteenth request in this regard, and 7.2 is not even > released yet. Unfortunately, there's just no way. If we tried, it would be ambiguous whether, say, "timestamp(6)" is a function call or a type name. This is not one of my favorite parts of SQL92 syntax :-( regards, tom lane
... > Imho it would be nice if we could allow "select timestamp(xxx);", > and this has been the umpteenth request in this regard, and 7.2 is not even > released yet. afaicr one of the very sticky areas is the SQL99-specified syntax for date/time literals: timestamp(6) '2001-01-08 04:05:06' which is difficult to reconcile with a function named timestamp: timstamp(something) - Thomas
> > Imho it would be nice if we could allow "select timestamp(xxx);", > > and this has been the umpteenth request in this regard, and 7.2 is not even > > released yet. > > afaicr one of the very sticky areas is the SQL99-specified syntax for > date/time literals: > > timestamp(6) '2001-01-08 04:05:06' > > which is difficult to reconcile with a function named timestamp: But since '2001-01-08 04:05:06' is in single quotes it can't be a column label, which would be the only other "token?" after a function, no ? So it is eighter timestamp(6) followed by ' a single quote, or timestamp is a function in this context ??? Andreas
I tried to create table foo (t time, time time); and received an error something like 'Error parsing near time' I'm on 7.2.b2 I'll upgrade and try again. Tom Lane wrote: >Dwayne Miller <dwayne-miller@home.com> writes: > >>Did time become a keyword in 7.2? 7.1.3 allowed it as a column name... >>7.2 rejects it. >> > >It's always been a keyword, but it is "more reserved" than it used to >be. See > >http://developer.postgresql.org/docs/postgres/sql-keywords-appendix.html > >However, according to that list TIME is still allowed as a column name, >and indeed I get: > >regression=# create table foo (f1 time, time time); >CREATE > >So I'm not sure what you did. > > regards, tom lane >