@@ -1069,7 +1069,7 @@ domain's base type for all subsequent steps.
1069
1069
functions, this behavior allows a domain type to be preserved through
1070
1070
a <literal>UNION</literal> or similar construct, so long as the user is
1071
1071
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 .
1073
1073
</para>
1074
1074
</footnote>
1075
1075
</para>
@@ -1092,24 +1092,29 @@ If the non-unknown inputs are not all of the same type category, fail.
1092
1092
1093
1093
<step performance="required">
1094
1094
<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.
1106
1111
</para>
1107
1112
</step>
1108
1113
1109
1114
<step performance="required">
1110
1115
<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.
1113
1118
</para>
1114
1119
</step>
1115
1120
</procedure>
0 commit comments