Re: truncating timestamps on arbitrary intervals - Mailing list pgsql-hackers

From John Naylor
Subject Re: truncating timestamps on arbitrary intervals
Date
Msg-id CAFBsxsGW=pHSitw5gY=CP1ctBAuz8+cFXiZkiB2fZXkuUh_6xQ@mail.gmail.com
Whole thread Raw
In response to Re: truncating timestamps on arbitrary intervals  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Responses Re: truncating timestamps on arbitrary intervals
List pgsql-hackers

On Sat, Apr 10, 2021 at 7:43 AM Peter Eisentraut <peter.eisentraut@enterprisedb.com> wrote:
>
> On 30.03.21 18:06, John Naylor wrote:
> > Currently, when the origin is after the input, the result is the
> > timestamp at the end of the bin, rather than the beginning as expected.
> > The attached puts the result consistently at the beginning of the bin.
>
> In the patch
>
> +   if (origin > timestamp && stride_usecs > 1)
> +       tm_delta -= stride_usecs;
>
> is the condition stride_usecs > 1 really necessary?  My assessment is
> that it's not, in which case it would be better to omit it.

Without the condition, the case of 1 microsecond will fail to be a no-op. This case has no practical use, but it still must work correctly, just as date_trunc('microsecond', input) does.

--
John Naylor
EDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Replication slot stats misgivings
Next
From: Amit Kapila
Date:
Subject: Re: Replication slot stats misgivings