@@ -12017,6 +12017,12 @@ SELECT COALESCE(description, short_description, '(none)') ...
12017
12017
<varname>short_description</> if it is not null, otherwise <literal>(none)</>.
12018
12018
</para>
12019
12019
12020
+ <para>
12021
+ The arguments must all be convertible to a common data type, which
12022
+ will be the type of the result (see
12023
+ <xref linkend="typeconv-union-case"> for details).
12024
+ </para>
12025
+
12020
12026
<para>
12021
12027
Like a <token>CASE</token> expression, <function>COALESCE</function> only
12022
12028
evaluates the arguments that are needed to determine the result;
@@ -12047,13 +12053,30 @@ SELECT COALESCE(description, short_description, '(none)') ...
12047
12053
<programlisting>
12048
12054
SELECT NULLIF(value, '(none)') ...
12049
12055
</programlisting>
12050
- </para>
12051
- <para>
12052
12056
In this example, if <literal>value</literal> is <literal>(none)</>,
12053
12057
null is returned, otherwise the value of <literal>value</literal>
12054
12058
is returned.
12055
12059
</para>
12056
12060
12061
+ <para>
12062
+ The two arguments must be of comparable types.
12063
+ To be specific, they are compared exactly as if you had
12064
+ written <literal><replaceable>value1</replaceable>
12065
+ = <replaceable>value2</replaceable></literal>, so there must be a
12066
+ suitable <literal>=</literal> operator available.
12067
+ </para>
12068
+
12069
+ <para>
12070
+ The result has the same type as the first argument — but there is
12071
+ a subtlety. What is actually returned is the first argument of the
12072
+ implied <literal>=</literal> operator, and in some cases that will have
12073
+ been promoted to match the second argument's type. For
12074
+ example, <literal>NULLIF(1, 2.2)</literal> yields <type>numeric</type>,
12075
+ because there is no <type>integer</type> <literal>=</literal>
12076
+ <type>numeric</type> operator,
12077
+ only <type>numeric</type> <literal>=</literal> <type>numeric</type>.
12078
+ </para>
12079
+
12057
12080
</sect2>
12058
12081
12059
12082
<sect2 id="functions-greatest-least">
0 commit comments