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

From Greg Stark
Subject Re: Bug in date arithmetic
Date
Msg-id 407d949e0908241313t20b0e78ekeb524846850cbbef@mail.gmail.com
Whole thread Raw
In response to Re: Bug in date arithmetic  (David Fetter <david@fetter.org>)
Responses Re: Bug in date arithmetic  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Bug in date arithmetic  (David Fetter <david@fetter.org>)
Re: Bug in date arithmetic  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
On Mon, Aug 24, 2009 at 8:27 PM, David Fetter<david@fetter.org> wrote:
> I'm thinking that the unknown literal here should just cause an error
> in the case of '+'.  Same with '-', for what it's worth.

That would make a lot of people very unhappy. They expect things like

select date + '1 year'

to just work.

The problem is that they would also like

select date - '1year'
and
select date - '2000-01-01'

to work.

I wonder if we could get around this by inventing a new type
date_or_interval which looks at the input and decides which it is
using fairly strict rules. date_sub would take that type and do the
appropriate operation based on what the constant had in it.

Of course we still want to be able to do date1 - date2 or
date1+intervalcolumn so we would need implicit casts from date and
interval to this new type. The question is whether we could arrange
things so this implicit cast doesn't cause ambiguity elsewhere.

--
greg
http://mit.edu/~gsstark/resume.pdf


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: hba load error and silent mode
Next
From: Peter Eisentraut
Date:
Subject: Re: Feedback about Drupal SQL debugging