Re: Bug in date arithmetic

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Greg Stark <gsstark(at)mit(dot)edu>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in date arithmetic
Date: 2009-08-25 00:34:07
Message-ID: 20090825003407.GP5896@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 24, 2009 at 07:48:06PM -0400, Tom Lane wrote:
> "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> > I realize I'm in a minority on this, but I would also prefer an
> > error. I expect things like
> >
> > SELECT "date" + (INTERVAL '1' YEAR)
> >
> > to just work.
>
> Uh, I think you're confused. That certainly works, and I didn't
> hear anyone proposing to change it. The issue is about undecorated
> literals. If we start throwing errors for those, the fallout will
> make the 8.3 implicit-cast changes look like a day at the beach. I
> believe that it would also violate the SQL spec in numerous places
> --- whether you like it or not, the concept of context-dependent
> type resolution is built into the standard.

As far as you can tell, does the standard speak to adding an untyped
literal to a time format? The draft standard I have here lists,
"Valid operators involving datetimes and intervals" as,

Operand 1 Operator Operand 2 Result Type
Datetime – Datetime Interval
Datetime + or – Interval Datetime
Interval + Datetime Datetime
Interval + or – Interval Interval
Interval * or / Numeric Interval
Numeric * Interval Interval

It's not crystal clear to me whether any type coercion behavior is
mandated here, or which kind, if there is some.

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-08-25 01:17:35 Re: Slaying the HYPOTamus
Previous Message Tom Lane 2009-08-25 00:14:31 Re: Slaying the HYPOTamus