Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2GSK-00062W-TG for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 16:35:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2GSI-0003N1-4P for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Jan 2021 16:35:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2GSH-0003Mt-R4 for pgsql-hackers@lists.postgresql.org; Wed, 20 Jan 2021 16:35:37 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l2GSC-0002Vw-OH for pgsql-hackers@postgresql.org; Wed, 20 Jan 2021 16:35:37 +0000 Received: by mail-io1-xd2b.google.com with SMTP id q2so46440020iow.13 for ; Wed, 20 Jan 2021 08:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:content-transfer-encoding:to:cc:subject:from:date :message-id:in-reply-to; bh=vNau1vlb7vqowSyfM16kfPIk6mram6aRCczBgXmv3g4=; b=sLG+FP0soJttrjo7J3CmxWJGKgBrsYeL6jFhDybrmgyZFJiQHPXCMvqA9XYaHNQYX8 RfDoByF317/4oiOyoLcktLTE5FCBAYLZFcH/Xitq5NnS7iJBxSgw0+v4A4udRJNhJcoU 2eDUVa3o6KcJZOyHalWX0ULl6ARA0Y8r9uT7uI1CmoOLBkQ6/TFToNLudWPVvCtiwjkq J9XcHYe/841AydclFmVj6pS5XY+8cwCW+zO0Z5nqt6fVciufv144wqavOT9L7PQSPKVv DskPYObxCgHbBYb+YhQ5miJmHGgSTrLgKPH3L35L4W8YzRyELbzfeq8NJJEh02NK92Bc PcKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to:cc :subject:from:date:message-id:in-reply-to; bh=vNau1vlb7vqowSyfM16kfPIk6mram6aRCczBgXmv3g4=; b=su801nwvAtyvHbQ5gFga2kx6r4V45OzH9wRKEP3s8amOLEEYLmRhuZe0N21i0uh6QH nTQgANLo4nCYWt9WxGB/uzEvmdJIHiagXafA3dU1IGmnM6tKjjE3vJ9pGIoK3Cb5VqAr U2qECgiVfntDO2dzgRVnvjWfilNPqsblSX1G/+KeNEphmcHwugnKaJxK0x0BisU2jUIk aXpDDWzQeYk3tCFlZwzqeJPTIZJ15TuxZyMDZ+02Zzdr8hxEIqdYv4F3xKx8d8DNb4Xc Q+ziUAqMQy7gO8ryLGeVsuuT2Jn3j2ggVGUTsXwpBCPRqn0RZVGZVxO4WWjteZCSJGz+ q4yw== X-Gm-Message-State: AOAM533Ihvqmf6Rph8ja5aD/3hUcFECul3a5ktr3SOBz/63UjBJ4wOyS MlbDpwgCsd/Oq+vEbph+QEI= X-Google-Smtp-Source: ABdhPJzHg5RlGIwKwNO8hP3zsCtdTHwtX76mXr2oA2P1mHmG/0x8j07AkgvDkgnsgNRPI8OmJrGCOg== X-Received: by 2002:a5e:c702:: with SMTP id f2mr5210052iop.133.1611160530703; Wed, 20 Jan 2021 08:35:30 -0800 (PST) Received: from localhost ([68.235.43.45]) by smtp.gmail.com with ESMTPSA id m18sm1036743ioy.44.2021.01.20.08.35.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jan 2021 08:35:30 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 To: "Dmitry Dolgov" <9erthalion6@gmail.com> Cc: "Pavel Stehule" , "Tom Lane" , "Andres Freund" , "Alexander Korotkov" , "Justin Pryzby" , "David Steele" , "Nikita Glukhov" , "Alvaro Herrera" , "David Fetter" , "Thomas Munro" , "Oleksandr Shulgin" , "Robert Haas" , "Michael Paquier" , "Oleg Bartunov" , "Peter Eisentraut" , "PostgreSQL Hackers" Subject: Re: [HACKERS] [PATCH] Generic type subscripting From: "Dian M Fay" Date: Wed, 20 Jan 2021 11:34:16 -0500 Message-Id: In-Reply-To: <20210120162231.4oht6mdp6v76xfhs@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 th= e > > added hints. > > Great! I've applied almost all of it, except: > > + A jsonb 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 jsonb 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'] =3D '"newvalue"' * SET arr[0][0][3] =3D '"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 jsonb 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 NULL-padded according to the path until the value can be placed appropriately.