@@ -17285,6 +17285,12 @@ SELECT COALESCE(description, short_description, '(none)') ...
17285
17285
<varname>short_description</varname> if it is not null, otherwise <literal>(none)</literal>.
17286
17286
</para>
17287
17287
17288
+ <para>
17289
+ The arguments must all be convertible to a common data type, which
17290
+ will be the type of the result (see
17291
+ <xref linkend="typeconv-union-case"/> for details).
17292
+ </para>
17293
+
17288
17294
<para>
17289
17295
Like a <token>CASE</token> expression, <function>COALESCE</function> only
17290
17296
evaluates the arguments that are needed to determine the result;
@@ -17315,13 +17321,30 @@ SELECT COALESCE(description, short_description, '(none)') ...
17315
17321
<programlisting>
17316
17322
SELECT NULLIF(value, '(none)') ...
17317
17323
</programlisting>
17318
- </para>
17319
- <para>
17320
17324
In this example, if <literal>value</literal> is <literal>(none)</literal>,
17321
17325
null is returned, otherwise the value of <literal>value</literal>
17322
17326
is returned.
17323
17327
</para>
17324
17328
17329
+ <para>
17330
+ The two arguments must be of comparable types.
17331
+ To be specific, they are compared exactly as if you had
17332
+ written <literal><replaceable>value1</replaceable>
17333
+ = <replaceable>value2</replaceable></literal>, so there must be a
17334
+ suitable <literal>=</literal> operator available.
17335
+ </para>
17336
+
17337
+ <para>
17338
+ The result has the same type as the first argument — but there is
17339
+ a subtlety. What is actually returned is the first argument of the
17340
+ implied <literal>=</literal> operator, and in some cases that will have
17341
+ been promoted to match the second argument's type. For
17342
+ example, <literal>NULLIF(1, 2.2)</literal> yields <type>numeric</type>,
17343
+ because there is no <type>integer</type> <literal>=</literal>
17344
+ <type>numeric</type> operator,
17345
+ only <type>numeric</type> <literal>=</literal> <type>numeric</type>.
17346
+ </para>
17347
+
17325
17348
</sect2>
17326
17349
17327
17350
<sect2 id="functions-greatest-least">
0 commit comments