Re: small bug in op + between datetime and integer

Lists: pgsql-bugs
From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: pgsql-bugs(at)postgresql(dot)org
Subject: small bug in op + between datetime and integer
Date: 2003-08-04 05:56:18
Message-ID: Pine.LNX.4.44.0308040748370.29876-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hello

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.

I use CVS version of PostgreSQL from last week

regards

Pavel Stehule


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: small bug in op + between datetime and integer
Date: 2003-08-05 05:09:21
Message-ID: 200308050509.h7559Lg25726@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


I can verify this is an existing bug in CVS.

---------------------------------------------------------------------------

Pavel Stehule wrote:
> Hello
>
> 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.
>
> I use CVS version of PostgreSQL from last week
>
> regards
>
> Pavel Stehule
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: small bug in op + between datetime and integer
Date: 2003-08-17 04:13:24
Message-ID: 200308170413.h7H4DOs07645@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Anyone have an idea on this one?

---------------------------------------------------------------------------

Pavel Stehule wrote:
> Hello
>
> 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.
>
> I use CVS version of PostgreSQL from last week
>
> regards
>
> Pavel Stehule
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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 04:52:00
Message-ID: 8939.1061095920@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Anyone have an idea on this one?

There's a date + integer operator, but no integer + date operator.
Yawn...

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(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 04:53:58
Message-ID: 200308170453.h7H4rwX11811@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Anyone have an idea on this one?
>
> There's a date + integer operator, but no integer + date operator.
> Yawn...

Uh, "Yawn" means we don't need to fix it, or "oh, here's another one"?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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 04:57:01
Message-ID: 9003.1061096221@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> There's a date + integer operator, but no integer + date operator.
>> Yawn...

> Uh, "Yawn" means we don't need to fix it, or "oh, here's another one"?

It means "I can't get excited about it." The docs don't claim that we
have such an operator (do they?) and I see no clear advantage to adding
one.

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(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:09:13
Message-ID: 200308170509.h7H59Dq13652@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Oh, OK.

---------------------------------------------------------------------------

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> There's a date + integer operator, but no integer + date operator.
> >> Yawn...
>
> > Uh, "Yawn" means we don't need to fix it, or "oh, here's another one"?
>
> It means "I can't get excited about it." The docs don't claim that we
> have such an operator (do they?) and I see no clear advantage to adding
> one.
>
> regards, tom lane
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


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: Raw Message | Whole Thread | Download mbox | Resend email
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: "Gaetano Mendola" <mendola(at)bigfoot(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: small bug in op + between datetime and integer
Date: 2003-08-17 08:17:44
Message-ID: 022101c36498$095c8210$10d4a8c0@mm.eutelsat.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> There's a date + integer operator, but no integer + date operator.
> >> Yawn...
>
> > Uh, "Yawn" means we don't need to fix it, or "oh, here's another one"?
>
> It means "I can't get excited about it." The docs don't claim that we
> have such an operator (do they?) and I see no clear advantage to adding
> one.

Well, I think that have the operator integer + date is not necessary but is
better to have just to forget that not exist each time that someone wrote an
expression involving integer and date.

Regards
Gaetano Mendola