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

From David Fetter
Subject Re: Bug in date arithmetic
Date
Msg-id 20090825003407.GP5896@fetter.org
Whole thread Raw
In response to Re: Bug in date arithmetic  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bug in date arithmetic  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
On Mon, Aug 24, 2009 at 07:48:06PM -0400, Tom Lane wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.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@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Slaying the HYPOTamus
Next
From: Greg Stark
Date:
Subject: Re: Slaying the HYPOTamus