Re: pgsql: Implement jsonpath .datetime() method

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
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-09-30 19:55:54
Message-ID: CA+Tgmoad=8vPjr1krdiE5qbaRoJPCaBkq8jQm+o4dhUYZHC7Nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Sun, Sep 29, 2019 at 10:30 AM Alexander Korotkov
<a(dot)korotkov(at)postgrespro(dot)ru> wrote:
> So, jsonpath behaves like 1000000 is not greater than 2020. This
> looks like plain false. And user can't expect that unless she is
> familiar with our particular issues. Now I got opinion that such
> errors shouldn't be suppressed. We can't suppress *every* error. If
> trying to do this, we can come to an idea to suppress OOM error and
> return garbage then, which is obviously ridiculous. Opinions?

I don't know enough about jsonpath to have a view on specifically
which errors ought to be suppressed, but I agree that it's probably
not all of them. In fact, I'd go so far as to say that thinking about
it in terms of error suppression is probably not the right approach in
the first place. Rather, you want to ask what behavior you're trying
to create.

For example, if I'm trying to write a function that takes a string as
input and returns JSON, where the result is formatted as a number if
possible or a string otherwise, I might want access at the C level to
the guts of numeric_in, with all parsing errors returned rather than
thrown. But it would be silly to suppress an out-of-memory condition,
because that doesn't help the caller. The caller wants to know whether
the thing can be parsed as a number or not, and that has nothing to do
with whether we're out of memory, so an out-of-memory error should
still be thrown.

In this case here, it seems to me that you should similarly start by
defining the behavior you're trying to create. Unless that's clearly
defined, deciding which errors to suppress may be difficult.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-09-30 20:07:54 pgsql: Stamp 12.0.
Previous Message Andrew Dunstan 2019-09-30 19:51:47 pgsql: Suppress another CR in program output

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-09-30 20:25:36 Re: Possible bug: SQL function parameter in window frame definition
Previous Message Peter Geoghegan 2019-09-30 19:54:28 Re: Connections hang indefinitely while taking a gin index's LWLock buffer_content lock(PG10.7)