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 1pWfco-0006uM-Qm for pgsql-docs@arkaria.postgresql.org; Mon, 27 Feb 2023 15:41:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWfcn-0007nV-Dk for pgsql-docs@arkaria.postgresql.org; Mon, 27 Feb 2023 15:41:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWfcn-0007nM-6S for pgsql-docs@lists.postgresql.org; Mon, 27 Feb 2023 15:41:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWfci-000648-BJ for pgsql-docs@lists.postgresql.org; Mon, 27 Feb 2023 15:41:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 31RFf6xH357541; Mon, 27 Feb 2023 10:41:06 -0500 From: Tom Lane To: umuttechin@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: Modifying Arrays In-reply-to: <167750600710.23480.2189471451420785675@wrigleys.postgresql.org> References: <167750600710.23480.2189471451420785675@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Mon, 27 Feb 2023 13:53:27 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <357539.1677512466.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 27 Feb 2023 10:41:06 -0500 Message-ID: <357540.1677512466@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > According to the official document of PostgreSQL 15, in the section 8.15= .4. > Modifying Arrays there is a statement like: > The slice syntaxes with omitted lower-bound and/or upper-bound can be us= ed > too, but only when updating an array value that is not NULL or > zero-dimensional (otherwise, there is no existing subscript limit to > substitute). > This statement is not true for the following statements or I am missing > something? Your example doesn't use a slice with omitted bound, so I'm not quite sure what you are trying to show? Using your test data, a slice with omitted bound does fail with Pam's null schedule: =3D> UPDATE sal_emp SET schedule[:2] =3D '{"w", "x", "y", "z"}' WHERE name= =3D 'Pam'; ERROR: array slice subscript must provide both boundaries DETAIL: When assigning to a slice of an empty array value, slice boundari= es must be fully specified. but it works for the other entries: =3D> UPDATE sal_emp SET schedule[:2] =3D '{"w", "x", "y", "z"}' WHERE name= !=3D 'Pam'; UPDATE 3 =3D> table sal_emp; name | pay_by_quarter | schedule = --------+---------------------------+--------------------------------- Pam | {20000,25001,25002,25003} | = Bill | {10000,10000,10000,10000} | {{w,x},{y,z}} Carol | {20000,25000,25000,25000} | {{w,x},{y,z}} Carolx | {20000,25001,25002,25003} | {{w,x},{y,z},{meetingy,lunchy}} (4 rows) regards, tom lane