Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
432fb5b8
Commit
432fb5b8
authored
Aug 19, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates for array documentation, from Joe Conway.
parent
80860c32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
23 deletions
+85
-23
doc/src/sgml/array.sgml
doc/src/sgml/array.sgml
+58
-18
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+9
-4
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+18
-1
No files found.
doc/src/sgml/array.sgml
View file @
432fb5b8
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.
29 2003/08/09 22:50:21
tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/array.sgml,v 1.
30 2003/08/19 06:06:43
tgl Exp $ -->
<sect1 id="arrays">
<sect1 id="arrays">
<title>Arrays</title>
<title>Arrays</title>
...
@@ -162,7 +162,6 @@ ERROR: multidimensional arrays must have array expressions with matching dimens
...
@@ -162,7 +162,6 @@ ERROR: multidimensional arrays must have array expressions with matching dimens
expression syntax is discussed in more detail in <xref
expression syntax is discussed in more detail in <xref
linkend="sql-syntax-array-constructors">.
linkend="sql-syntax-array-constructors">.
</para>
</para>
</sect2>
</sect2>
<sect2>
<sect2>
...
@@ -326,9 +325,9 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
...
@@ -326,9 +325,9 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
<literal>||</literal>.
<literal>||</literal>.
<programlisting>
<programlisting>
SELECT ARRAY[1,2] || ARRAY[3,4];
SELECT ARRAY[1,2] || ARRAY[3,4];
?column?
?column?
-----------
----
-----------
{
{1,2},{3,4}
}
{
1,2,3,4
}
(1 row)
(1 row)
SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
...
@@ -337,27 +336,68 @@ SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
...
@@ -337,27 +336,68 @@ SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
{{5,6},{1,2},{3,4}}
{{5,6},{1,2},{3,4}}
(1 row)
(1 row)
</programlisting>
</programlisting>
</para>
<para>
The concatenation operator allows a single element to be pushed on to the
The concatenation operator allows a single element to be pushed on to the
beginning or end of a one-dimensional array. It also accepts two
beginning or end of a one-dimensional array. It also accepts two
<replaceable>N</>-dimensional arrays, or an <replaceable>N</>-dimensional
<replaceable>N</>-dimensional arrays, or an <replaceable>N</>-dimensional
and an <replaceable>N+1</>-dimensional array. In the former case, the two
and an <replaceable>N+1</>-dimensional array.
<replaceable>N</>-dimension arrays become outer elements of an
</para>
<replaceable>N+1</>-dimensional array. In the latter, the
<replaceable>N</>-dimensional array is added as either the first or last
outer element of the <replaceable>N+1</>-dimensional array.
When extending an array by concatenation, the subscripts of its existing
elements are preserved. For example, when pushing
onto the beginning of an array with one-based subscripts, the resulting
array has zero-based subscripts:
<para>
When a single element is pushed on to the beginning of a one-dimensional
array, the result is an array with a lower bound subscript equal to
the righthand operand's lower bound subscript, minus one. When a single
element is pushed on to the end of a one-dimensional array, the result is
an array retaining the lower bound of the lefthand operand. For example:
<programlisting>
<programlisting>
SELECT array_dims(1 || ARRAY[2,3]);
SELECT array_dims(1 || ARRAY[2,3]);
array_dims
array_dims
------------
------------
[0:2]
[0:2]
(1 row)
(1 row)
SELECT array_dims(ARRAY[1,2] || 3);
array_dims
------------
[1:3]
(1 row)
</programlisting>
</para>
<para>
When two arrays with an equal number of dimensions are concatenated, the
result retains the lower bound subscript of the lefthand operand's outer
dimension. The result is an array comprising every element of the lefthand
operand followed by every element of the righthand operand. For example:
<programlisting>
SELECT array_dims(ARRAY[1,2] || ARRAY[3,4,5]);
array_dims
------------
[1:5]
(1 row)
SELECT array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]);
array_dims
------------
[1:5][1:2]
(1 row)
</programlisting>
</para>
<para>
When an <replaceable>N</>-dimensional array is pushed on to the beginning
or end of an <replaceable>N+1</>-dimensional array, the result is
analogous to the element-array case above. Each <replaceable>N</>-dimensional
sub-array is essentially an element of the <replaceable>N+1</>-dimensional
array's outer dimension. For example:
<programlisting>
SELECT array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]]);
array_dims
------------
[0:2][1:2]
(1 row)
</programlisting>
</programlisting>
</para>
</para>
...
@@ -386,9 +426,9 @@ SELECT array_append(ARRAY[1,2], 3);
...
@@ -386,9 +426,9 @@ SELECT array_append(ARRAY[1,2], 3);
(1 row)
(1 row)
SELECT array_cat(ARRAY[1,2], ARRAY[3,4]);
SELECT array_cat(ARRAY[1,2], ARRAY[3,4]);
array_cat
array_cat
-----------
----
-----------
{
{1,2},{3,4}
}
{
1,2,3,4
}
(1 row)
(1 row)
SELECT array_cat(ARRAY[[1,2],[3,4]], ARRAY[5,6]);
SELECT array_cat(ARRAY[[1,2],[3,4]], ARRAY[5,6]);
...
...
doc/src/sgml/func.sgml
View file @
432fb5b8
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.16
7 2003/08/17 04:52:41 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.16
8 2003/08/19 06:06:43 tgl
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -7032,7 +7032,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -7032,7 +7032,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<para>
<para>
<xref linkend="array-operators-table"> shows the operators
<xref linkend="array-operators-table"> shows the operators
available for
the
<type>array</type> types.
available for <type>array</type> types.
</para>
</para>
<table id="array-operators-table">
<table id="array-operators-table">
...
@@ -7093,7 +7093,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -7093,7 +7093,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<entry> <literal>||</literal> </entry>
<entry> <literal>||</literal> </entry>
<entry>array-to-array concatenation</entry>
<entry>array-to-array concatenation</entry>
<entry><literal>ARRAY[1,2,3] || ARRAY[4,5,6]</literal></entry>
<entry><literal>ARRAY[1,2,3] || ARRAY[4,5,6]</literal></entry>
<entry><literal>{
{1,2,3},{4,5,6}
}</literal></entry>
<entry><literal>{
1,2,3,4,5,6
}</literal></entry>
</row>
</row>
<row>
<row>
...
@@ -7120,6 +7120,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -7120,6 +7120,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
</tgroup>
</tgroup>
</table>
</table>
<para>
See <xref linkend="arrays"> for more details about array operator
behavior.
</para>
<para>
<para>
<xref linkend="array-functions-table"> shows the functions
<xref linkend="array-functions-table"> shows the functions
available for use with array types. See <xref linkend="arrays">
available for use with array types. See <xref linkend="arrays">
...
@@ -7167,7 +7172,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
...
@@ -7167,7 +7172,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
for <literal>NULL</literal> inputs
for <literal>NULL</literal> inputs
</entry>
</entry>
<entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5,6])</literal></entry>
<entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5,6])</literal></entry>
<entry><literal>{
{1,2,3},{4,5,6}
}</literal></entry>
<entry><literal>{
1,2,3,4,5,6
}</literal></entry>
</row>
</row>
<row>
<row>
<entry>
<entry>
...
...
doc/src/sgml/syntax.sgml
View file @
432fb5b8
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.8
2 2003/08/14 23:13:27
tgl Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.8
3 2003/08/19 06:06:48
tgl Exp $
-->
-->
<chapter id="sql-syntax">
<chapter id="sql-syntax">
...
@@ -1270,6 +1270,23 @@ SELECT ARRAY[[1,2],[3,4]];
...
@@ -1270,6 +1270,23 @@ SELECT ARRAY[[1,2],[3,4]];
at the same level must produce sub-arrays of identical dimensions.
at the same level must produce sub-arrays of identical dimensions.
</para>
</para>
<para>
Multidimensional array constructor elements can be anything yielding
an array of the proper kind, not only a sub-<literal>ARRAY</> construct.
For example:
<programlisting>
create table arr(f1 int[], f2 int[]);
CREATE TABLE
insert into arr values (ARRAY[[1,2],[3,4]],ARRAY[[5,6],[7,8]]);
INSERT 2635544 1
select ARRAY[f1, f2, '{{9,10},{11,12}}'::int[]] from arr;
array
------------------------------------------------
{{{1,2},{3,4}},{{5,6},{7,8}},{{9,10},{11,12}}}
(1 row)
</programlisting>
</para>
<para>
<para>
It is also possible to construct an array from the results of a
It is also possible to construct an array from the results of a
subquery. In this form, the array constructor is written with the
subquery. In this form, the array constructor is written with the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment