8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Misc adjustments/renaming/comments based on Vlad's feedback.

This commit is contained in:
Dmitry Yemanov 2016-05-16 11:31:04 +03:00
parent 4653b6b80a
commit 4690eb6a0d
3 changed files with 32 additions and 28 deletions

View File

@ -396,8 +396,13 @@ Savepoint* Savepoint::rollback(thread_db* tdbb, Savepoint* prior)
while (m_actions)
{
m_actions->undo(tdbb, m_transaction);
releaseAction(m_actions);
VerbAction* const action = m_actions;
action->undo(tdbb, m_transaction);
m_actions = action->vct_next;
action->vct_next = m_freeActions;
m_freeActions = action;
}
tdbb->setTransaction(old_tran);
@ -457,22 +462,29 @@ Savepoint* Savepoint::rollforward(thread_db* tdbb, Savepoint* prior)
while (m_actions)
{
VerbAction* const action = m_actions;
VerbAction* nextAction = NULL;
if (m_next)
{
nextAction = m_next->getAction(m_actions->vct_relation);
nextAction = m_next->getAction(action->vct_relation);
if (!nextAction) // next savepoint didn't touch this table yet - send whole action
{
propagateAction(m_actions);
m_actions = action->vct_next;
action->vct_next = m_next->m_actions;
m_next->m_actions = action;
continue;
}
}
// No luck, merge actions in a slow way
m_actions->mergeTo(tdbb, m_transaction, nextAction);
releaseAction(m_actions);
// No luck, merge action in a slow way
action->mergeTo(tdbb, m_transaction, nextAction);
// and release it afterwards
m_actions = action->vct_next;
action->vct_next = m_freeActions;
m_freeActions = action;
}
tdbb->setTransaction(old_tran);

View File

@ -147,6 +147,8 @@ namespace Jrd
VerbAction* getAction(const jrd_rel* relation) const
{
// Find and return (if exists) action that belongs to the given relation
for (VerbAction* action = m_actions; action; action = action->vct_next)
{
if (action->vct_relation == relation)
@ -201,8 +203,11 @@ namespace Jrd
m_flags |= SAV_force_dfw;
}
Savepoint* mergeTo(Savepoint*& target)
Savepoint* moveToStack(Savepoint*& target)
{
// Relink savepoint to the top of the provided savepoint stack.
// Return the former "next" pointer to the caller.
Savepoint* const next = m_next;
m_next = target;
target = this;
@ -211,27 +216,11 @@ namespace Jrd
VerbAction* createAction(jrd_rel* relation);
void releaseAction(VerbAction* action)
{
m_actions = action->vct_next;
action->vct_next = m_freeActions;
m_freeActions = action;
}
void propagateAction(VerbAction* action)
{
m_actions = action->vct_next;
action->vct_next = m_next->m_actions;
m_next->m_actions = action;
}
void cleanupTempData();
Savepoint* rollback(thread_db* tdbb, Savepoint* prior = NULL);
Savepoint* rollforward(thread_db* tdbb, Savepoint* prior = NULL);
static Savepoint* start(jrd_tra* transaction, bool root = false);
static void destroy(Savepoint*& savepoint)
{
while (savepoint)
@ -242,10 +231,13 @@ namespace Jrd
}
}
static void merge(Savepoint*& target, Savepoint*& source)
static void mergeStacks(Savepoint*& target, Savepoint*& source)
{
// Given two savepoint stacks, merge them together.
// The source stack becomes empty after that.
while (source)
source = source->mergeTo(target);
source = source->moveToStack(target);
}
class Iterator

View File

@ -617,7 +617,7 @@ void EXE_receive(thread_db* tdbb,
if (request->req_proc_sav_point)
{
// Push all saved savepoints to the top of transaction savepoints stack
Savepoint::merge(transaction->tra_save_point, request->req_proc_sav_point);
Savepoint::mergeStacks(transaction->tra_save_point, request->req_proc_sav_point);
fb_assert(!request->req_proc_sav_point);
}
else
@ -687,7 +687,7 @@ void EXE_receive(thread_db* tdbb,
Savepoint* const savepoint = transaction->tra_save_point;
transaction->rollforwardSavepoint(tdbb);
fb_assert(transaction->tra_save_free == savepoint);
transaction->tra_save_free = savepoint->mergeTo(request->req_proc_sav_point);
transaction->tra_save_free = savepoint->moveToStack(request->req_proc_sav_point);
fb_assert(request->req_proc_sav_point == savepoint);
}
}