Re: [SQL] Interval subtracting

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Mark Dilger <pgsql(at)markdilger(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] Interval subtracting
Date: 2006-03-01 23:26:24
Message-ID: 200603012326.k21NQOv08610@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql

Mark Dilger wrote:
> Tom Lane wrote:
> > Well, the question is whether justify_days has a sane definition that is
> > different from this. Based on your example, I'm not seeing one.
>
> Backwards compatibility is probably more important than sanity. Let's just
> deprecate the existing functions and recommend that people use
> justify_interval(...). By not changing the existing functions we can avoid a
> certain amount of hell.

Those functions are new in 8.1 so I do think we can improve them in 8.2
if we agree. Tom's idea of:

> * month > 0 and 0 <= day < 30
> * month < 0 and -30 < day <= 0
> * month = 0 and -30 < day < 30

seems a good change for 8.2, and the same for justify_hours(). The
question is whether justify_days should also adjust hours I think is the
issue, and the reason for a justify_interval() function. Even if we had
people do:

justify_hours(justify_days(justify_hours()))

I don't think that would do what we want in all cases. Consider '1 mon
-1 hour'. That should be '29 days 23 hours' but neither existing
function, even if modified, will allow us to return that. Only
something like justify_interval() could do it.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2006-03-01 23:43:58 Re: [SQL] Interval subtracting
Previous Message Tom Lane 2006-03-01 23:23:53 Re: [SQL] Interval subtracting

Browse pgsql-patches by date

  From Date Subject
Next Message Mark Dilger 2006-03-01 23:43:58 Re: [SQL] Interval subtracting
Previous Message Tom Lane 2006-03-01 23:23:53 Re: [SQL] Interval subtracting

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Dilger 2006-03-01 23:43:58 Re: [SQL] Interval subtracting
Previous Message Tom Lane 2006-03-01 23:23:53 Re: [SQL] Interval subtracting