diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-19 04:14:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-19 04:14:24 +0000 |
commit | 63e98b55f04004423852fa1e1730761074c412db (patch) | |
tree | da6543b147182237e6039c7ec8a35f5c2d2e96a4 /src | |
parent | 2dad10f467165ad87dace65ae9aa1cf19fae0867 (diff) | |
download | postgresql-63e98b55f04004423852fa1e1730761074c412db.tar.gz |
Coercion sanity check in ri_HashCompareOp failed to allow for enums, as per
example from Rod Taylor. On reflection the correct test here is for any
polymorphic type, not specifically ANYARRAY as in the original coding.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/tablecmds.c | 12 | ||||
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 10 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0bef48e07b..58f0b01b09 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.254 2008/05/16 23:36:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.255 2008/05/19 04:14:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -4377,11 +4377,11 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel, /* * Otherwise, look for an implicit cast from the FK type to the * opcintype, and if found, use the primary equality operator. - * This is a bit tricky because opcintype might be a generic type - * such as ANYARRAY, and so what we have to test is whether the - * two actual column types can be concurrently cast to that type. - * (Otherwise, we'd fail to reject combinations such as int[] and - * point[].) + * This is a bit tricky because opcintype might be a polymorphic + * type such as ANYARRAY or ANYENUM; so what we have to test is + * whether the two actual column types can be concurrently cast to + * that type. (Otherwise, we'd fail to reject combinations such + * as int[] and point[].) */ Oid input_typeids[2]; Oid target_typeids[2]; diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 59f7e49795..7f564e09fa 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -15,7 +15,7 @@ * * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.108 2008/05/12 20:02:02 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.109 2008/05/19 04:14:24 tgl Exp $ * * ---------- */ @@ -3938,8 +3938,12 @@ ri_HashCompareOp(Oid eq_opr, Oid typeid) if (pathtype != COERCION_PATH_FUNC && pathtype != COERCION_PATH_RELABELTYPE) { - /* If target is ANYARRAY, assume it's OK, else punt. */ - if (lefttype != ANYARRAYOID) + /* + * The declared input type of the eq_opr might be a + * polymorphic type such as ANYARRAY or ANYENUM. If so, + * assume the coercion is valid; otherwise complain. + */ + if (!IsPolymorphicType(lefttype)) elog(ERROR, "no conversion function from %s to %s", format_type_be(typeid), format_type_be(lefttype)); |