here are the modifications to ri_triggers.c
On Wed, Jul 12, 2017 at 12:26 AM, Mark Rofail <markm.rof...@gmail.com> wrote: > > *What I did * > > - now the RI checks utilise the @>(anyarray, anyelement) > > Best Regards, > Mark Rofail >
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 3a25ba52f3..2d2b8e6a4f 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -2650,7 +2650,7 @@ quoteRelationName(char *buffer, Relation rel) * ri_GenerateQual --- generate a WHERE clause equating two variables * * The idea is to append " sep leftop op rightop" to buf, or if fkreftype is - * FKCONSTR_REF_EACH_ELEMENT, append " sep leftop op ANY(rightop)" to buf. + * FKCONSTR_REF_EACH_ELEMENT, append " sep leftop <@ rightop" to buf. * * The complexity comes from needing to be sure that the parser will select * the desired operator. We always name the operator using @@ -2694,21 +2694,34 @@ ri_GenerateQual(StringInfo buf, else oprright = operform->oprright; - appendStringInfo(buf, " %s %s", sep, leftop); - if (leftoptype != operform->oprleft) - ri_add_cast_to(buf, operform->oprleft); - - appendStringInfo(buf, " OPERATOR(%s.%s) ", + if (fkreftype == FKCONSTR_REF_EACH_ELEMENT){ + appendStringInfo(buf, " %s %s", sep, rightop); + + if (rightoptype != oprright) + ri_add_cast_to(buf, oprright); + + appendStringInfo(buf, " @> "); + + appendStringInfoString(buf, leftop); + + if (leftoptype != operform->oprleft) + ri_add_cast_to(buf, operform->oprleft); + } + else{ + appendStringInfo(buf, " %s %s", sep, leftop); + + if (leftoptype != operform->oprleft) + ri_add_cast_to(buf, operform->oprleft); + + appendStringInfo(buf, " OPERATOR(%s.%s) ", quote_identifier(nspname), oprname); - - if (fkreftype == FKCONSTR_REF_EACH_ELEMENT) - appendStringInfoString(buf, "ANY ("); - appendStringInfoString(buf, rightop); - if (rightoptype != oprright) - ri_add_cast_to(buf, oprright); - if (fkreftype == FKCONSTR_REF_EACH_ELEMENT) - appendStringInfoChar(buf, ')'); + appendStringInfoString(buf, rightop); + + if (rightoptype != oprright) + ri_add_cast_to(buf, oprright); + } + ReleaseSysCache(opertup); }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers