Re: [SQL] Interval subtracting - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [SQL] Interval subtracting
Date
Msg-id 14834.1141244891@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] Interval subtracting  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [SQL] Interval subtracting  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: [SQL] Interval subtracting  (Mark Dilger <pgsql@markdilger.com>)
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I don't think we can accept a change that takes a negative and turns it
> into a positive and negative.

Yeah, I find the patch's changes to the regression results pretty
disturbing.

Perhaps the correct definition ought to be like "if month part >= 0
then the reduced day part should be between 0 and 30, otherwise the
reduced day part should be between 0 and -30".  However there are
still corner cases to worry about.  If the original month and day
parts are of different sign, you might not be able to do such a
reduction without changing the sign of the month part, consider
"1 month -95 days".  Not clear what to do with this.

I guess I would expect a good result to satisfy one of these three
cases:* month > 0 and 0 <= day < 30* month < 0 and -30 < day <= 0* month = 0 and -30 < day < 30
If you believe that then "1 month -95 days" should justify to
"-2 months -5 days".
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [SQL] Interval subtracting
Next
From: Hannu Krosing
Date:
Subject: Re: [SQL] Interval subtracting