pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pietro Pugni <pietro.pugni@gmail.com>
To: Pantelis Theodosiou <ypercube@gmail.com>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Date: Fri, 28 Apr 2017 11:04:01 +0200
Message-ID: <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com> (raw)
In-Reply-To: <CAE3TBxzz-rSEsctew3HeKQQbQcsXErTKCgkXfEUosdsFtGCEbA@mail.gmail.com>
References: <20170426182322.24371.95224@wrigleys.postgresql.org>
	<CAKFQuwZ+PXKFrQ+LqOOorfva9nMesie0WQpe_hJTdkMn7vCZAw@mail.gmail.com>
	<5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com>
	<CAKFQuwZDo-CwNiqJ_v64HkKntggFmz1sN82n+FLy99qfez9-3g@mail.gmail.com>
	<AA4AA8B1-AD27-458F-9941-6E5B5F56EACA@gmail.com>
	<CAL9smLD5ARjoWon=YgJCXKD-Dc9cCPXOhNRQYxu_J-4ivPeuPw@mail.gmail.com>
	<6CEF6FC2-6081-48CC-B534-055594B3851A@gmail.com>
	<CAE3TBxzz-rSEsctew3HeKQQbQcsXErTKCgkXfEUosdsFtGCEbA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

> Il giorno 27 apr 2017, alle ore 14:31, Pantelis Theodosiou <ypercube@gmail.com> ha scritto:
> 
> You seem to think that expressions similar to these should yield the same results:
> 
>     dateD + intervalA + intervalB
> 
>     (dateD + intervalA) + intervalB
> 
>     dateD + (intervalA + intervalB)
> 
> But they don't and they couldn't, as many others have mentioned already.
> Expressions 1 and 2 are equivalent but the 3rd is not.
> 
> And we don't even need leap years to find such "wrong" results. We have leap seconds (which are rare) and leap months (which are pretty common although we don't call them leap months). Just try 
> 
> SELECT 
>    '2017-03-31'::date + '1 month'::interval + '1 month'::interval,
>    '2017-03-31'::date + ('1 month'::interval + '1 month'::interval) ;
> 
> Not all months have the same number of days and there is not a way to fix that.
> 
> It's just not possible to squeeze 31 days in a 30-days month. What should  '2017-03-31'::date + '1 month'::interval result and what should '2017-03-30'::date + '1 month'::interval result? 
> 
> Regards, 
> Pantelis


Probably it should be worth it to implement a sort of age2(timestamp, timestamp) function that returns ages accounting for leap years, months, days and seconds, without changing the actual implementation of age(timestamp, timestamp).

Kind regards,
 Pietro Pugni=

view thread (25+ messages)  latest in thread

Message-ID: <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com>
Permalink:  ../07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com/
Also on:    postgresql.org/message-id/07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: pietro.pugni@gmail.com, ypercube@gmail.com, marko@joh.to, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
  In-Reply-To: <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com>
  References: <20170426182322.24371.95224@wrigleys.postgresql.org> <CAKFQuwZ+PXKFrQ+LqOOorfva9nMesie0WQpe_hJTdkMn7vCZAw@mail.gmail.com> <5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com> <CAKFQuwZDo-CwNiqJ_v64HkKntggFmz1sN82n+FLy99qfez9-3g@mail.gmail.com> <AA4AA8B1-AD27-458F-9941-6E5B5F56EACA@gmail.com> <CAL9smLD5ARjoWon=YgJCXKD-Dc9cCPXOhNRQYxu_J-4ivPeuPw@mail.gmail.com> <6CEF6FC2-6081-48CC-B534-055594B3851A@gmail.com> <CAE3TBxzz-rSEsctew3HeKQQbQcsXErTKCgkXfEUosdsFtGCEbA@mail.gmail.com> <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox