Fix ExecBRDeleteTriggers so that deletion is not suppressed when delete
triggers exist but are all disabled. Problem noted by Gavin Sherry in original discussion of enable/disable trigger patch, but was never addressed.
This commit is contained in:
parent
130b2dd8ea
commit
a0a0bc02b7
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.193 2005/08/23 22:40:08 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.194 2005/08/24 17:38:35 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1492,9 +1492,10 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
|
|||||||
TriggerDesc *trigdesc = relinfo->ri_TrigDesc;
|
TriggerDesc *trigdesc = relinfo->ri_TrigDesc;
|
||||||
int ntrigs = trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
|
int ntrigs = trigdesc->n_before_row[TRIGGER_EVENT_DELETE];
|
||||||
int *tgindx = trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
|
int *tgindx = trigdesc->tg_before_row[TRIGGER_EVENT_DELETE];
|
||||||
|
bool result = true;
|
||||||
TriggerData LocTriggerData;
|
TriggerData LocTriggerData;
|
||||||
HeapTuple trigtuple;
|
HeapTuple trigtuple;
|
||||||
HeapTuple newtuple = NULL;
|
HeapTuple newtuple;
|
||||||
TupleTableSlot *newSlot;
|
TupleTableSlot *newSlot;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1524,13 +1525,16 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
|
|||||||
relinfo->ri_TrigInstrument,
|
relinfo->ri_TrigInstrument,
|
||||||
GetPerTupleMemoryContext(estate));
|
GetPerTupleMemoryContext(estate));
|
||||||
if (newtuple == NULL)
|
if (newtuple == NULL)
|
||||||
|
{
|
||||||
|
result = false; /* tell caller to suppress delete */
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (newtuple != trigtuple)
|
if (newtuple != trigtuple)
|
||||||
heap_freetuple(newtuple);
|
heap_freetuple(newtuple);
|
||||||
}
|
}
|
||||||
heap_freetuple(trigtuple);
|
heap_freetuple(trigtuple);
|
||||||
|
|
||||||
return (newtuple == NULL) ? false : true;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user