From 1b52359d90d4830dd687d473089a4bfdecba9684 Mon Sep 17 00:00:00 2001 From: Bruce Momjian <bruce@momjian.us> Date: Tue, 20 Feb 2007 14:34:25 +0000 Subject: [PATCH] Update array slice documentation to be clearer. --- doc/src/sgml/array.sgml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml index 3fe542446b8..246ca382812 100644 --- a/doc/src/sgml/array.sgml +++ b/doc/src/sgml/array.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.56 2007/02/01 00:28:16 momjian Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.57 2007/02/20 14:34:25 momjian Exp $ --> <sect1 id="arrays"> <title>Arrays</title> @@ -243,18 +243,14 @@ SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill'; (1 row) </programlisting> - We could also have written: + If any dimmension is written as a slice, i.e contains a colon, then all + dimmensions are treated as slices. If a dimmension is missing, it is + assumed to be <literal>[1:1]</>. If a dimmension has only a single + number (no colon), that dimmension is treated as being from <literal>1</> + to the number specified. For example, <literal>[2]</> is treated as + <literal>[1:2], as in this example: <programlisting> -SELECT schedule[1:2][1] FROM sal_emp WHERE name = 'Bill'; -</programlisting> - - with the same result. An array subscripting operation is always taken to - represent an array slice if any of the subscripts are written in the form - <literal><replaceable>lower</replaceable>:<replaceable>upper</replaceable></literal>. - A lower bound of 1 is assumed for any subscript where only one value - is specified, as in this example: -<programlisting> SELECT schedule[1:2][2] FROM sal_emp WHERE name = 'Bill'; schedule -- GitLab