mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Fix select_common_type() so that it can select a domain type, if all inputs
to a UNION, CASE, or related construct are of the same domain type. The main part of this routine smashes domains to their base types, which seems necessary because the logic involves TypeCategory() and IsPreferredType(), neither of which work usefully on domains. However, we can add a first pass that just detects whether all the inputs are exactly the same type, and if so accept that without question (so long as it's not UNKNOWN). Per recent gripe from Dean Rasheed. In passing, remove some tests for InvalidOid, which have clearly been dead code for quite some time now, because getBaseType() would fail on that input. Also, clarify the manual's not-very-precise description of the existing algorithm's behavior.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/typeconv.sgml,v 1.52 2007/06/05 21:31:04 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/typeconv.sgml,v 1.53 2007/11/26 16:46:50 tgl Exp $ -->
|
||||
|
||||
<chapter Id="typeconv">
|
||||
<title>Type Conversion</title>
|
||||
@ -843,11 +843,19 @@ data type.
|
||||
<title>Type Resolution for <literal>UNION</literal>, <literal>CASE</literal>,
|
||||
and Related Constructs</title>
|
||||
|
||||
<step performance="required">
|
||||
<para>
|
||||
If all inputs are of the same type, and it is not <type>unknown</type>,
|
||||
resolve as that type. Otherwise, replace any domain types in the list with
|
||||
their underlying base types.
|
||||
</para>
|
||||
</step>
|
||||
|
||||
<step performance="required">
|
||||
<para>
|
||||
If all inputs are of type <type>unknown</type>, resolve as type
|
||||
<type>text</type> (the preferred type of the string category).
|
||||
Otherwise, ignore the <type>unknown</type> inputs while choosing the result type.
|
||||
Otherwise, the <type>unknown</type> inputs will be ignored.
|
||||
</para>
|
||||
</step>
|
||||
|
||||
@ -860,14 +868,23 @@ If the non-unknown inputs are not all of the same type category, fail.
|
||||
<step performance="required">
|
||||
<para>
|
||||
Choose the first non-unknown input type which is a preferred type in
|
||||
that category or allows all the non-unknown inputs to be implicitly
|
||||
converted to it.
|
||||
that category, if there is one.
|
||||
</para>
|
||||
</step>
|
||||
|
||||
<step performance="required">
|
||||
<para>
|
||||
Convert all inputs to the selected type.
|
||||
Otherwise, choose the last non-unknown input type that allows all the
|
||||
preceding non-unknown inputs to be implicitly converted to it. (There
|
||||
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>
|
||||
</step>
|
||||
</procedure>
|
||||
|
Reference in New Issue
Block a user