| From: | Dennis Björklund <db(at)zigo(dot)dhs(dot)org> |
|---|---|
| To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
| Cc: | Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>, <pgsql-bugs(at)postgresql(dot)org> |
| Subject: | Re: small bug in op + between datetime and integer |
| Date: | 2003-08-17 05:30:21 |
| Message-ID: | Pine.LNX.4.44.0308170720240.15267-100000@zigo.dhs.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Sun, 17 Aug 2003, Bruce Momjian wrote:
> Anyone have an idea on this one?
>
> > It is maybe not bug, but I didn't find any warning about this behavior.
> >
> > select current_date + 1; -- ok
> > select 1 + current_date; -- not
> >
> > ERROR: operator does not exist: integer + date
> > HINT: No operator matches the given name and argument type(s). You may
> > need to add explicit typecasts.
It's not a bug. The operator + has one definition of the type
(date,integer) -> date
but there is no definition for
(integer,date) -> date
Instead of integer one can also have an interval. So if you start with a
date you can add an interval to it. But if you start with a time interval
you can not add a date to it. What would it mean to add a date to
something? I have no idea. Well, that's the logic behind the current
behaviour.
It would of course not be difficult to add a definition of + with the
integer first and the date as the second argument. To me it's not much of
an improvement, but it's not for me to decide. The postgresql operator +
is not the same as the mathematical operator + and it does not have the
same properties.
--
/Dennis
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2003-08-17 05:44:31 | Re: ALTER SCHEMA problem |
| Previous Message | Bruce Momjian | 2003-08-17 05:28:05 | Re: ALTER SCHEMA problem |