Re: Bug in date arithmetic - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug in date arithmetic
Date
Msg-id 14437.1251132406@sss.pgh.pa.us
Whole thread Raw
In response to Bug in date arithmetic  (David Fetter <david@fetter.org>)
Responses Re: Bug in date arithmetic  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
David Fetter <david@fetter.org> writes:
> While debugging an error with Aziz (postgres_newbie) Sharief in the
> #postgresql IRC channel, I found a major POLA violation:

I see no bug here.  There is only one '+' operator with timestamptz
as left input, and it is timestamptz plus interval, so the system
takes the unknown literal as an interval.  Possibly it should throw
error instead of assuming that the unmarked value is in seconds, but
I'll bet money that people are depending on that longstanding behavior.
As for the other case, there are two possible interpretations:

regression=# select oid::regoperator from pg_operator where oprname = '-' and oprleft = 'timestamptz'::regtype;
              oid                          
 
-------------------------------------------------------(timestamp with time zone,timestamp with time zone)-(timestamp
withtime zone,interval)
 
(2 rows)

and the first one is preferred due to an ancient and generally correct
heuristic.  I'm not sure why it's complaining about field overflow
rather than syntax error when the literal is taken as a timestamp,
but that's a pretty minor issue.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: hba load error and silent mode
Next
From: Tom Lane
Date:
Subject: Re: DELETE syntax on JOINS