Skip to content

Commit 1b52359

Browse files
committed
Update array slice documentation to be clearer.
1 parent 265124e commit 1b52359

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

doc/src/sgml/array.sgml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.56 2007/02/01 00:28:16 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.57 2007/02/20 14:34:25 momjian Exp $ -->
22

33
<sect1 id="arrays">
44
<title>Arrays</title>
@@ -243,18 +243,14 @@ SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
243243
(1 row)
244244
</programlisting>
245245

246-
We could also have written:
246+
If any dimmension is written as a slice, i.e contains a colon, then all
247+
dimmensions are treated as slices. If a dimmension is missing, it is
248+
assumed to be <literal>[1:1]</>. If a dimmension has only a single
249+
number (no colon), that dimmension is treated as being from <literal>1</>
250+
to the number specified. For example, <literal>[2]</> is treated as
251+
<literal>[1:2], as in this example:
247252

248253
<programlisting>
249-
SELECT schedule[1:2][1] FROM sal_emp WHERE name = 'Bill';
250-
</programlisting>
251-
252-
with the same result. An array subscripting operation is always taken to
253-
represent an array slice if any of the subscripts are written in the form
254-
<literal><replaceable>lower</replaceable>:<replaceable>upper</replaceable></literal>.
255-
A lower bound of 1 is assumed for any subscript where only one value
256-
is specified, as in this example:
257-
<programlisting>
258254
SELECT schedule[1:2][2] FROM sal_emp WHERE name = 'Bill';
259255

260256
schedule

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy