Re: time values past 24:00:00 (or rather 23:59:60)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: time values past 24:00:00 (or rather 23:59:60)
Date: 2020-05-21 05:53:01
Message-ID: 6194.1590040381@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Christoph Berg <myon(at)debian(dot)org> writes:
> This is not ok:

> # select '23:59:60.999'::time;
> time
> --------------
> 24:00:00.999

Yeah. Here's a draft patch for that (sans any regression tests as yet).
I found several places with largely the same logic, so I tried to
centralize the tests; although it turns out we need a minimum of
two versions, because some places deal with fractional seconds
differently.

The places using float seconds had their own bugs: one forgot to worry
about NaN, and neither was being careful about imprecise input.

It's slightly annoying to have the check functions duplicate the
calculation that some level of caller is going to do, but avoiding that
would take more refactoring than I think is warranted. In practice a
few extra multiplications aren't likely to be noticeable here.

regards, tom lane

Attachment Content-Type Size
handle-maximum-time-of-day-better.patch text/x-diff 6.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message wenjing zeng 2020-05-21 07:28:28 Re: [bug] Table not have typarray when created by single user mode
Previous Message Michael Paquier 2020-05-21 05:47:03 Re: BUG #16343: Build problem: Install.pm "Could not find debug or release binaries"