@@ -11577,6 +11577,12 @@ SELECT COALESCE(description, short_description, '(none)') ...
11577
11577
<varname>short_description</> if it is not null, otherwise <literal>(none)</>.
11578
11578
</para>
11579
11579
11580
+ <para>
11581
+ The arguments must all be convertible to a common data type, which
11582
+ will be the type of the result (see
11583
+ <xref linkend="typeconv-union-case"> for details).
11584
+ </para>
11585
+
11580
11586
<para>
11581
11587
Like a <token>CASE</token> expression, <function>COALESCE</function> only
11582
11588
evaluates the arguments that are needed to determine the result;
@@ -11607,13 +11613,30 @@ SELECT COALESCE(description, short_description, '(none)') ...
11607
11613
<programlisting>
11608
11614
SELECT NULLIF(value, '(none)') ...
11609
11615
</programlisting>
11610
- </para>
11611
- <para>
11612
11616
In this example, if <literal>value</literal> is <literal>(none)</>,
11613
11617
null is returned, otherwise the value of <literal>value</literal>
11614
11618
is returned.
11615
11619
</para>
11616
11620
11621
+ <para>
11622
+ The two arguments must be of comparable types.
11623
+ To be specific, they are compared exactly as if you had
11624
+ written <literal><replaceable>value1</replaceable>
11625
+ = <replaceable>value2</replaceable></literal>, so there must be a
11626
+ suitable <literal>=</literal> operator available.
11627
+ </para>
11628
+
11629
+ <para>
11630
+ The result has the same type as the first argument — but there is
11631
+ a subtlety. What is actually returned is the first argument of the
11632
+ implied <literal>=</literal> operator, and in some cases that will have
11633
+ been promoted to match the second argument's type. For
11634
+ example, <literal>NULLIF(1, 2.2)</literal> yields <type>numeric</type>,
11635
+ because there is no <type>integer</type> <literal>=</literal>
11636
+ <type>numeric</type> operator,
11637
+ only <type>numeric</type> <literal>=</literal> <type>numeric</type>.
11638
+ </para>
11639
+
11617
11640
</sect2>
11618
11641
11619
11642
<sect2 id="functions-greatest-least">
0 commit comments