Bug or feature? Timestamp parsing
Bug or feature? Timestamp parsing
От:
Josh Berkus <josh@agliodbs.com>
Дата:
select 'NOW?'::TIMESTAMP; timestamp ----------------------------2010-06-09 14:08:21.020259 postgres=# select ';;;infinity???#@$%$'::TIMESTAMP;timestamp -----------infinity (1 row) It appears that the ts parser will ignore any punctuation surrounding the special value calls. In general, this isn't a potential problem. However, it could cause some confusion with careless value replacement by users. Imagine a case like this: create or replace function epoch(integer) returns timestamp language sql as 'SELECT ''epoch''::timestamp + $1 * interval ''1 second'';'; Then later you fail on your client quoting rules and do the following in your app code: UPDATE some_tableSET timestamp_field = 'epoch(150000)' WHERE id = 501; The above will result in 1970-01-01 00:00:00 UTC getting into the field, not 1970-01-02 17:40:00 as the user intended, since the '(150000)' will be ignored. And given the lack of an error message, a lot of debugging time. On the other hand, it appears that our timestamps have had this bug since at least 8.0, so it clearly isn't a widespread problem for most users. And likely some users have been "taking advantage" of letting garbage into their timestamp casts, so there would be some application breakage. Thoughts? -- -- Josh Berkus PostgreSQL Experts Inc. http://www.pgexperts.com
Re: Bug or feature? Timestamp parsing
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Josh Berkus writes: > It appears that the ts parser will ignore any punctuation surrounding > the special value calls. The datetime parser ignores "extraneous" punctuation all over the place, not only with regards to special values. I'm hesitant to monkey with that, because there are so many weird date formats out there. > On the other hand, it appears that our timestamps have had this bug > since at least 8.0, so it clearly isn't a widespread problem for most > users. It's had that behavior since Tom Lockhart was messing with it, maybe even before that. regards, tom lane