Re: [HACKERS] [PATCH] Generic type subscripting

Dian Fay <dian.m.fay@gmail.com>

From: "Dian M Fay" <dian.m.fay@gmail.com>
To: "Dmitry Dolgov" <9erthalion6@gmail.com>
Cc: "Pavel Stehule" <pavel.stehule@gmail.com>, "Tom Lane" <tgl@sss.pgh.pa.us>, "Andres Freund" <andres@anarazel.de>, "Alexander Korotkov" <aekorotkov@gmail.com>, "Justin Pryzby" <pryzby@telsasoft.com>, "David Steele" <david@pgmasters.net>, "Nikita Glukhov" <n.gluhov@postgrespro.ru>, "Alvaro Herrera" <alvherre@2ndquadrant.com>, "David Fetter" <david@fetter.org>, "Thomas Munro" <thomas.munro@gmail.com>, "Oleksandr Shulgin" <oleksandr.shulgin@zalando.de>, "Robert Haas" <robertmhaas@gmail.com>, "Michael Paquier" <michael.paquier@gmail.com>, "Oleg Bartunov" <obartunov@gmail.com>, "Peter Eisentraut" <peter.eisentraut@2ndquadrant.com>, "PostgreSQL Hackers" <pgsql-hackers@postgresql.org>
Date: 2021-01-20T16:34:16Z
Lists: pgsql-hackers
On Wed Jan 20, 2021 at 11:22 AM EST, Dmitry Dolgov wrote:
> > On Tue Jan 19, 2021 at 1:42 PM EST, Pavel Stehule wrote:
> >
> > I found minor issues.
> >
> > Doc - missing tag
> >
> > and three whitespaces issues
> >
> > see attached patch
>
> Thanks, I need to remember to not skipp doc building for testing process
> even for such small changes. Hope now I didn't forget anything.
>
> > On Wed, Jan 20, 2021 at 09:58:43AM -0500, Dian M Fay wrote:
>
> > Here's a full editing pass on the documentation, with v45 and Pavel's
> > doc-whitespaces-fix.patch applied. I also corrected a typo in one of the
> > added hints.
>
> Great! I've applied almost all of it, except:
>
> + A <type>jsonb</type> value will accept assignments to nonexistent
> subscript
> + paths as long as the nonexistent elements being traversed are all
> arrays.
>
> Maybe I've misunderstood the intention, but there is no requirement
> about arrays for creating such an empty path. I've formulated it as:
>
> + A <type>jsonb</type> value will accept assignments to nonexistent
> subscript
> + paths as long as the last existing path key is an object or an array.

My intention there was to highlight the difference between:

* SET obj['a']['b']['c'] = '"newvalue"'
* SET arr[0][0][3] = '"newvalue"'

obj has to conform to {"a": {"b": {...}}} in order to receive the
assignment of the nested c. If it doesn't, that's the error case we
discussed earlier. But arr can be null, [], and so on, and any missing
structure [[[null, null, null, "newvalue"]]] will be created. Take 2:

A <type>jsonb</type> value will accept assignments to nonexistent
subscript paths as long as object key subscripts can be traversed as
described above. The final subscript is not traversed and, if it
describes a missing object key, will be created. Nested arrays will
always be created and <literal>NULL</literal>-padded according to the
path until the value can be placed appropriately.



Commits

  1. Throw error when assigning jsonb scalar instead of a composite object

  2. Filling array gaps during jsonb subscripting

  3. Implementation of subscripting for jsonb

  4. Allow ALTER TYPE to update an existing type's typsubscript value.

  5. Allow subscripting of hstore values.

  6. Support subscripting of arbitrary types, not only arrays.

  7. jit: Reference function pointer types via llvmjit_types.c.

  8. Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

  9. jit: Correct parameter type for generated expression evaluation functions.

  10. Renaming for new subscripting mechanism

  11. Fix assertion failure for SSL connections.

  12. Teach eval_const_expressions() to handle some more cases.