bool should_free_new = false;
/*
- * Locate trigger in trigdesc.
+ * Locate trigger in trigdesc. It might not be present, and in fact the
+ * trigdesc could be NULL, if the trigger was dropped since the event was
+ * queued. In that case, silently do nothing.
*/
+ if (trigdesc == NULL)
+ return;
for (tgindx = 0; tgindx < trigdesc->numtriggers; tgindx++)
{
if (trigdesc->triggers[tgindx].tgoid == tgoid)
}
}
if (LocTriggerData.tg_trigger == NULL)
- elog(ERROR, "could not find trigger %u", tgoid);
+ return;
/*
* If doing EXPLAIN ANALYZE, start charging time to this trigger. We want
/* Catch calls with insufficient relcache refcounting */
Assert(!RelationHasReferenceCountZero(rel));
trigdesc = rInfo->ri_TrigDesc;
+ /* caution: trigdesc could be NULL here */
finfo = rInfo->ri_TrigFunctions;
instr = rInfo->ri_TrigInstrument;
if (slot1 != NULL)
slot2 = MakeSingleTupleTableSlot(rel->rd_att,
&TTSOpsMinimalTuple);
}
- if (trigdesc == NULL) /* should not happen */
- elog(ERROR, "relation %u has no triggers",
- evtshared->ats_relid);
}
/*
drop table refd_table, trig_table;
--
+-- Test that we can drop a not-yet-fired deferred trigger
+--
+create table refd_table (id int primary key);
+create table trig_table (fk int references refd_table initially deferred);
+begin;
+insert into trig_table values (1);
+drop table refd_table cascade;
+NOTICE: drop cascades to constraint trig_table_fk_fkey on table trig_table
+commit;
+drop table trig_table;
+--
-- self-referential FKs are even more fun
--
create table self_ref (a int primary key,
drop table refd_table, trig_table;
+--
+-- Test that we can drop a not-yet-fired deferred trigger
+--
+
+create table refd_table (id int primary key);
+create table trig_table (fk int references refd_table initially deferred);
+
+begin;
+insert into trig_table values (1);
+drop table refd_table cascade;
+commit;
+
+drop table trig_table;
+
--
-- self-referential FKs are even more fun
--