1- <!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.69 2009/04/27 16:27:35 momjian Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.70 2009/06/17 21:58:48 tgl Exp $ -->
22
33<sect1 id="arrays">
44 <title>Arrays</title>
@@ -60,18 +60,17 @@ CREATE TABLE tictactoe (
6060 </para>
6161
6262 <para>
63- In addition, the current implementation does not enforce the declared
63+ The current implementation does not enforce the declared
6464 number of dimensions either. Arrays of a particular element type are
6565 all considered to be of the same type, regardless of size or number
66- of dimensions. So, declaring the number of dimensions or sizes in
67- <command>CREATE TABLE</command> is simply documentation, it does not
66+ of dimensions. So, declaring the array size or number of dimensions in
67+ <command>CREATE TABLE</command> is simply documentation; it does not
6868 affect run-time behavior.
6969 </para>
7070
7171 <para>
7272 An alternative syntax, which conforms to the SQL standard by using
73- they keyword <literal>ARRAY</>, can
74- be used for one-dimensional arrays;
73+ the keyword <literal>ARRAY</>, can be used for one-dimensional arrays.
7574 <structfield>pay_by_quarter</structfield> could have been defined
7675 as:
7776<programlisting>
@@ -109,7 +108,7 @@ CREATE TABLE tictactoe (
109108 for the type, as recorded in its <literal>pg_type</literal> entry.
110109 Among the standard data types provided in the
111110 <productname>PostgreSQL</productname> distribution, all use a comma
112- (<literal>,</>), except for the type <literal >box</> which uses a semicolon
111+ (<literal>,</>), except for type <type >box</> which uses a semicolon
113112 (<literal>;</>). Each <replaceable>val</replaceable> is
114113 either a constant of the array element type, or a subarray. An example
115114 of an array constant is:
@@ -121,7 +120,7 @@ CREATE TABLE tictactoe (
121120 </para>
122121
123122 <para>
124- To set an element of an array to NULL, write <literal>NULL</>
123+ To set an element of an array constant to NULL, write <literal>NULL</>
125124 for the element value. (Any upper- or lower-case variant of
126125 <literal>NULL</> will do.) If you want an actual string value
127126 <quote>NULL</>, you must put double quotes around it.
@@ -211,7 +210,7 @@ INSERT INTO sal_emp
211210 First, we show how to access a single element of an array.
212211 This query retrieves the names of the employees whose pay changed in
213212 the second quarter:
214-
213+
215214<programlisting>
216215SELECT name FROM sal_emp WHERE pay_by_quarter[1] <> pay_by_quarter[2];
217216
@@ -230,7 +229,7 @@ SELECT name FROM sal_emp WHERE pay_by_quarter[1] <> pay_by_quarter[2];
230229
231230 <para>
232231 This query retrieves the third quarter pay of all employees:
233-
232+
234233<programlisting>
235234SELECT pay_by_quarter[3] FROM sal_emp;
236235
@@ -248,7 +247,7 @@ SELECT pay_by_quarter[3] FROM sal_emp;
248247 <literal><replaceable>lower-bound</replaceable>:<replaceable>upper-bound</replaceable></literal>
249248 for one or more array dimensions. For example, this query retrieves the first
250249 item on Bill's schedule for the first two days of the week:
251-
250+
252251<programlisting>
253252SELECT schedule[1:2][1:1] FROM sal_emp WHERE name = 'Bill';
254253
@@ -417,14 +416,14 @@ SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
417416 </para>
418417
419418 <para>
420- The concatenation operator allows a single element to be pushed to the
419+ The concatenation operator allows a single element to be pushed onto the
421420 beginning or end of a one-dimensional array. It also accepts two
422421 <replaceable>N</>-dimensional arrays, or an <replaceable>N</>-dimensional
423422 and an <replaceable>N+1</>-dimensional array.
424423 </para>
425424
426425 <para>
427- When a single element is pushed to either the beginning or end of a
426+ When a single element is pushed onto either the beginning or end of a
428427 one-dimensional array, the result is an array with the same lower bound
429428 subscript as the array operand. For example:
430429<programlisting>
@@ -463,7 +462,7 @@ SELECT array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]);
463462 </para>
464463
465464 <para>
466- When an <replaceable>N</>-dimensional array is pushed to the beginning
465+ When an <replaceable>N</>-dimensional array is pushed onto the beginning
467466 or end of an <replaceable>N+1</>-dimensional array, the result is
468467 analogous to the element-array case above. Each <replaceable>N</>-dimensional
469468 sub-array is essentially an element of the <replaceable>N+1</>-dimensional
@@ -601,9 +600,9 @@ SELECT * FROM
601600 around the array value plus delimiter characters between adjacent items.
602601 The delimiter character is usually a comma (<literal>,</>) but can be
603602 something else: it is determined by the <literal>typdelim</> setting
604- for the array's element type. ( Among the standard data types provided
605- in the <productname>PostgreSQL</productname> distribution, all
606- use a comma, except for <literal >box</>, which uses a semicolon (<literal>;</>).)
603+ for the array's element type. Among the standard data types provided
604+ in the <productname>PostgreSQL</productname> distribution, all use a comma,
605+ except for type <type >box</>, which uses a semicolon (<literal>;</>).
607606 In a multidimensional array, each dimension (row, plane,
608607 cube, etc.) gets its own level of curly braces, and delimiters
609608 must be written between adjacent curly-braced entities of the same level.
@@ -657,7 +656,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
657656 As shown previously, when writing an array value you can use double
658657 quotes around any individual array element. You <emphasis>must</> do so
659658 if the element value would otherwise confuse the array-value parser.
660- For example, elements containing curly braces, commas (or the matching
659+ For example, elements containing curly braces, commas (or the data type's
661660 delimiter character), double quotes, backslashes, or leading or trailing
662661 whitespace must be double-quoted. Empty strings and strings matching the
663662 word <literal>NULL</> must be quoted, too. To put a double quote or
@@ -668,7 +667,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
668667 </para>
669668
670669 <para>
671- You can use whitespace before a left brace or after a right
670+ You can add whitespace before a left brace or after a right
672671 brace. You can also add whitespace before or after any individual item
673672 string. In all of these cases the whitespace will be ignored. However,
674673 whitespace within double-quoted elements, or surrounded on both sides by
0 commit comments