From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, John W Higgins <wishdev(at)gmail(dot)com>, pgsql-hackers list <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Have I found an interval arithmetic bug? |
Date: | 2021-07-30 19:55:05 |
Message-ID: | 20210730195505.GE9600@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Fri, Jul 30, 2021 at 03:47:53PM -0400, Robert Haas wrote:
> On Fri, Jul 30, 2021 at 3:20 PM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Uh, what do you suggest then? You wanted the years/months fixed, and
> > rounding at spill stop time makes sense, and fixes the problem.
>
> Hmm, maybe I misunderstood. Are you saying that you think the patch
> will fix cases like interval '-1.7 years 29.4 months' and interval
> '29.4 months -1.7 years' to produce the same answer without changing
> any other cases? I had the impression that you were proposing a bigger
Yes, tests from the oringal email:
SELECT interval '-1.7 years 29.4 months';
interval
----------------
9 mons 12 days
(1 row)
SELECT interval '29.4 months -1.7 years';
interval
----------------
9 mons 12 days
(1 row)
SELECT interval '-1.7 years' + interval '29.4 months';
?column?
----------------
9 mons 12 days
(1 row)
SELECT interval '29.4 months' + interval '-1.7 years';
?column?
----------------
9 mons 12 days
> change to the rules for converting fractional units to units of lower
> type, particularly because Tom called it an "API change".
The API change is to _round_ units greater than months to integeral
month values; we currently truncate. Changing the spill behavior has
been rejected.
> For some reason I can't apply the patch locally.
>
> [rhaas pgsql]$ patch -p1 < ~/Downloads/interval.diff
> (Stripping trailing CRs from patch.)
> patching file doc/src/sgml/datatype.sgml
> (Stripping trailing CRs from patch.)
> patching file src/backend/utils/adt/datetime.c
> patch: **** malformed patch at line 90: @@ -3601,7 +3597,7 @@
> DecodeISO8601Interval(char *str,
Uh, here is the patch again, in case that helps.
--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com
If only the physical world exists, free will is an illusion.
Attachment | Content-Type | Size |
---|---|---|
interval.diff | text/x-diff | 6.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2021-07-30 19:56:49 | Re: Have I found an interval arithmetic bug? |
Previous Message | Tom Lane | 2021-07-30 19:54:42 | Re: Have I found an interval arithmetic bug? |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2021-07-30 19:56:49 | Re: Have I found an interval arithmetic bug? |
Previous Message | Tom Lane | 2021-07-30 19:54:42 | Re: Have I found an interval arithmetic bug? |