summaryrefslogtreecommitdiff
path: root/doc/src/sgml/func.sgml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/func.sgml')
-rw-r--r--doc/src/sgml/func.sgml199
1 files changed, 198 insertions, 1 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 3519fad36e6..d092cafa2da 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.154 2003/05/05 15:08:49 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.155 2003/06/24 23:14:42 momjian Exp $
PostgreSQL documentation
-->
@@ -6962,6 +6962,203 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
</sect1>
+ <sect1 id="functions-array">
+ <title>Array Functions</title>
+
+ <para>
+ <xref linkend="array-operators-table"> shows the operators
+ available for the <type>array</type> types.
+ </para>
+
+ <table id="array-operators-table">
+ <title><type>array</type> Operators</title>
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>Operator</entry>
+ <entry>Description</entry>
+ <entry>Example</entry>
+ <entry>Result</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry> <literal>=</literal> </entry>
+ <entry>equals</entry>
+ <entry><literal>ARRAY[1.1,2.1,3.1]::int[] = ARRAY[1,2,3]</literal></entry>
+ <entry><literal>t</literal></entry>
+ </row>
+ <row>
+ <entry> <literal>||</literal> </entry>
+ <entry>array-to-array concatenation</entry>
+ <entry><literal>ARRAY[1,2,3] || ARRAY[4,5,6]</literal></entry>
+ <entry><literal>{{1,2,3},{4,5,6}}</literal></entry>
+ </row>
+ <row>
+ <entry> <literal>||</literal> </entry>
+ <entry>array-to-array concatenation</entry>
+ <entry><literal>ARRAY[1,2,3] || ARRAY[[4,5,6],[7,8,9]]</literal></entry>
+ <entry><literal>{{1,2,3},{4,5,6},{7,8,9}}</literal></entry>
+ </row>
+ <row>
+ <entry> <literal>||</literal> </entry>
+ <entry>element-to-array concatenation</entry>
+ <entry><literal>3 || ARRAY[4,5,6]</literal></entry>
+ <entry><literal>{3,4,5,6}</literal></entry>
+ </row>
+ <row>
+ <entry> <literal>||</literal> </entry>
+ <entry>array-to-element concatenation</entry>
+ <entry><literal>ARRAY[4,5,6] || 7</literal></entry>
+ <entry><literal>{4,5,6,7}</literal></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ <xref linkend="array-functions-table"> shows the functions
+ available for use with array types. See <xref linkend="arrays">
+ for more discussion and examples for the use of these functions.
+ </para>
+
+ <table id="array-functions-table">
+ <title><type>array</type> Functions</title>
+ <tgroup cols="5">
+ <thead>
+ <row>
+ <entry>Function</entry>
+ <entry>Return Type</entry>
+ <entry>Description</entry>
+ <entry>Example</entry>
+ <entry>Result</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>
+ <function>array_append</function>
+ (<type>anyarray</type>, <type>anyelement</type>)
+ </literal>
+ </entry>
+ <entry><type>anyarray</type></entry>
+ <entry>
+ append an element to the end of an array, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_append(ARRAY[1,2], 3)</literal></entry>
+ <entry><literal>{1,2,3}</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_cat</function>
+ (<type>anyarray</type>, <type>anyarray</type>)
+ </literal>
+ </entry>
+ <entry><type>anyarray</type></entry>
+ <entry>
+ concatenate two arrays, returning <literal>NULL</literal>
+ for <literal>NULL</literal> inputs
+ </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>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_dims</function>
+ (<type>anyarray</type>)
+ </literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>
+ returns a text representation of array dimension lower and upper bounds,
+ generating an ERROR for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_dims(array[[1,2,3],[4,5,6]])</literal></entry>
+ <entry><literal>[1:2][1:3]</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_lower</function>
+ (<type>anyarray</type>, <type>integer</type>)
+ </literal>
+ </entry>
+ <entry><type>integer</type></entry>
+ <entry>
+ returns lower bound of the requested array dimension, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_lower(array_prepend(0, ARRAY[1,2,3]), 1)</literal></entry>
+ <entry><literal>0</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_prepend</function>
+ (<type>anyelement</type>, <type>anyarray</type>)
+ </literal>
+ </entry>
+ <entry><type>anyarray</type></entry>
+ <entry>
+ append an element to the beginning of an array, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_prepend(1, ARRAY[2,3])</literal></entry>
+ <entry><literal>{1,2,3}</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_to_string</function>
+ (<type>anyarray</type>, <type>text</type>)
+ </literal>
+ </entry>
+ <entry><type>text</type></entry>
+ <entry>
+ concatenates array elements using provided delimiter, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_to_string(array[1.1,2.2,3.3]::numeric(4,2)[],'~^~')</literal></entry>
+ <entry><literal>1.10~^~2.20~^~3.30</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>array_upper</function>
+ (<type>anyarray</type>, <type>integer</type>)
+ </literal>
+ </entry>
+ <entry><type>integer</type></entry>
+ <entry>
+ returns upper bound of the requested array dimension, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>array_upper(array_append(ARRAY[1,2,3], 4), 1)</literal></entry>
+ <entry><literal>4</literal></entry>
+ </row>
+ <row>
+ <entry>
+ <literal>
+ <function>string_to_array</function>
+ (<type>text</type>, <type>text</type>)
+ </literal>
+ </entry>
+ <entry><type>text[]</type></entry>
+ <entry>
+ splits string into array elements using provided delimiter, returning
+ <literal>NULL</literal> for <literal>NULL</literal> inputs
+ </entry>
+ <entry><literal>string_to_array('1.10~^~2.20~^~3.30','~^~')::float8[]</literal></entry>
+ <entry><literal>{1.1,2.2,3.3}</literal></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect1>
<sect1 id="functions-aggregate">
<title>Aggregate Functions</title>