jsonb array-style subscripting - Mailing list pgsql-hackers

From Dmitry Dolgov
Subject jsonb array-style subscripting
Date
Msg-id CA+q6zcV8qvGcDXurwwgUbwACV86Th7G80pnubg42e-p9gsSf=g@mail.gmail.com
Whole thread Raw
Responses Re: jsonb array-style subscripting
Re: jsonb array-style subscripting
Re: jsonb array-style subscripting
Re: jsonb array-style subscripting
List pgsql-hackers
Hi,

Some time ago the array-style subscripting for the jsonb data type was discussed in this mailing list. I think it will be quite convenient to have a such nice syntax to update jsonb objects, so I'm trying to implement this. I created a patch, that allows doing something like this:


=# create TEMP TABLE test_jsonb_subscript (
       id int,
       test_json jsonb
);

=# insert into test_jsonb_subscript values
(1, '{}'),
(2, '{}');

=# update test_jsonb_subscript set test_json['a']['a1']['a2'] = 42;
=# select * from test_jsonb_subscript;
 id |        test_json         
----+--------------------------
  1 | {"a": {"a1": {"a2": 42}}}
  2 | {"a": {"a1": {"a2": 42}}}
(2 rows)

=# select test_json['a']['a1'] from test_jsonb_subscript;
 test_json  
------------
 {"a2": 42}
 {"a2": 42}
(2 rows)


This patch has a status "work in progress" of course. Generally speaking, this implementation extends the `ArrayRef` usage for the jsonb.
And I need some sort of advice about several questions:

* is it interesting for the community?
* is that a good idea to extend the `ArrayRef` for jsonb? If it's appropriate, probably we can rename it to `ArrayJsonbRef` of something.
* what can be improved in the code at the top level (function placement, probably, functionality duplication, etc.)?
* are there any special cases, that I should take care of in this implementation?

Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: More WITH
Next
From: Peter Eisentraut
Date:
Subject: missing documentation for partial WAL files