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