Re: [HACKERS] [PATCH] Generic type subscripting

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>, Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Oleg Bartunov <obartunov(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, David Steele <david(at)pgmasters(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
Date: 2018-10-10 12:25:33
Message-ID: CAFj8pRBJ_RSV9wiyecE=24z-g=hpsLp56Niip+wYnwVNa3a8sw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

ne 30. 9. 2018 v 8:23 odesílatel Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
napsal:

>
>
> ne 30. 9. 2018 v 0:21 odesílatel Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
> napsal:
>
>> > On Fri, 20 Jul 2018 at 23:32, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
>> wrote:
>> >
>> > > On Thu, 26 Apr 2018 at 16:44, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
>> wrote:
>> > >
>> > > > On 22 March 2018 at 23:25, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
>> wrote:
>> > > >
>> > > > Here is the updated version of patch, rebased after recent
>> conflicts and with
>> > > > suggested documentation improvements.
>> > >
>> > > Another rebased version of the patch.
>> >
>> > I've noticed, that I never updated llvmjit code for the arrayref
>> expressions,
>> > and it's important to do so, since the patch introduces another layer of
>> > flexibility. Hence here is the new version.
>>
>> Here is another rebased version, and a bit of history: the first
>> prototypes of
>> this patch were sent more than 3 years ago. Of course the patch evolved
>> significantly over this period, and I take it as a good sign that it
>> wasn't
>> rejected and keeps moving through the commitfests. At the same time the
>> lack of
>> attention makes things a bit frustrating. I have an impression that it's
>> sort
>> of regular situation and wonder if there are any ideas (besides the well
>> known
>> advice of putting some efforts into review patches from other people,
>> since I'm
>> already doing my best and enjoying this) how to make progress in such
>> cases?
>>
>
> This feature looks nice, and it can be great when some values of some not
> atomic type should be updated.
>

I am playing with this feature little bit

I have one idea - can be possible to use integer subscript for record
fields? It can helps with iteration over record.

example:

select ('{"a":{"a":[10,20]}}'::jsonb)[0];--> NULL, but can be more
practical if it returns same like select
('{"a":{"a":[10,"20"]}}'::jsonb)['a'];

I don't like quite ignoring bad subsript in update

postgres=# insert into test(v) values( '[]');
INSERT 0 1
postgres=# update test set v[1000] = 'a';
UPDATE 1
postgres=# update test set v[1000] = 'a';
UPDATE 1
postgres=# update test set v[1000] = 'a';
UPDATE 1
postgres=# select * from test;
┌────┬─────────────────┐
│ id │ v │
╞════╪═════════════════╡
│ │ ["a", "a", "a"] │
└────┴─────────────────┘
(1 row)

It should to raise exception in this case. Current behave allows append
simply, but can be source of errors. For this case we can introduce some
special symbol - some like -0 :)

It is maybe strange, but I prefer less magic syntax like

update test set v['a']['a'] = v['a']['a'] || '1000';

more readable than

update test set v['a']['a'][1000000] = 1000;

My first impression is very good - update jsonb, xml documents can be very
friendly.

Regards

Pavel

>
> Regards
>
> Pavel
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Haribabu Kommi 2018-10-10 12:27:21 Re: View to get all the extension control file details
Previous Message Daniel Gustafsson 2018-10-10 12:20:53 Re: [HACKERS] Optional message to user when terminating/cancelling backend