Re: jsonb concatenate operator's semantics seem questionable

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Ryan Pedela <rpedela(at)datalanche(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Ilya Ashchepkov <koctep(at)gmail(dot)com>
Subject: Re: jsonb concatenate operator's semantics seem questionable
Date: 2015-05-21 21:25:00
Message-ID: 555E4D2C.1040600@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 05/21/2015 10:15 AM, Robert Haas wrote:
> On Wed, May 20, 2015 at 3:42 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> On 2015-05-20 15:37:15 -0400, Tom Lane wrote:
>>> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>>>> That does cover all bases, and users would be able to create the
>>>> operator which suits their particular use case easily. It's also fairly
>>>> similar to how jsquery works, although the syntax is completely different.
>>>> But ... it's after feature freeze. So, thoughts?
>>> I think this could be seen as a correction/bug fix for a pre-freeze
>>> feature. We should not be too resistant to filing down rough edges
>>> on new features, even if that involves a spec change.
>> +1
> +1, emphatically.
>

I appreciate your enthusiasm :-)

Here is a patch that renames jsonb_replace to jsonb_set with a boolean
create_missing flag that defaults to false (should we default it to
true?). With the flag set it's more or less upsert for jsonb. Without,
it's just update.

While the patch is sizable, it's mostly a) docs, b) regression changes,
and c) code changes from changing jsonb_replace to jsonb_set (and
replacePath to setPath in jsonfuncs.c). The actual significant code
changes are still quite small, around 200 lines.

I added a note in the docs to make the semantics of jsonb || jsonb much
more explicit.

This change really makes this set of jsonb features quite a bit more
compelling. I'm glad I thought of it - wish I had done so earlier. So
notwithstanding the controversy upthread, I think this is a good result.

cheers

andrew

Attachment Content-Type Size
jsonb_set.patch text/x-patch 33.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-05-21 21:53:51 Re: Float/Double cast to int
Previous Message Tom Lane 2015-05-21 21:24:00 Re: GiST KNN Crasher