pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Ariadne Conill <ariadne@dereferenced.org>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Christoph Moench-Tegeder <cmt@burggraben.net>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: feld@freebsd.org
Subject: Re: jsonb_set() strictness considered harmful to data
Date: Sat, 19 Oct 2019 11:21:26 -0400
Message-ID: <20191019152125.GN6962@tamriel.snowman.net> (raw)
In-Reply-To: <CA+q6zcVcWGCoKhhuJqmMRFNqdaO7PdbQJWSj24RddtE3tdHdJw@mail.gmail.com>
References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com>
	<20191018215018.GB56427@elch.exwg.net>
	<CAKFQuwZ2w5D1yJ9vaexiR8kbqOyxbzKwo2hsbi74ruVfFiNe-g@mail.gmail.com>
	<CAAOiGNyc=g3CvazQ3degiUpzrLiF2P-JyE++BMj5Mxe6K+XARQ@mail.gmail.com>
	<ec60858c-f01c-8103-a039-415f2ef87d04@aklaver.com>
	<CAAOiGNzvaExLy_u-D0-8Xj_wO2Od6cexrReZcFugYvAMNXATnA@mail.gmail.com>
	<20191018235159.GG6962@tamriel.snowman.net>
	<CAAOiGNzsi75ycyYH-V2KtN5gcy+RT8C5dxvEEbUQGvOyZJ-2LA@mail.gmail.com>
	<20191019110831.7y7d2yys5xlujqw6@development>
	<CA+q6zcVcWGCoKhhuJqmMRFNqdaO7PdbQJWSj24RddtE3tdHdJw@mail.gmail.com>

Greetings,

* Dmitry Dolgov (9erthalion6@gmail.com) wrote:
> If we want to change it, the question is where to stop? Essentially we have:
> 
>     update table set data = some_func(data, some_args_with_null);
> 
> where some_func happened to be jsonb_set, but could be any strict function.

I don't think it makes any sense to try and extrapolate this out to
other strict functions.  Functions should be strict when it makes sense
for them to be- in this case, it sounds like it doesn't really make
sense for jsonb_set to be strict, and that's where we stop it.

> I wonder if in this case it makes sense to think about an alternative? For
> example, there is generic type subscripting patch, that allows to update a
> jsonb in the following way:
> 
>     update table set jsonb_data[key] = 'value';
> 
> It doesn't look like a function, so it's not a big deal if it will handle NULL
> values differently. And at the same time one can argue, that people, who are
> not aware about this caveat with jsonb_set and NULL values, will most likely
> use it due to a bit simpler syntax (more similar to some popular programming
> languages).

This seems like an entirely independent thing ...

Thanks,

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (83+ messages)  latest in thread

Message-ID: <20191019152125.GN6962@tamriel.snowman.net>
Permalink:  ../20191019152125.GN6962@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20191019152125.GN6962@tamriel.snowman.net

 · 

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: sfrost@snowman.net, 9erthalion6@gmail.com, tomas.vondra@2ndquadrant.com, ariadne@dereferenced.org, adrian.klaver@aklaver.com, david.g.johnston@gmail.com, cmt@burggraben.net, feld@freebsd.org
  Subject: Re: jsonb_set() strictness considered harmful to data
  In-Reply-To: <20191019152125.GN6962@tamriel.snowman.net>
  References: <CAAOiGNwUsgM-UBqsJH_mriCFr-JCPxD+pQoXNvyOEQPc+YHQRQ@mail.gmail.com> <20191018215018.GB56427@elch.exwg.net> <CAKFQuwZ2w5D1yJ9vaexiR8kbqOyxbzKwo2hsbi74ruVfFiNe-g@mail.gmail.com> <CAAOiGNyc=g3CvazQ3degiUpzrLiF2P-JyE++BMj5Mxe6K+XARQ@mail.gmail.com> <ec60858c-f01c-8103-a039-415f2ef87d04@aklaver.com> <CAAOiGNzvaExLy_u-D0-8Xj_wO2Od6cexrReZcFugYvAMNXATnA@mail.gmail.com> <20191018235159.GG6962@tamriel.snowman.net> <CAAOiGNzsi75ycyYH-V2KtN5gcy+RT8C5dxvEEbUQGvOyZJ-2LA@mail.gmail.com> <20191019110831.7y7d2yys5xlujqw6@development> <CA+q6zcVcWGCoKhhuJqmMRFNqdaO7PdbQJWSj24RddtE3tdHdJw@mail.gmail.com> <20191019152125.GN6962@tamriel.snowman.net>

* 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