pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David Steele <david@pgmasters.net>
Cc: Nikita Glukhov <n.gluhov@postgrespro.ru>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: David Fetter <david@fetter.org>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Oleg Bartunov <obartunov@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] [PATCH] Generic type subscripting
Date: Fri, 18 Sep 2020 13:02:04 +0200
Message-ID: <20200918110204.77yu4ioqlhhfhcya@localhost> (raw)
In-Reply-To: <CAFj8pRAQS3Z_ViOmMKCHWTu2uzajCuUUWwxq3z2nWpRWE1D3tg@mail.gmail.com>
References: <CAFj8pRBZ_82spPExOa-m+Fed4=yvufvx0kKcga7GQbszJvG-BA@mail.gmail.com>
	<20200805140422.fzwnvq7qr5vsgx3b@localhost>
	<20200909210435.GU18552@telsasoft.com>
	<CAFj8pRA784QJU2Yr-f-frgRdXNuA4b50ug8as=NyzPSiV-K5bA@mail.gmail.com>
	<20200916093703.rkyl66ggdhmw5pc6@localhost>
	<CAFj8pRDWShrKjNs7Q1u=ZDT4jKpXQfVwfy-kA6K_JXtRF8MoYg@mail.gmail.com>
	<20200917105849.vgqhutrooatdxwzq@localhost>
	<CAFj8pRDuJ8n3tf_kaxd4evp3uKa8h3KA97q4GG5qRDxicbGazg@mail.gmail.com>
	<20200917135627.7koag6rnhshgjlai@localhost>
	<CAFj8pRAQS3Z_ViOmMKCHWTu2uzajCuUUWwxq3z2nWpRWE1D3tg@mail.gmail.com>

> On Thu, Sep 17, 2020 at 05:19:19PM +0200, Pavel Stehule wrote:
>
> ok, then I think we can design some workable behaviour
>
> My first rule - there should not be any implicit action that shifts
> positions in the array. It can be explicit, but not implicit. It is true
> for positive indexes, and it should be true for negative indexes too.
>
> then I think so some like this can work
>
> if (idx < 0)
> {
>   if (abs(idx) > length of array)
>     exception("index is of of range");
>   array[length of array - idx] := value;
> }
> else
> {
>    /* known behave for positive index */
> }

In this way (returning an error on a negative indices bigger than the
number of elements) functionality for assigning via subscripting will be
already significantly differ from the original one via jsonb_set. Which
in turn could cause a new wave of something similar to "why assigning an
SQL NULL as a value returns NULL instead of jsonb?". Taking into account
that this is not absolutely new interface, but rather a convenient
shortcut for the existing one it probably makes sense to try to find a
balance between both consistency with regular array and similarity with
already existing jsonb modification functions.

Having said that, my impression is that this balance should be not fully
shifted towards consistensy with the regular array type, as jsonb array
and regular array are fundamentally different in terms of
implementation. If any differences are of concern, they should be
addressed at different level. At the same time I've already sort of gave
up on this patch in the form I wanted to see it anyway, so anything goes
if it helps bring it to the finish point. In case if there would be no
more arguments from other involved sides, I can post the next version
with your suggestion included.





view thread (276+ messages)  latest in thread

Message-ID: <20200918110204.77yu4ioqlhhfhcya@localhost>
Permalink:  ../20200918110204.77yu4ioqlhhfhcya@localhost/
Also on:    postgresql.org/message-id/20200918110204.77yu4ioqlhhfhcya@localhost

 · 

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-hackers@postgresql.org
  Cc: 9erthalion6@gmail.com, pavel.stehule@gmail.com, pryzby@telsasoft.com, tgl@sss.pgh.pa.us, david@pgmasters.net, n.gluhov@postgrespro.ru, alvherre@2ndquadrant.com, david@fetter.org, thomas.munro@gmail.com, thomas.munro@enterprisedb.com, oleksandr.shulgin@zalando.de, robertmhaas@gmail.com, andres@anarazel.de, michael.paquier@gmail.com, obartunov@gmail.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: [HACKERS] [PATCH] Generic type subscripting
  In-Reply-To: <20200918110204.77yu4ioqlhhfhcya@localhost>
  References: <CAFj8pRBZ_82spPExOa-m+Fed4=yvufvx0kKcga7GQbszJvG-BA@mail.gmail.com> <20200805140422.fzwnvq7qr5vsgx3b@localhost> <20200909210435.GU18552@telsasoft.com> <CAFj8pRA784QJU2Yr-f-frgRdXNuA4b50ug8as=NyzPSiV-K5bA@mail.gmail.com> <20200916093703.rkyl66ggdhmw5pc6@localhost> <CAFj8pRDWShrKjNs7Q1u=ZDT4jKpXQfVwfy-kA6K_JXtRF8MoYg@mail.gmail.com> <20200917105849.vgqhutrooatdxwzq@localhost> <CAFj8pRDuJ8n3tf_kaxd4evp3uKa8h3KA97q4GG5qRDxicbGazg@mail.gmail.com> <20200917135627.7koag6rnhshgjlai@localhost> <CAFj8pRAQS3Z_ViOmMKCHWTu2uzajCuUUWwxq3z2nWpRWE1D3tg@mail.gmail.com> <20200918110204.77yu4ioqlhhfhcya@localhost>

* 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