From: | Zhihong Yu <zyu(at)yugabyte(dot)com> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, Bryn Llewellyn <bryn(at)yugabyte(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, John W Higgins <wishdev(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: Have I found an interval arithmetic bug? |
Date: | 2021-04-12 02:33:34 |
Message-ID: | CALNJ-vQkNfeM--i_L9XSpXsP_sj=UYFnAtF+u2ZhGUSe0PW6Cw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Sun, Apr 11, 2021 at 4:33 PM Zhihong Yu <zyu(at)yugabyte(dot)com> wrote:
>
>
> On Sun, Apr 11, 2021 at 12:57 PM Zhihong Yu <zyu(at)yugabyte(dot)com> wrote:
>
>>
>>
>> On Thu, Apr 8, 2021 at 10:24 AM Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>>
>>> On Mon, Apr 5, 2021 at 02:01:58PM -0400, Bruce Momjian wrote:
>>> > On Mon, Apr 5, 2021 at 11:33:10AM -0500, Justin Pryzby wrote:
>>> > Well, bug or not, we are not going to change back branches for this,
>>> and
>>> > if you want a larger discussion, it will have to wait for PG 15.
>>> >
>>> > > >
>>> https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT
>>> > > > « …field values can have fractional parts; for example '1.5 week'
>>> or '01:02:03.45'. Such input is converted to the appropriate number of
>>> months, days, and seconds for storage. When this would result in a
>>> fractional number of months or days, the fraction is added to the
>>> lower-order fields using the conversion factors 1 month = 30 days and 1 day
>>> = 24 hours. For example, '1.5 month' becomes 1 month and 15 days. Only
>>> seconds will ever be shown as fractional on output. »
>>> >
>>> > I see that. What is not clear here is how far we flow down. I was
>>> > looking at adding documentation or regression tests for that, but was
>>> > unsure. I adjusted the docs slightly in the attached patch.
>>>
>>> Here is an updated patch, which will be for PG 15. It updates the
>>> documentation to state:
>>>
>>> The fractional parts are used to compute appropriate values for
>>> the next
>>> lower-order internal fields (months, days, seconds).
>>>
>>> It removes the flow from fractional months/weeks to
>>> hours-minutes-seconds, and adds missing rounding for fractional
>>> computations.
>>>
>>> --
>>> 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.
>>>
>>>
>> +1 to this patch.
>>
>
> Bryn reminded me, off list, about the flowing down from fractional
> day after the patch.
>
> Before Bruce confirms the removal of the flowing down from fractional day,
> I withhold my previous +1.
>
> Bryn would respond with more details.
>
> Cheers
>
Among previous examples given by Bryn, the following produces correct
result based on Bruce's patch.
# select interval '-1.7 years 29.4 months';
interval
----------------
9 mons 12 days
(1 row)
Cheers
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2021-04-12 03:21:15 | Re: The Amazon CloudFront distribution is configured to block access from your country. |
Previous Message | Igor Korot | 2021-04-12 00:08:33 | Re: How can I insert the image as a blob in the table |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2021-04-12 03:10:11 | Re: psql - add SHOW_ALL_RESULTS option |
Previous Message | 蔡梦娟 (玊于) | 2021-04-12 02:01:43 | 回复:Bug on update timing of walrcv->flushedUpto variable |