11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.172 2003/09/11 18:30:38 momjian Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.173 2003/09/12 22:17:22 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -3890,8 +3890,8 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
38903890 </table>
38913891
38923892 <para>
3893- Warning. <literal><function>to_char</function>(<type>interval</type>, <type>text</type>)</literal>
3894- is deprecated and should not be used in newly-written code.Will be removed in the next version.
3893+ Warning: <literal><function>to_char</function>(<type>interval</type>, <type>text</type>)</literal>
3894+ is deprecated and should not be used in newly-written code.It will be removed in the next version.
38953895 </para>
38963896
38973897 <para>
@@ -6402,7 +6402,16 @@ SELECT a,
64026402 2 | two
64036403 3 | other
64046404</screen>
6405- </para>
6405+ </para>
6406+
6407+ <para>
6408+ A <token>CASE</token> expression does not evaluate any subexpressions
6409+ that are not needed to determine the result. For example, this is a
6410+ possible way of avoiding a division-by-zero failure:
6411+ <programlisting>
6412+ SELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END;
6413+ </programlisting>
6414+ </para>
64066415 </sect2>
64076416
64086417 <sect2>
@@ -6418,13 +6427,21 @@ SELECT a,
64186427
64196428 <para>
64206429 The <function>COALESCE</function> function returns the first of its
6421- arguments that is not null. This is often useful to substitute a
6430+ arguments that is not null. Null is returned only if all arguments
6431+ are null. This is often useful to substitute a
64226432 default value for null values when data is retrieved for display,
64236433 for example:
64246434<programlisting>
64256435SELECT COALESCE(description, short_description, '(none)') ...
64266436</programlisting>
64276437 </para>
6438+
6439+ <para>
6440+ Like a <token>CASE</token> expression, <function>COALESCE</function> will
6441+ not evaluate arguments that are not needed to determine the result;
6442+ that is, arguments to the right of the first non-null argument are
6443+ not evaluated.
6444+ </para>
64286445 </sect2>
64296446
64306447 <sect2>
@@ -7277,6 +7294,21 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
72777294 <tbody>
72787295 <row>
72797296<entry>
7297+ <literal>
7298+ <function>array_cat</function>
7299+ (<type>anyarray</type>, <type>anyarray</type>)
7300+ </literal>
7301+ </entry>
7302+ <entry><type>anyarray</type></entry>
7303+ <entry>
7304+ concatenate two arrays, returning <literal>NULL</literal>
7305+ for <literal>NULL</literal> inputs
7306+ </entry>
7307+ <entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5])</literal></entry>
7308+ <entry><literal>{1,2,3,4,5}</literal></entry>
7309+ </row>
7310+ <row>
7311+ <entry>
72807312 <literal>
72817313 <function>array_append</function>
72827314 (<type>anyarray</type>, <type>anyelement</type>)
@@ -7293,17 +7325,17 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
72937325 <row>
72947326<entry>
72957327 <literal>
7296- <function>array_cat </function>
7297- (<type>anyarray </type>, <type>anyarray</type>)
7328+ <function>array_prepend </function>
7329+ (<type>anyelement </type>, <type>anyarray</type>)
72987330 </literal>
72997331 </entry>
73007332<entry><type>anyarray</type></entry>
73017333<entry>
7302- concatenate two arrays , returning <literal>NULL</literal>
7303- for <literal>NULL</literal> inputs
7334+ append an element to the beginning of an array , returning
7335+ <literal>NULL</literal> for <literal>NULL</literal> inputs
73047336 </entry>
7305- <entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5,6 ])</literal></entry>
7306- <entry><literal>{1,2,3,4,5,6 }</literal></entry>
7337+ <entry><literal>array_prepend(1, ARRAY[2,3 ])</literal></entry>
7338+ <entry><literal>{1,2,3}</literal></entry>
73077339 </row>
73087340 <row>
73097341<entry>
@@ -7317,7 +7349,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73177349 returns a text representation of array dimension lower and upper bounds,
73187350 generating an ERROR for <literal>NULL</literal> inputs
73197351 </entry>
7320- <entry><literal>array_dims(array[[1,2,3],[4,5,6]])</literal></entry>
7352+ <entry><literal>array_dims(array[[1,2,3], [4,5,6]])</literal></entry>
73217353<entry><literal>[1:2][1:3]</literal></entry>
73227354 </row>
73237355 <row>
@@ -7338,17 +7370,17 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73387370 <row>
73397371<entry>
73407372 <literal>
7341- <function>array_prepend </function>
7342- (<type>anyelement </type>, <type>anyarray </type>)
7373+ <function>array_upper </function>
7374+ (<type>anyarray </type>, <type>integer </type>)
73437375 </literal>
73447376 </entry>
7345- <entry><type>anyarray </type></entry>
7377+ <entry><type>integer </type></entry>
73467378<entry>
7347- append an element to thebeginning of an array, returning
7379+ returns upper bound of therequested array dimension , returning
73487380 <literal>NULL</literal> for <literal>NULL</literal> inputs
73497381 </entry>
7350- <entry><literal>array_prepend(1, ARRAY[2,3] )</literal></entry>
7351- <entry><literal>{1,2,3} </literal></entry>
7382+ <entry><literal>array_upper( ARRAY[1, 2,3,4], 1 )</literal></entry>
7383+ <entry><literal>4 </literal></entry>
73527384 </row>
73537385 <row>
73547386<entry>
@@ -7362,23 +7394,8 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73627394 concatenates array elements using provided delimiter, returning
73637395 <literal>NULL</literal> for <literal>NULL</literal> inputs
73647396 </entry>
7365- <entry><literal>array_to_string(array[1.1,2.2,3.3]::numeric(4,2)[],'~^~')</literal></entry>
7366- <entry><literal>1.10~^~2.20~^~3.30</literal></entry>
7367- </row>
7368- <row>
7369- <entry>
7370- <literal>
7371- <function>array_upper</function>
7372- (<type>anyarray</type>, <type>integer</type>)
7373- </literal>
7374- </entry>
7375- <entry><type>integer</type></entry>
7376- <entry>
7377- returns upper bound of the requested array dimension, returning
7378- <literal>NULL</literal> for <literal>NULL</literal> inputs
7379- </entry>
7380- <entry><literal>array_upper(array_append(ARRAY[1,2,3], 4), 1)</literal></entry>
7381- <entry><literal>4</literal></entry>
7397+ <entry><literal>array_to_string(array[1, 2, 3], '~^~')</literal></entry>
7398+ <entry><literal>1~^~2~^~3</literal></entry>
73827399 </row>
73837400 <row>
73847401<entry>
@@ -7392,8 +7409,8 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
73927409 splits string into array elements using provided delimiter, returning
73937410 <literal>NULL</literal> for <literal>NULL</literal> inputs
73947411 </entry>
7395- <entry><literal>string_to_array('1.10 ~^~2.20 ~^~3.30', '~^~')::float8[] </literal></entry>
7396- <entry><literal>{1.1,2.2,3.3 }</literal></entry>
7412+ <entry><literal>string_to_array( 'xx ~^~yy ~^~zz', '~^~')</literal></entry>
7413+ <entry><literal>{xx,yy,zz }</literal></entry>
73977414 </row>
73987415 </tbody>
73997416 </tgroup>