pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: umuttechin@gmail.com
Cc: pgsql-docs@lists.postgresql.org
Subject: Re: Modifying Arrays
Date: Mon, 27 Feb 2023 10:41:06 -0500
Message-ID: <357540.1677512466@sss.pgh.pa.us> (raw)
In-Reply-To: <167750600710.23480.2189471451420785675@wrigleys.postgresql.org>
References: <167750600710.23480.2189471451420785675@wrigleys.postgresql.org>

PG Doc comments form <noreply@postgresql.org> 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 used
> 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:

=> UPDATE sal_emp SET schedule[:2] = '{"w", "x", "y", "z"}' WHERE name = 'Pam';
ERROR:  array slice subscript must provide both boundaries
DETAIL:  When assigning to a slice of an empty array value, slice boundaries must be fully specified.

but it works for the other entries:

=> UPDATE sal_emp SET schedule[:2] = '{"w", "x", "y", "z"}' WHERE name != 'Pam';
UPDATE 3
=> 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





view thread (3+ messages)  latest in thread

Message-ID: <357540.1677512466@sss.pgh.pa.us>
Permalink:  ../357540.1677512466@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/357540.1677512466@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, umuttechin@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: Modifying Arrays
  In-Reply-To: <357540.1677512466@sss.pgh.pa.us>

* 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