From: Pietro Pugni <pietro.pugni@gmail.com>
To: Pedro Gimeno <pgsql-004@personal.formauri.es>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Date: Fri, 28 Apr 2017 10:28:05 +0200
Message-ID: <F85A433C-95EA-40DE-A325-2EFF1E6DADFF@gmail.com> (raw)
In-Reply-To: <59024CC9.6050109@personal.formauri.es>
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>
<59024CC9.6050109@personal.formauri.es>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
> Il giorno 27 apr 2017, alle ore 21:55, Pedro Gimeno <pgsql-004@personal.formauri.es> ha scritto:
>
> I would like to better understand your expectations regarding your proposed fix.
>
> 1. What do you propose that this specific query should return?
>
> SELECT '1912-02-28'::date + interval '10 years’;
1922-02-28
(same result returned by Postgres)
> 2. What do you propose that this specific query should return?
>
> SELECT (whatever your answer to question 1 is)::date - interval '10 years’;
1912-02-28
(same result returned by Postgres but collides with result returned at point 4.)
> 3. What do you propose that this specific query should return?
>
> SELECT '1912-02-29'::date + interval '10 years’;
1922-02-28
(same result returned by Postgres)
> 4. What do you propose that this specific query should return?
>
> SELECT (whatever your answer to question 3 is)::date - interval '10 years’;
1912-02-29
(different from result returned at point 2.)
> 5. What do you propose that this specific query should return?
>
> SELECT '1912-03-01'::date + interval '10 years’;
1922-03-01
(same result returned by Postgres)
> 6. What do you propose that this specific query should return?
>
> SELECT (whatever your answer to question 5 is)::date - interval '10 years’;
1912-03-01
(same result returned by Postgres)
I’m aware that 2. and 4. can’t return different result because they are the same queries, but in that cases the result correctness depends on the context.
Probably it should be worth it to implement a sort of age2(timestamp, timestamp) function that returns ages accounting for leap years, without changing the actual implementation of age(timestamp, timestamp).
Kind regards,
Pietro Pugni
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, pgsql-004@personal.formauri.es
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
In-Reply-To: <F85A433C-95EA-40DE-A325-2EFF1E6DADFF@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> <59024CC9.6050109@personal.formauri.es> <F85A433C-95EA-40DE-A325-2EFF1E6DADFF@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