@@ -12638,6 +12638,12 @@ SELECT COALESCE(description, short_description, '(none)') ...
12638
12638
<varname>short_description</varname> if it is not null, otherwise <literal>(none)</literal>.
12639
12639
</para>
12640
12640
12641
+ <para>
12642
+ The arguments must all be convertible to a common data type, which
12643
+ will be the type of the result (see
12644
+ <xref linkend="typeconv-union-case"/> for details).
12645
+ </para>
12646
+
12641
12647
<para>
12642
12648
Like a <token>CASE</token> expression, <function>COALESCE</function> only
12643
12649
evaluates the arguments that are needed to determine the result;
@@ -12668,13 +12674,30 @@ SELECT COALESCE(description, short_description, '(none)') ...
12668
12674
<programlisting>
12669
12675
SELECT NULLIF(value, '(none)') ...
12670
12676
</programlisting>
12671
- </para>
12672
- <para>
12673
12677
In this example, if <literal>value</literal> is <literal>(none)</literal>,
12674
12678
null is returned, otherwise the value of <literal>value</literal>
12675
12679
is returned.
12676
12680
</para>
12677
12681
12682
+ <para>
12683
+ The two arguments must be of comparable types.
12684
+ To be specific, they are compared exactly as if you had
12685
+ written <literal><replaceable>value1</replaceable>
12686
+ = <replaceable>value2</replaceable></literal>, so there must be a
12687
+ suitable <literal>=</literal> operator available.
12688
+ </para>
12689
+
12690
+ <para>
12691
+ The result has the same type as the first argument — but there is
12692
+ a subtlety. What is actually returned is the first argument of the
12693
+ implied <literal>=</literal> operator, and in some cases that will have
12694
+ been promoted to match the second argument's type. For
12695
+ example, <literal>NULLIF(1, 2.2)</literal> yields <type>numeric</type>,
12696
+ because there is no <type>integer</type> <literal>=</literal>
12697
+ <type>numeric</type> operator,
12698
+ only <type>numeric</type> <literal>=</literal> <type>numeric</type>.
12699
+ </para>
12700
+
12678
12701
</sect2>
12679
12702
12680
12703
<sect2 id="functions-greatest-least">
0 commit comments