Thread: pgsql: Fix select_common_type() so that it can select a domain type, if

pgsql: Fix select_common_type() so that it can select a domain type, if

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        typeconv.sgml (r1.52 -> r1.53)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/typeconv.sgml?r1=1.52&r2=1.53)
    pgsql/src/backend/parser:
        parse_coerce.c (r2.158 -> r2.159)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_coerce.c?r1=2.158&r2=2.159)
    pgsql/src/test/regress/expected:
        domain.out (r1.42 -> r1.43)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/domain.out?r1=1.42&r2=1.43)
    pgsql/src/test/regress/sql:
        domain.sql (r1.25 -> r1.26)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/domain.sql?r1=1.25&r2=1.26)