Re: jsonb_set() strictness considered harmful to data - Mailing list pgsql-general

From David G. Johnston
Subject Re: jsonb_set() strictness considered harmful to data
Date
Msg-id CAKFQuwYp1b4jU294Q1tRbib3Ei9WRYBiKvGQ+ySnspSJkgdZhw@mail.gmail.com
Whole thread Raw
In response to Re: jsonb_set() strictness considered harmful to data  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
List pgsql-general
On Sun, Oct 20, 2019 at 3:51 PM Andrew Dunstan <andrew.dunstan@2ndquadrant.com> wrote:
I'm not arguing against the idea of improving the situation. But I am
arguing against a minimal fix that will not provide much of value to a
careful app developer. i.e. I want to do more to support app devs.
Ideally they would not need to use wrapper functions. There will be
plenty of situations where it is mighty inconvenient to catch an
exception thrown by jsonb_set(). And catching exceptions can be
expensive. You want to avoid that if possible in your
performance-critical plpgsql code.

As there is pretty much nothing that can be done at runtime if this exception is raised actually "catching" it anywhere deeper than near the top of the application code is largely pointless.  Its more like a NullPointerException in Java - if the application raises it there should be a last line of defense error handler that basically says "you developer made a mistake somewhere and needs to fix it - tell them this happened".

Performance critical subsections (and pretty much the whole) of the application can just raise the error to the caller using normal mechanisms for "SQLException" propogation.

David J.

pgsql-general by date:

Previous
From: Horacio Miranda
Date:
Subject: Re: Postgres Point in time Recovery (PITR),
Next
From: Steven Pousty
Date:
Subject: Re: jsonb_set() strictness considered harmful to data