mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 02:03:04 +01:00
Fixed bug CORE-4216 : Memory leak with TRIGGER ON TRANSACTION COMMIT
This commit is contained in:
parent
ecf2413331
commit
8ee66e0bb0
@ -1070,11 +1070,9 @@ void EXE_execute_triggers(thread_db* tdbb,
|
||||
|
||||
AutoPtr<Record> null_rec;
|
||||
|
||||
if (!old_rec && !new_rec)
|
||||
{
|
||||
// this is a database trigger
|
||||
}
|
||||
else if (!old_rec || !new_rec)
|
||||
const bool is_db_trigger = (!old_rec && !new_rec);
|
||||
|
||||
if (!is_db_trigger && (!old_rec || !new_rec))
|
||||
{
|
||||
const Record* record = old_rec ? old_rec : new_rec;
|
||||
fb_assert(record && record->rec_format);
|
||||
@ -1097,39 +1095,42 @@ void EXE_execute_triggers(thread_db* tdbb,
|
||||
|
||||
jrd_req* trigger = ptr->statement->findRequest(tdbb);
|
||||
|
||||
if (trigger->req_rpb.getCount() > 0)
|
||||
if (!is_db_trigger)
|
||||
{
|
||||
trigger->req_rpb[0].rpb_record = old_rec ? old_rec : null_rec.get();
|
||||
|
||||
if (old_rec && trigger_action != jrd_req::req_trigger_insert)
|
||||
if (trigger->req_rpb.getCount() > 0)
|
||||
{
|
||||
trigger->req_rpb[0].rpb_number = old_rpb->rpb_number;
|
||||
trigger->req_rpb[0].rpb_number.setValid(true);
|
||||
}
|
||||
else
|
||||
trigger->req_rpb[0].rpb_number.setValid(false);
|
||||
}
|
||||
trigger->req_rpb[0].rpb_record = old_rec ? old_rec : null_rec.get();
|
||||
|
||||
if (trigger->req_rpb.getCount() > 1)
|
||||
trigger->req_rpb[1].rpb_record = new_rec ? new_rec : null_rec.get();
|
||||
|
||||
if (new_rec && !(which_trig == StmtNode::PRE_TRIG &&
|
||||
trigger_action == jrd_req::req_trigger_insert))
|
||||
{
|
||||
if (which_trig == StmtNode::PRE_TRIG &&
|
||||
trigger_action == jrd_req::req_trigger_update)
|
||||
{
|
||||
new_rpb->rpb_number = old_rpb->rpb_number;
|
||||
if (old_rec && trigger_action != jrd_req::req_trigger_insert)
|
||||
{
|
||||
trigger->req_rpb[0].rpb_number = old_rpb->rpb_number;
|
||||
trigger->req_rpb[0].rpb_number.setValid(true);
|
||||
}
|
||||
else
|
||||
trigger->req_rpb[0].rpb_number.setValid(false);
|
||||
}
|
||||
|
||||
if (trigger->req_rpb.getCount() > 1)
|
||||
trigger->req_rpb[1].rpb_record = new_rec ? new_rec : null_rec.get();
|
||||
|
||||
if (new_rec && !(which_trig == StmtNode::PRE_TRIG &&
|
||||
trigger_action == jrd_req::req_trigger_insert))
|
||||
{
|
||||
trigger->req_rpb[1].rpb_number = new_rpb->rpb_number;
|
||||
trigger->req_rpb[1].rpb_number.setValid(true);
|
||||
if (which_trig == StmtNode::PRE_TRIG &&
|
||||
trigger_action == jrd_req::req_trigger_update)
|
||||
{
|
||||
new_rpb->rpb_number = old_rpb->rpb_number;
|
||||
}
|
||||
|
||||
if (trigger->req_rpb.getCount() > 1)
|
||||
{
|
||||
trigger->req_rpb[1].rpb_number = new_rpb->rpb_number;
|
||||
trigger->req_rpb[1].rpb_number.setValid(true);
|
||||
}
|
||||
}
|
||||
else if (trigger->req_rpb.getCount() > 1)
|
||||
trigger->req_rpb[1].rpb_number.setValid(false);
|
||||
}
|
||||
else if (trigger->req_rpb.getCount() > 1)
|
||||
trigger->req_rpb[1].rpb_number.setValid(false);
|
||||
|
||||
trigger->req_timestamp = timestamp;
|
||||
trigger->req_trigger_action = trigger_action;
|
||||
|
Loading…
Reference in New Issue
Block a user