Re: pgsql: Implement jsonpath .datetime() method

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>, pgsql-committers <pgsql-committers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <akorotkov(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgsql: Implement jsonpath .datetime() method
Date: 2019-10-13 01:52:21
Message-ID: CAPpHfdvRPRh_mTGar5WmDeRZ=U5dOXHdxspYYD=76m3knNGjXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Oct 3, 2019 at 4:48 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Oct 1, 2019 at 1:41 PM Alexander Korotkov
> <a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> > So, basically standard requires us to suppress any error happening in
> > filter expression.
>
> Sounds like the standard is dumb, then. :-)
>
> > But as I wrote before suppression of errors in
> > datetime comparison may lead to surprising results. That happens in
> > rare corner cases, but still. This makes uneasy choice between
> > consistent behavior and standard behavior.
>
> Yeah.

Proposed patch eliminates this dilemma in particular case. It
provides correct cross-type comparison of datetime values even if one
of values overflows during cast. In order to do this, I made cast
functions to report whether lower or upper boundary is overflowed. We
know that overflowed value is lower (or upper) than any valid value
except infinity.

This patch also changes the way timestamp to timestamptz cast works.
Previously it did timestamp2tm() then tm2timestamp(). Instead, after
timestamp2tm() it calculates timezone offset and applies it to
original timestamp value. I hope this is correct. If so, besides
making overflow handling easier, this refactoring saves some CPU
cycles.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
0002-Refactor-jsonpath-s-compareDatetime-2.patch application/octet-stream 27.4 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-10-13 02:24:27 Re: pgsql: Implement jsonpath .datetime() method
Previous Message Peter Eisentraut 2019-10-12 19:42:36 pgsql: Fix use of term "verifier"

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-10-13 02:24:27 Re: pgsql: Implement jsonpath .datetime() method
Previous Message Tomas Vondra 2019-10-13 01:26:10 CREATE TEXT SEARCH DICTIONARY segfaulting on 9.6+