From: Tom Lane Date: Sat, 23 Sep 2000 21:15:26 +0000 (+0000) Subject: Apply Jeroen van Vianen's patch for failure to check heap_openr failure X-Git-Tag: REL7_0_3~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a5531a3f47124851ab84a18f08fec6ddda86e34;p=thirdparty%2Fpostgresql.git Apply Jeroen van Vianen's patch for failure to check heap_openr failure in RI triggers. This is fixed in another way in current sources, but might as well apply this patch to REL7_0 branch so that 7.0.3 need not suffer this crash. --- diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 79010b53f75..053213a8594 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -6,7 +6,7 @@ * * 1999 Jan Wieck * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.14 2000/04/12 17:15:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.14.2.1 2000/09/23 21:15:26 tgl Exp $ * * ---------- */ @@ -204,6 +204,13 @@ RI_FKey_check(FmgrInfo *proinfo) */ fk_rel = trigdata->tg_relation; pk_rel = heap_openr(tgargs[RI_PK_RELNAME_ARGNO], NoLock); + + if (pk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_PK_RELNAME_ARGNO]); + } + if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) { old_row = trigdata->tg_trigtuple; @@ -564,6 +571,12 @@ RI_FKey_noaction_del(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -775,6 +788,12 @@ RI_FKey_noaction_upd(FmgrInfo *proinfo) new_row = trigdata->tg_newtuple; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -990,6 +1009,12 @@ RI_FKey_cascade_del(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -1189,6 +1214,12 @@ RI_FKey_cascade_upd(FmgrInfo *proinfo) new_row = trigdata->tg_newtuple; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -1421,6 +1452,12 @@ RI_FKey_restrict_del(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -1637,6 +1674,12 @@ RI_FKey_restrict_upd(FmgrInfo *proinfo) new_row = trigdata->tg_newtuple; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -1852,6 +1895,12 @@ RI_FKey_setnull_del(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -2064,6 +2113,12 @@ RI_FKey_setnull_upd(FmgrInfo *proinfo) old_row = trigdata->tg_trigtuple; match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]); + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (match_type) { /* ---------- @@ -2317,6 +2372,12 @@ RI_FKey_setdefault_del(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ---------- @@ -2573,9 +2634,14 @@ RI_FKey_setdefault_upd(FmgrInfo *proinfo) pk_rel = trigdata->tg_relation; new_row = trigdata->tg_newtuple; old_row = trigdata->tg_trigtuple; - match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]); + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (match_type) { /* ---------- @@ -2842,6 +2908,12 @@ RI_FKey_keyequal_upd(void) new_row = trigdata->tg_newtuple; old_row = trigdata->tg_trigtuple; + if (fk_rel == NULL) + { + elog(ERROR, "RI constraint %s cannot find table %s", + tgargs[RI_CONSTRAINT_NAME_ARGNO], tgargs[RI_FK_RELNAME_ARGNO]); + } + switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO])) { /* ----------