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