summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/func.sgml35
-rw-r--r--doc/src/sgml/typeconv.sgml26
2 files changed, 53 insertions, 8 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 8c7a48308ec..d7430f1ccf8 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.259 2005/06/24 20:53:29 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.260 2005/06/26 22:05:35 tgl Exp $
PostgreSQL documentation
-->
@@ -6901,6 +6901,39 @@ SELECT NULLIF(value, '(none)') ...
</sect2>
+ <sect2>
+ <title><literal>GREATEST</literal> and <literal>LEAST</literal></title>
+
+ <indexterm>
+ <primary>GREATEST</primary>
+ </indexterm>
+ <indexterm>
+ <primary>LEAST</primary>
+ </indexterm>
+
+<synopsis>
+<function>GREATEST</function>(<replaceable>value</replaceable> <optional>, ...</optional>)
+</synopsis>
+<synopsis>
+<function>LEAST</function>(<replaceable>value</replaceable> <optional>, ...</optional>)
+</synopsis>
+
+ <para>
+ The <function>GREATEST</> and <function>LEAST</> functions select the
+ largest or smallest value from a list of any number of expressions.
+ The expressions must all be convertible to a common data type, which
+ will be the type of the result
+ (see <xref linkend="typeconv-union-case"> for details). NULL values
+ in the list are ignored. The result will be NULL only if all the
+ expressions evaluate to NULL.
+ </para>
+
+ <para>
+ Note that <function>GREATEST</> and <function>LEAST</> are not in
+ the SQL standard, but are a common extension.
+ </para>
+ </sect2>
+
</sect1>
diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml
index ae0e3aea4d7..86e0561acc0 100644
--- a/doc/src/sgml/typeconv.sgml
+++ b/doc/src/sgml/typeconv.sgml
@@ -1,5 +1,5 @@
<!--
-$PostgreSQL: pgsql/doc/src/sgml/typeconv.sgml,v 1.43 2004/12/23 23:07:38 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/typeconv.sgml,v 1.44 2005/06/26 22:05:36 tgl Exp $
-->
<chapter Id="typeconv">
@@ -120,7 +120,7 @@ with, and perhaps converted to, the types of the target columns.
</varlistentry>
<varlistentry>
<term>
-<literal>UNION</literal>, <literal>CASE</literal>, and <literal>ARRAY</literal> constructs
+<literal>UNION</literal>, <literal>CASE</literal>, and related constructs
</term>
<listitem>
<para>
@@ -129,7 +129,8 @@ must appear in a single set of columns, the types of the results of each
<command>SELECT</> clause must be matched up and converted to a uniform set.
Similarly, the result expressions of a <literal>CASE</> construct must be
converted to a common type so that the <literal>CASE</> expression as a whole
-has a known output type. The same holds for <literal>ARRAY</> constructs.
+has a known output type. The same holds for <literal>ARRAY</> constructs,
+and for the <function>GREATEST</> and <function>LEAST</> functions.
</para>
</listitem>
</varlistentry>
@@ -782,7 +783,7 @@ padding spaces.
</sect1>
<sect1 id="typeconv-union-case">
-<title><literal>UNION</literal>, <literal>CASE</literal>, and <literal>ARRAY</literal> Constructs</title>
+<title><literal>UNION</literal>, <literal>CASE</literal>, and Related Constructs</title>
<indexterm zone="typeconv-union-case">
<primary>UNION</primary>
@@ -799,20 +800,31 @@ padding spaces.
<secondary>determination of result type</secondary>
</indexterm>
+<indexterm zone="typeconv-union-case">
+ <primary>GREATEST</primary>
+ <secondary>determination of result type</secondary>
+</indexterm>
+
+<indexterm zone="typeconv-union-case">
+ <primary>LEAST</primary>
+ <secondary>determination of result type</secondary>
+</indexterm>
+
<para>
SQL <literal>UNION</> constructs must match up possibly dissimilar
types to become a single result set. The resolution algorithm is
applied separately to each output column of a union query. The
<literal>INTERSECT</> and <literal>EXCEPT</> constructs resolve
dissimilar types in the same way as <literal>UNION</>. The
-<literal>CASE</> and <literal>ARRAY</> constructs use the identical
+<literal>CASE</>, <literal>ARRAY</>, <function>GREATEST</> and
+<function>LEAST</> constructs use the identical
algorithm to match up their component expressions and select a result
data type.
</para>
<procedure>
-<title><literal>UNION</literal>, <literal>CASE</literal>, and
-<literal>ARRAY</literal> Type Resolution</title>
+<title>Type Resolution for <literal>UNION</literal>, <literal>CASE</literal>,
+and Related Constructs</title>
<step performance="required">
<para>