Thread: small bug in op + between datetime and integer
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
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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Oh, OK. --------------------------------------------------------------------------- Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian <pgman@candle.pha.pa.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
Tom Lane wrote: > Bruce Momjian <pgman@candle.pha.pa.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@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian <pgman@candle.pha.pa.us> writes: > Anyone have an idea on this one? There's a date + integer operator, but no integer + date operator. Yawn... regards, tom lane
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: "Tom Lane" <tgl@sss.pgh.pa.us> wrote: > Bruce Momjian <pgman@candle.pha.pa.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