@@ -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</literal> 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>
@@ -1092,24 +1092,29 @@ If the non-unknown inputs are not all of the same type category, fail.
10921092
10931093<step performance="required">
10941094<para>
1095- Choose the first non-unknown input type which is a preferred type in
1096- that category, if there is one.
1097- </para>
1098- </step>
1099-
1100- <step performance="required">
1101- <para>
1102- Otherwise, choose the last non-unknown input type that allows all the
1103- preceding non-unknown inputs to be implicitly converted to it. (There
1104- always is such a type, since at least the first type in the list must
1105- satisfy this condition.)
1095+ Select the first non-unknown input type as the candidate type,
1096+ then consider each other non-unknown input type, left to right.
1097+ <footnote>
1098+ <para>
1099+ For historical reasons, <literal>CASE</literal> treats
1100+ its <literal>ELSE</literal> clause (if any) as the <quote>first</quote>
1101+ input, with the <literal>THEN</literal> clauses(s) considered after
1102+ that. In all other cases, <quote>left to right</quote> means the order
1103+ in which the expressions appear in the query text.
1104+ </para>
1105+ </footnote>
1106+ If the candidate type can be implicitly converted to the other type,
1107+ but not vice-versa, select the other type as the new candidate type.
1108+ Then continue considering the remaining inputs. If, at any stage of this
1109+ process, a preferred type is selected, stop considering additional
1110+ inputs.
11061111</para>
11071112</step>
11081113
11091114<step performance="required">
11101115<para>
1111- Convert all inputs to the selected type. Fail if there is not a
1112- conversion from a given input to the selected type.
1116+ Convert all inputs to the final candidate type. Fail if there is not an
1117+ implicit conversion from a given input type to the candidate type.
11131118</para>
11141119</step>
11151120</procedure>
0 commit comments