diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-27 23:21:12 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-03-27 23:21:12 +0000 |
commit | bf94076348ef7e0a81e3fe4ededb2fdcd14b303b (patch) | |
tree | e513ac49a62f2fbde540bbc57b3e162d7ff13624 /src/backend/utils/adt/ri_triggers.c | |
parent | 87564ffc6a87c6cdcc669472892be2ef0870a0f3 (diff) | |
download | postgresql-bf94076348ef7e0a81e3fe4ededb2fdcd14b303b.tar.gz postgresql-bf94076348ef7e0a81e3fe4ededb2fdcd14b303b.zip |
Fix array coercion expressions to ensure that the correct volatility is
seen by code inspecting the expression. The best way to do this seems
to be to drop the original representation as a function invocation, and
instead make a special expression node type that represents applying
the element-type coercion function to each array element. In this way
the element function is exposed and will be checked for volatility.
Per report from Guillaume Smet.
Diffstat (limited to 'src/backend/utils/adt/ri_triggers.c')
-rw-r--r-- | src/backend/utils/adt/ri_triggers.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index af363f4acff..b9a026c7ea1 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-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.93 2007/03/25 19:45:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.94 2007/03/27 23:21:10 tgl Exp $ * * ---------- */ @@ -3871,6 +3871,7 @@ ri_HashCompareOp(Oid eq_opr, Oid typeid) Oid lefttype, righttype, castfunc; + bool arrayCoerce; /* We always need to know how to call the equality operator */ fmgr_info_cxt(get_opcode(eq_opr), &entry->eq_opr_finfo, @@ -3879,13 +3880,19 @@ ri_HashCompareOp(Oid eq_opr, Oid typeid) /* * If we chose to use a cast from FK to PK type, we may have to * apply the cast function to get to the operator's input type. + * + * XXX eventually it would be good to support array-coercion cases + * here and in ri_AttributesEqual(). At the moment there is no + * point because cases involving nonidentical array types will + * be rejected at constraint creation time. */ op_input_types(eq_opr, &lefttype, &righttype); Assert(lefttype == righttype); if (typeid == lefttype) castfunc = InvalidOid; /* simplest case */ else if (!find_coercion_pathway(lefttype, typeid, COERCION_IMPLICIT, - &castfunc)) + &castfunc, &arrayCoerce) + || arrayCoerce) /* XXX fixme */ { /* If target is ANYARRAY, assume it's OK, else punt. */ if (lefttype != ANYARRAYOID) |