pgsql: Filling array gaps during jsonb subscripting

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Filling array gaps during jsonb subscripting
Date: 2021-01-31 20:54:27
Message-ID: E1l6Jjn-0000kq-7W@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Filling array gaps during jsonb subscripting

This commit introduces two new flags for jsonb assignment:

* JB_PATH_FILL_GAPS: Appending array elements on the specified position, gaps
are filled with nulls (similar to the JavaScript behavior). This mode also
instructs to create the whole path in a jsonb object if some part of the
path (more than just the last element) is not present.

* JB_PATH_CONSISTENT_POSITION: Assigning keeps array positions consistent by
preventing prepending of elements.

Both flags are used only in jsonb subscripting assignment.

Initially proposed by Nikita Glukhov based on polymorphic subscripting
patch, but transformed into an independent change.

Discussion: https://postgr.es/m/CA%2Bq6zcV8qvGcDXurwwgUbwACV86Th7G80pnubg42e-p9gsSf%3Dg%40mail.gmail.com
Discussion: https://postgr.es/m/CA%2Bq6zcX3mdxGCgdThzuySwH-ApyHHM-G4oB1R0fn0j2hZqqkLQ%40mail.gmail.com
Discussion: https://postgr.es/m/CA%2Bq6zcVDuGBv%3DM0FqBYX8DPebS3F_0KQ6OVFobGJPM507_SZ_w%40mail.gmail.com
Discussion: https://postgr.es/m/CA%2Bq6zcVovR%2BXY4mfk-7oNk-rF91gH0PebnNfuUjuuDsyHjOcVA%40mail.gmail.com
Author: Dmitry Dolgov
Reviewed-by: Tom Lane, Arthur Zakirov, Pavel Stehule, Dian M Fay
Reviewed-by: Andrew Dunstan, Chapman Flack, Merlin Moncure, Peter Geoghegan
Reviewed-by: Alvaro Herrera, Jim Nasby, Josh Berkus, Victor Wagner
Reviewed-by: Aleksander Alekseev, Robert Haas, Oleg Bartunov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/81fcc72e66222357f9bccce3eeda62eb2cb29849

Modified Files
--------------
doc/src/sgml/json.sgml | 24 ++++
src/backend/utils/adt/jsonfuncs.c | 227 +++++++++++++++++++++++++++++++++---
src/test/regress/expected/jsonb.out | 135 +++++++++++++++++++++
src/test/regress/sql/jsonb.sql | 81 +++++++++++++
4 files changed, 452 insertions(+), 15 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2021-02-01 06:55:52 Re: pgsql: Implementation of subscripting for jsonb
Previous Message Peter Geoghegan 2021-01-31 18:11:27 pgsql: Remove unused _bt_delitems_delete() argument.