~ubuntu-branches/ubuntu/trusty/postgresql-9.3/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/arrays.html

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2016-03-31 11:04:53 UTC
  • mfrom: (1.1.11) (18.1.4 trusty-security)
  • Revision ID: package-import@ubuntu.com-20160331110453-h6xfs9f11suj3mze
Tags: 9.3.12-0ubuntu0.14.04
* New upstream bug fix release. (LP: #1564268)
  - See http://www.postgresql.org/about/news/1656/ for details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
REV="MADE"
10
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
11
11
REL="HOME"
12
 
TITLE="PostgreSQL 9.3.9 Documentation"
 
12
TITLE="PostgreSQL 9.3.12 Documentation"
13
13
HREF="index.html"><LINK
14
14
REL="UP"
15
15
TITLE="Data Types"
26
26
HTTP-EQUIV="Content-Type"
27
27
CONTENT="text/html; charset=ISO-8859-1"><META
28
28
NAME="creation"
29
 
CONTENT="2015-06-09T19:42:38"></HEAD
 
29
CONTENT="2016-03-28T20:28:06"></HEAD
30
30
><BODY
31
31
CLASS="SECT1"
32
32
><DIV
44
44
VALIGN="bottom"
45
45
><A
46
46
HREF="index.html"
47
 
>PostgreSQL 9.3.9 Documentation</A
 
47
>PostgreSQL 9.3.12 Documentation</A
48
48
></TH
49
49
></TR
50
50
><TR
814
814
CLASS="FUNCTION"
815
815
>array_cat</CODE
816
816
> supports multidimensional arrays.
817
 
 
818
 
  Note that the concatenation operator discussed above is preferred over
819
 
  direct use of these functions. In fact, these functions primarily exist for use
820
 
  in implementing the concatenation operator. However, they might be directly
821
 
  useful in the creation of user-defined aggregates. Some examples:
 
817
  Some examples:
822
818
 
823
819
</P><PRE
824
820
CLASS="PROGRAMLISTING"
852
848
 {{5,6},{1,2},{3,4}}</PRE
853
849
><P>
854
850
 </P
 
851
><P
 
852
>  In simple cases, the concatenation operator discussed above is preferred
 
853
  over direct use of these functions.  However, because the concatenation
 
854
  operator is overloaded to serve all three cases, there are situations where
 
855
  use of one of the functions is helpful to avoid ambiguity.  For example
 
856
  consider:
 
857
 
 
858
</P><PRE
 
859
CLASS="PROGRAMLISTING"
 
860
>SELECT ARRAY[1, 2] || '{3, 4}';  -- the untyped literal is taken as an array
 
861
 ?column?
 
862
-----------
 
863
 {1,2,3,4}
 
864
 
 
865
SELECT ARRAY[1, 2] || '7';                 -- so is this one
 
866
ERROR:  malformed array literal: "7"
 
867
 
 
868
SELECT ARRAY[1, 2] || NULL;                -- so is an undecorated NULL
 
869
 ?column?
 
870
----------
 
871
 {1,2}
 
872
(1 row)
 
873
 
 
874
SELECT array_append(ARRAY[1, 2], NULL);    -- this might have been meant
 
875
 array_append
 
876
--------------
 
877
 {1,2,NULL}</PRE
 
878
><P>
 
879
 
 
880
  In the examples above, the parser sees an integer array on one side of the
 
881
  concatenation operator, and a constant of undetermined type on the other.
 
882
  The heuristic it uses to resolve the constant's type is to assume it's of
 
883
  the same type as the operator's other input &mdash; in this case,
 
884
  integer array.  So the concatenation operator is presumed to
 
885
  represent <CODE
 
886
CLASS="FUNCTION"
 
887
>array_cat</CODE
 
888
>, not <CODE
 
889
CLASS="FUNCTION"
 
890
>array_append</CODE
 
891
>.  When
 
892
  that's the wrong choice, it could be fixed by casting the constant to the
 
893
  array's element type; but explicit use of <CODE
 
894
CLASS="FUNCTION"
 
895
>array_append</CODE
 
896
> might
 
897
  be a preferable solution.
 
898
 </P
855
899
></DIV
856
900
><DIV
857
901
CLASS="SECT2"