Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d41Gq-0005jH-Fp for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2017 08:28:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d41Gq-0006PL-2B for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2017 08:28:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d41G8-0004t4-M5 for pgsql-bugs@postgresql.org; Fri, 28 Apr 2017 08:28:12 +0000 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d41G5-0005ZI-0h for pgsql-bugs@postgresql.org; Fri, 28 Apr 2017 08:28:12 +0000 Received: by mail-wr0-x234.google.com with SMTP id w50so29618991wrc.0 for ; Fri, 28 Apr 2017 01:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=dEtFsfngKL6FXubW7lPMq0XE2Dl8+Q0xNxh9HraDtXU=; b=JjBVv8YwMjlz/mP5kxl1nAWMOE+R8VirdzKN1fvqMEe88Jy999LR3uBCcUmLiM1ndK lQLcNFH2TWb/FC4zhbWEPau5mx9zd3vQhsQtktPB9o7T+2aCRy5NQfCUeV9rN9M7SZFF 4wl9AuKZ0EGj97m+MI9uOHd1ZOtc5Tk6aJ8CfkewBiJcF3R2lFykq35LZqLidwqG9Ztp UmZiGXfQO1Q85P9jLv2qDDmHvzRahCoIfbUOWUM6z4ttx7qBvWTZbI2SaxlONderqzpF BbwaeUTQ+vvoiCW42DipL59+CfmbLGhg7g5XokScIRh+zwZldRJV8Xx+IIG8Dz5CcLl1 SG0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=dEtFsfngKL6FXubW7lPMq0XE2Dl8+Q0xNxh9HraDtXU=; b=WS1ta04HfDf+1of+2Ji1lT5IpbkMunx6L5+dTlovfk/eDpiRRpH37geW0roNEG92au kIJ3yCv1NRIqIx1rklYfwoowy8KLkrju21fOAe6Ts1RLnZ0vJsTEu0Vre6GgQvEzxFWc kuxDNxCQZLzfhRTKA/OOindYUYqrfD7uQOVcdaai88bsLCxP09DajJSswa2zzJ6OJA1k zs6B1Fgd3iD8uKXj2GJ1cojleqW9X4aqb9r4VawpDhWF/3h8LzIiwXZwxvhUfl506T3o lPLv8mDjrMoajwNrabrbAeGrqHqM1qZjQVAalmDIVgo87muQoySL3eehQWR7vsWHa5Ee ERJw== X-Gm-Message-State: AN3rC/5aFK4j83Gv+ktdmrQjqgzJrPV7MSusLx4Y/Z2Cs34kfspUvt74 LlyrmQSpS7vd5+KhtsI= X-Received: by 10.223.136.235 with SMTP id g40mr6763027wrg.107.1493368087438; Fri, 28 Apr 2017 01:28:07 -0700 (PDT) Received: from [192.168.2.5] (2-230-140-245.ip202.fastwebnet.it. [2.230.140.245]) by smtp.gmail.com with ESMTPSA id 25sm5118198wrz.8.2017.04.28.01.28.05 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 01:28:06 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_8569BE65-2A9C-413E-8F0A-0C4212B4ECA7" Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. From: Pietro Pugni In-Reply-To: <59024CC9.6050109@personal.formauri.es> Date: Fri, 28 Apr 2017 10:28:05 +0200 Cc: pgsql-bugs@postgresql.org Message-Id: References: <20170426182322.24371.95224@wrigleys.postgresql.org> <5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com> <59024CC9.6050109@personal.formauri.es> To: Pedro Gimeno X-Mailer: Apple Mail (2.3124) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --Apple-Mail=_8569BE65-2A9C-413E-8F0A-0C4212B4ECA7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Il giorno 27 apr 2017, alle ore 21:55, Pedro Gimeno = ha scritto: >=20 > I would like to better understand your expectations regarding your = proposed fix. >=20 > 1. What do you propose that this specific query should return? >=20 > SELECT '1912-02-28'::date + interval '10 years=E2=80=99; 1922-02-28=20 (same result returned by Postgres) > 2. What do you propose that this specific query should return? >=20 > SELECT (whatever your answer to question 1 is)::date - interval '10 = years=E2=80=99; 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? >=20 > SELECT '1912-02-29'::date + interval '10 years=E2=80=99; 1922-02-28 (same result returned by Postgres) > 4. What do you propose that this specific query should return? >=20 > SELECT (whatever your answer to question 3 is)::date - interval '10 = years=E2=80=99; 1912-02-29 (different from result returned at point 2.) > 5. What do you propose that this specific query should return? >=20 > SELECT '1912-03-01'::date + interval '10 years=E2=80=99; 1922-03-01 (same result returned by Postgres) > 6. What do you propose that this specific query should return? >=20 > SELECT (whatever your answer to question 5 is)::date - interval '10 = years=E2=80=99; 1912-03-01 (same result returned by Postgres) I=E2=80=99m aware that 2. and 4. can=E2=80=99t 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 --Apple-Mail=_8569BE65-2A9C-413E-8F0A-0C4212B4ECA7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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=E2=80=99;

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=E2=80=99;

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=E2=80=99;

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=E2=80=99;

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=E2=80=99;

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=E2=80=99;

1912-03-01
(same result = returned by Postgres)



I=E2=80=99m aware that 2. and 4. can=E2=80=99t 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


= --Apple-Mail=_8569BE65-2A9C-413E-8F0A-0C4212B4ECA7--