@@ -1069,7 +1069,7 @@ domain's base type for all subsequent steps.
10691069 functions, this behavior allows a domain type to be preserved through
10701070 a <literal>UNION</> or similar construct, so long as the user is
10711071 careful to ensure that all inputs are implicitly or explicitly of that
1072- exact type. Otherwise the domain's base type will be preferred .
1072+ exact type. Otherwise the domain's base type will be used .
10731073 </para>
10741074 </footnote>
10751075</para>
@@ -1091,24 +1091,29 @@ If the non-unknown inputs are not all of the same type category, fail.
10911091
10921092<step performance="required">
10931093<para>
1094- Choose the first non-unknown input type which is a preferred type in
1095- that category, if there is one.
1096- </para>
1097- </step>
1098-
1099- <step performance="required">
1100- <para>
1101- Otherwise, choose the last non-unknown input type that allows all the
1102- preceding non-unknown inputs to be implicitly converted to it. (There
1103- always is such a type, since at least the first type in the list must
1104- satisfy this condition.)
1094+ Select the first non-unknown input type as the candidate type,
1095+ then consider each other non-unknown input type, left to right.
1096+ <footnote>
1097+ <para>
1098+ For historical reasons, <literal>CASE</literal> treats
1099+ its <literal>ELSE</literal> clause (if any) as the <quote>first</quote>
1100+ input, with the <literal>THEN</literal> clauses(s) considered after
1101+ that. In all other cases, <quote>left to right</quote> means the order
1102+ in which the expressions appear in the query text.
1103+ </para>
1104+ </footnote>
1105+ If the candidate type can be implicitly converted to the other type,
1106+ but not vice-versa, select the other type as the new candidate type.
1107+ Then continue considering the remaining inputs. If, at any stage of this
1108+ process, a preferred type is selected, stop considering additional
1109+ inputs.
11051110</para>
11061111</step>
11071112
11081113<step performance="required">
11091114<para>
1110- Convert all inputs to the selected type. Fail if there is not a
1111- conversion from a given input to the selected type.
1115+ Convert all inputs to the final candidate type. Fail if there is not an
1116+ implicit conversion from a given input type to the candidate type.
11121117</para>
11131118</step>
11141119</procedure>
0 commit comments