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.
This commit is contained in:
parent
2d7a219b0d
commit
7e1cb82469
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242.2.2 2008/05/09 22:37:34 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.242.2.3 2008/05/19 04:14:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -4139,11 +4139,11 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
|
|||||||
/*
|
/*
|
||||||
* Otherwise, look for an implicit cast from the FK type to the
|
* Otherwise, look for an implicit cast from the FK type to the
|
||||||
* opcintype, and if found, use the primary equality operator.
|
* opcintype, and if found, use the primary equality operator.
|
||||||
* This is a bit tricky because opcintype might be a generic type
|
* This is a bit tricky because opcintype might be a polymorphic
|
||||||
* such as ANYARRAY, and so what we have to test is whether the
|
* type such as ANYARRAY or ANYENUM; so what we have to test is
|
||||||
* two actual column types can be concurrently cast to that type.
|
* whether the two actual column types can be concurrently cast to
|
||||||
* (Otherwise, we'd fail to reject combinations such as int[] and
|
* that type. (Otherwise, we'd fail to reject combinations such
|
||||||
* point[].)
|
* as int[] and point[].)
|
||||||
*/
|
*/
|
||||||
Oid input_typeids[2];
|
Oid input_typeids[2];
|
||||||
Oid target_typeids[2];
|
Oid target_typeids[2];
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.103.2.1 2008/02/18 23:00:38 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.103.2.2 2008/05/19 04:14:33 tgl Exp $
|
||||||
*
|
*
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
@ -3933,8 +3933,12 @@ ri_HashCompareOp(Oid eq_opr, Oid typeid)
|
|||||||
if (pathtype != COERCION_PATH_FUNC &&
|
if (pathtype != COERCION_PATH_FUNC &&
|
||||||
pathtype != COERCION_PATH_RELABELTYPE)
|
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",
|
elog(ERROR, "no conversion function from %s to %s",
|
||||||
format_type_be(typeid),
|
format_type_be(typeid),
|
||||||
format_type_be(lefttype));
|
format_type_be(lefttype));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user