@@ -13909,6 +13909,12 @@ SELECT COALESCE(description, short_description, '(none)') ...
13909
13909
<varname>short_description</varname> if it is not null, otherwise <literal>(none)</literal>.
13910
13910
</para>
13911
13911
13912
+ <para>
13913
+ The arguments must all be convertible to a common data type, which
13914
+ will be the type of the result (see
13915
+ <xref linkend="typeconv-union-case"/> for details).
13916
+ </para>
13917
+
13912
13918
<para>
13913
13919
Like a <token>CASE</token> expression, <function>COALESCE</function> only
13914
13920
evaluates the arguments that are needed to determine the result;
@@ -13939,13 +13945,30 @@ SELECT COALESCE(description, short_description, '(none)') ...
13939
13945
<programlisting>
13940
13946
SELECT NULLIF(value, '(none)') ...
13941
13947
</programlisting>
13942
- </para>
13943
- <para>
13944
13948
In this example, if <literal>value</literal> is <literal>(none)</literal>,
13945
13949
null is returned, otherwise the value of <literal>value</literal>
13946
13950
is returned.
13947
13951
</para>
13948
13952
13953
+ <para>
13954
+ The two arguments must be of comparable types.
13955
+ To be specific, they are compared exactly as if you had
13956
+ written <literal><replaceable>value1</replaceable>
13957
+ = <replaceable>value2</replaceable></literal>, so there must be a
13958
+ suitable <literal>=</literal> operator available.
13959
+ </para>
13960
+
13961
+ <para>
13962
+ The result has the same type as the first argument — but there is
13963
+ a subtlety. What is actually returned is the first argument of the
13964
+ implied <literal>=</literal> operator, and in some cases that will have
13965
+ been promoted to match the second argument's type. For
13966
+ example, <literal>NULLIF(1, 2.2)</literal> yields <type>numeric</type>,
13967
+ because there is no <type>integer</type> <literal>=</literal>
13968
+ <type>numeric</type> operator,
13969
+ only <type>numeric</type> <literal>=</literal> <type>numeric</type>.
13970
+ </para>
13971
+
13949
13972
</sect2>
13950
13973
13951
13974
<sect2 id="functions-greatest-least">
0 commit comments