Fix up JOIN .. USING with domains
authorBruce Momjian
Wed, 25 Jun 2003 04:32:03 +0000 (04:32 +0000)
committerBruce Momjian
Wed, 25 Jun 2003 04:32:03 +0000 (04:32 +0000)
The attached fixes select_common_type() to support the below case:

create table t1( c1 int);
create domain dom_c1 int;
create table t2(c1 dom_c1);
select * from t1 join t2 using( c1 );

I didn't see a need for maintaining the domain as the preferred type. A
simple getBaseType() call on all elements of the list seems to be
enough.

--
Rod Taylor 

src/backend/parser/parse_coerce.c

index 9861d18fdb05a8dff32c7f638f567b79a33c4419..7fd831ca91648c694b07b34f746937f2ee4ee2ec 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.98 2003/06/24 23:14:45 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.99 2003/06/25 04:32:03 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -599,11 +599,11 @@ select_common_type(List *typeids, const char *context)
    List       *l;
 
    Assert(typeids != NIL);
-   ptype = lfirsto(typeids);
+   ptype = getBaseType(lfirsto(typeids));
    pcategory = TypeCategory(ptype);
    foreach(l, lnext(typeids))
    {
-       Oid         ntype = lfirsto(l);
+       Oid         ntype = getBaseType(lfirsto(l));
 
        /* move on to next one if no new information... */
        if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype))