mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Doc: fix description of UNION/CASE/etc type unification.
The description of what select_common_type() does was not terribly accurate. Improve it. David Johnston and Tom Lane Discussion: https://postgr.es/m/1019930.1597613200@sss.pgh.pa.us
This commit is contained in:
parent
a28d731a11
commit
22e75a341e
@ -1069,7 +1069,7 @@ domain's base type for all subsequent steps.
|
|||||||
functions, this behavior allows a domain type to be preserved through
|
functions, this behavior allows a domain type to be preserved through
|
||||||
a <literal>UNION</literal> or similar construct, so long as the user is
|
a <literal>UNION</literal> or similar construct, so long as the user is
|
||||||
careful to ensure that all inputs are implicitly or explicitly of that
|
careful to ensure that all inputs are implicitly or explicitly of that
|
||||||
exact type. Otherwise the domain's base type will be preferred.
|
exact type. Otherwise the domain's base type will be used.
|
||||||
</para>
|
</para>
|
||||||
</footnote>
|
</footnote>
|
||||||
</para>
|
</para>
|
||||||
@ -1092,24 +1092,29 @@ If the non-unknown inputs are not all of the same type category, fail.
|
|||||||
|
|
||||||
<step performance="required">
|
<step performance="required">
|
||||||
<para>
|
<para>
|
||||||
Choose the first non-unknown input type which is a preferred type in
|
Select the first non-unknown input type as the candidate type,
|
||||||
that category, if there is one.
|
then consider each other non-unknown input type, left to right.
|
||||||
|
<footnote>
|
||||||
|
<para>
|
||||||
|
For historical reasons, <literal>CASE</literal> treats
|
||||||
|
its <literal>ELSE</literal> clause (if any) as the <quote>first</quote>
|
||||||
|
input, with the <literal>THEN</literal> clauses(s) considered after
|
||||||
|
that. In all other cases, <quote>left to right</quote> means the order
|
||||||
|
in which the expressions appear in the query text.
|
||||||
|
</para>
|
||||||
|
</footnote>
|
||||||
|
If the candidate type can be implicitly converted to the other type,
|
||||||
|
but not vice-versa, select the other type as the new candidate type.
|
||||||
|
Then continue considering the remaining inputs. If, at any stage of this
|
||||||
|
process, a preferred type is selected, stop considering additional
|
||||||
|
inputs.
|
||||||
</para>
|
</para>
|
||||||
</step>
|
</step>
|
||||||
|
|
||||||
<step performance="required">
|
<step performance="required">
|
||||||
<para>
|
<para>
|
||||||
Otherwise, choose the last non-unknown input type that allows all the
|
Convert all inputs to the final candidate type. Fail if there is not an
|
||||||
preceding non-unknown inputs to be implicitly converted to it. (There
|
implicit conversion from a given input type to the candidate type.
|
||||||
always is such a type, since at least the first type in the list must
|
|
||||||
satisfy this condition.)
|
|
||||||
</para>
|
|
||||||
</step>
|
|
||||||
|
|
||||||
<step performance="required">
|
|
||||||
<para>
|
|
||||||
Convert all inputs to the selected type. Fail if there is not a
|
|
||||||
conversion from a given input to the selected type.
|
|
||||||
</para>
|
</para>
|
||||||
</step>
|
</step>
|
||||||
</procedure>
|
</procedure>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user