Re: BUG #1993: Adding/subtracting negative time intervals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, Michael Glaesemann <grzm(at)myrealbox(dot)com>, Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>, Russell Smith <mr-russ(at)pws(dot)com(dot)au>, pgsql-bugs(at)postgresql(dot)org, Nicholas <hb(at)x256(dot)com>
Subject: Re: BUG #1993: Adding/subtracting negative time intervals
Date: 2005-10-25 04:37:39
Message-ID: 9631.1130215059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> Urgh. I think this is a serious thinko in Michael Glaesemann's rewrite
>> of interval_mul.

> The reason interval_justify_hours is called by interval multiplication
> is so multipling an interval '2 days, 4 hours' by 10 doesn't return
> values like 20 days, 40 hours, etc, but instead something like '21 days,
> 16 hours', which seems more reasonable.

That's utterly WRONG, though. The entire *point* of the 8.1 change is
that days and hours are incommensurable. We are forced to down-convert
in some cases --- for example, we can't compute a useful result for
"0.5 * '1 day'" without imputing "12 hours" as the equivalent of 0.5 day
--- but we never have to and never should up-convert, except by explicit
user command ... which is what the justify_hours function is for.

> One solution would be
> to suggest the use of interval_justify_hours() in the documentation for
> interval multiplication, and prevent the justification from happening
> automatically.

Exactly. Forcing the justification to happen is broken, because there's
no way to get the other behavior.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruno Wolff III 2005-10-25 05:31:39 Re: BUG #1943: Lock A row with the option NoWait
Previous Message Bruce Momjian 2005-10-25 04:23:51 Re: BUG #1993: Adding/subtracting negative time intervals

Browse pgsql-hackers by date

  From Date Subject
Next Message daveg 2005-10-25 05:52:17 Re: PG Killed by OOM Condition
Previous Message Bruno Wolff III 2005-10-25 04:26:52 Re: PG Killed by OOM Condition