pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Mark Felder <feld@freebsd.org>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: jsonb_set() strictness considered harmful to data
Date: Sat, 19 Oct 2019 21:27:23 +0200
Message-ID: <20191019192723.luarxhq57qkzuncw@development> (raw)
In-Reply-To: <a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com>
References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com>
	<d7a4e2b2-e009-4d79-aa5b-82bcf96aad2f@www.fastmail.com>
	<7dc242bd-b78f-2e0d-0c38-7b4b299f11bf@2ndQuadrant.com>
	<20191019161851.v7dwloiiav5yrpwu@development>
	<CAKFQuwa0epfqMsJ=yz8t+ASmdf5PoFXhXj=9DBpoHa2i_67nJw@mail.gmail.com>
	<a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com>

On Sat, Oct 19, 2019 at 12:47:39PM -0400, Andrew Dunstan wrote:
>
>On 10/19/19 12:32 PM, David G. Johnston wrote:
>> On Sat, Oct 19, 2019 at 9:19 AM Tomas Vondra
>> <tomas.vondra@2ndquadrant.com <mailto:tomas.vondra@2ndquadrant.com>>
>> wrote:
>>
>>     >
>>     >We invented jsonb_set() (credit to Dmitry Dolgov). And we've had it
>>     >since 9.5. That's five releases ago.  So it's a bit late to be
>>     coming to
>>     >us telling us it's not safe (according to your preconceptions of
>>     what it
>>     >should be doing).
>>     >
>>
>>
>> There have been numerous complaints and questions about this behavior
>> in those five years; and none of the responses to those defenses has
>> actually made the current behavior sound beneficial but rather have
>> simply said "this is how it works, deal with it".
>
>
>I haven't seen a patch, which for most possible solutions should be
>fairly simple to code. This is open source. Code speaks louder than
>complaints.
>

IMHO that might be a bit too harsh - I'm not surprised no one sent a
patch when we're repeatedly telling people "you're holding it wrong".
Without a clear consensus what the "correct" behavior is, I wouldn't
send a patch either.

>
>>
>>     >
>>     >We could change it prospectively (i.e. from release 13 on) if we
>>     choose.
>>     >But absent an actual bug (i.e. acting contrary to documented
>>     behaviour)
>>     >we do not normally backpatch such changes, especially when there is a
>>     >simple workaround for the perceived problem. And it's that policy
>>     that
>>     >is in large measure responsible for Postgres' deserved reputation for
>>     >stability.
>>     >
>>
>>     Yeah.
>>
>>
>> Agreed, this is v13 material if enough people come on board to support
>> making a change.
>
>
>
>We have changed such things in the past. But maybe a new function might
>be a better way to go. I haven't given it enough thought yet.
>

I think the #1 thing we should certainly do is explaining the behavior
in the docs.

>
>
>>
>>     >And if we were to change it I'm not at all sure that we should do
>>     it the
>>     >way that's suggested here, which strikes me as no more intuitive than
>>     >the current behaviour. Rather I think we should possibly fill in
>>     a json
>>     >null in the indicated place.
>>     >
>>
>>     Not sure, but that seems rather confusing to me, because it's
>>     mixing SQL
>>     NULL and JSON null, i.e. it's not clear to me why
>>
>> [...]
>>
>>     But I admit it's quite subjective.
>>
>>
>> Providing SQL NULL to this function and asking it to do something with
>> that is indeed subjective - with no obvious reasonable default, and I
>> agree that "return a NULL" while possible consistent is probably the
>> least useful behavior that could have been chosen.  We should never
>> have allowed an SQL NULL to be an acceptable argument in the first
>> place, and can reasonably safely and effectively prevent it going
>> forward.  Then people will have to explicitly code what they want to
>> do if their data and queries present this invalid unknown data to the
>> function.
>>
>>
>
>How exactly do we prevent a NULL being passed as an argument? The only
>thing we could do would be to raise an exception, I think. That seems
>like a fairly ugly thing to do, I'd need a h3eck of a lot of convincing.
>

I don't know, but if we don't know what the "right" behavior with NULL
is, is raising an exception really that ugly?


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services 





view thread (83+ messages)  latest in thread

Message-ID: <20191019192723.luarxhq57qkzuncw@development>
Permalink:  ../20191019192723.luarxhq57qkzuncw@development/
Also on:    postgresql.org/message-id/20191019192723.luarxhq57qkzuncw@development

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, andrew.dunstan@2ndquadrant.com, david.g.johnston@gmail.com, feld@freebsd.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: jsonb_set() strictness considered harmful to data
  In-Reply-To: <20191019192723.luarxhq57qkzuncw@development>
  References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com> <d7a4e2b2-e009-4d79-aa5b-82bcf96aad2f@www.fastmail.com> <7dc242bd-b78f-2e0d-0c38-7b4b299f11bf@2ndQuadrant.com> <20191019161851.v7dwloiiav5yrpwu@development> <CAKFQuwa0epfqMsJ=yz8t+ASmdf5PoFXhXj=9DBpoHa2i_67nJw@mail.gmail.com> <a2c965cc-7d90-ed89-d50f-b2c046d4499e@2ndQuadrant.com> <20191019192723.luarxhq57qkzuncw@development>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox