Re: pgsql: Additional functions and operators for jsonb

From: Petr Jelinek <petr(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-committers(at)postgresql(dot)org" <pgsql-committers(at)postgresql(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Subject: Re: pgsql: Additional functions and operators for jsonb
Date: 2015-05-13 16:28:57
Message-ID: 55537BC9.1080805@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 13/05/15 16:34, Andrew Dunstan wrote:
>
> On 05/12/2015 04:11 PM, Pavel Stehule wrote:
>> Hi
>>
>> I did some tests, and I am not sure if this is not bug:
>>
>> postgres=# select '{"x":20}'::jsonb - 'x'::text;
>> ERROR: unknown type of jsonb container --->>> it should be empty
>> jsonb, not error
>> Time: 0.971 ms
>> postgres=# select '{"x":20, "y":30}'::jsonb - 'x'::text;
>> ┌───────────┐
>> │ ?column? │
>> ╞═══════════╡
>> │ {"y": 30} │
>> └───────────┘
>> (1 row)
>>
>>
>>
>
>
>
> Some of this logic needs tightening. The attached patch should do that.
> Among other things, it errors out if we attempt to delete or replace on
> a scalar, just returns the input argument if there are no changes
> instead of cloning it, checks via an Assert that the constructed
> JsonbValue is not null, and otherwise returns it unconditionally. The
> result is actually simpler code, I think. Before I apply it I'd like to
> have comments from Dmitry and Petr, just to make sure I haven't
> inadvertently slipped my moorings.
>

I think it's ok like this, except that the "cannot get delete from
scalar" error message should probably be "cannot delete from scalar" in
both places.

--
Petr Jelinek http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Dmitry Dolgov 2015-05-13 16:30:38 Re: pgsql: Additional functions and operators for jsonb
Previous Message Robert Haas 2015-05-13 15:02:06 pgsql: Remove useless assertion.