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

Change the savepoint start function, as suggested by Dimitry Sibiryakov.

This commit is contained in:
Dmitry Yemanov 2016-05-15 18:51:55 +03:00
parent fbd7bd86da
commit 46a7d66246
6 changed files with 47 additions and 37 deletions

View File

@ -532,7 +532,7 @@ const StmtNode* BlockNode::execute(thread_db* tdbb, jrd_req* request, ExeState*
case jrd_req::req_evaluate:
if (!(transaction->tra_flags & TRA_system))
{
const Savepoint* const savepoint = Savepoint::start(transaction);
const Savepoint* const savepoint = transaction->startSavepoint();
savNumber = savepoint->getNumber();
*request->getImpure<SavNumber>(impureOffset) = savNumber;
}
@ -3702,7 +3702,7 @@ const StmtNode* InAutonomousTransactionNode::execute(thread_db* tdbb, jrd_req* r
request->req_auto_trans.push(org_transaction);
impure->traNumber = transaction->tra_number;
const Savepoint* const savepoint = Savepoint::start(transaction);
const Savepoint* const savepoint = transaction->startSavepoint();
impure->savNumber = savepoint->getNumber();
if (!(attachment->att_flags & ATT_no_db_triggers))
@ -4704,7 +4704,7 @@ const StmtNode* ForNode::execute(thread_db* tdbb, jrd_req* request, ExeState* /*
transaction->tra_save_point &&
transaction->tra_save_point->hasChanges())
{
const Savepoint* const savepoint = Savepoint::start(transaction);
const Savepoint* const savepoint = transaction->startSavepoint();
*request->getImpure<SavNumber>(impureOffset) = savepoint->getNumber();
}
cursor->open(tdbb);
@ -7188,7 +7188,7 @@ const StmtNode* UserSavepointNode::execute(thread_db* tdbb, jrd_req* request, Ex
}
// Restore the savepoint initially created by EXE_start
Savepoint::start(transaction);
transaction->startSavepoint();
break;
}
@ -7197,7 +7197,7 @@ const StmtNode* UserSavepointNode::execute(thread_db* tdbb, jrd_req* request, Ex
transaction->rollbackToSavepoint(tdbb, savepoint->getNumber());
// Now set the savepoint again to allow to return to it later
Savepoint* const savepoint = Savepoint::start(transaction);
Savepoint* const savepoint = transaction->startSavepoint();
savepoint->setName(name);
break;
}
@ -7808,7 +7808,7 @@ const StmtNode* SavePointNode::execute(thread_db* tdbb, jrd_req* request, ExeSta
{
// Start a save point.
if (!(transaction->tra_flags & TRA_system))
Savepoint::start(transaction);
transaction->startSavepoint();
request->req_operation = jrd_req::req_return;
}

View File

@ -327,26 +327,6 @@ void VerbAction::release(jrd_tra* transaction)
// Savepoint implementation
Savepoint* Savepoint::start(jrd_tra* transaction, bool root)
{
// Start a new savepoint. Reuse some priorly allocated one, if exists.
Savepoint* savepoint = transaction->tra_save_free;
if (savepoint)
transaction->tra_save_free = savepoint->m_next;
else
savepoint = FB_NEW_POOL(*transaction->tra_pool) Savepoint(transaction);
savepoint->m_number = ++transaction->tra_save_point_number;
savepoint->m_flags = root ? SAV_root : 0;
savepoint->m_next = transaction->tra_save_point;
transaction->tra_save_point = savepoint;
return savepoint;
}
VerbAction* Savepoint::createAction(jrd_rel* relation)
{
// Create action for the given relation. If it already exists, just return.
@ -583,7 +563,7 @@ Savepoint* Savepoint::release(Savepoint* prior)
AutoSavePoint::AutoSavePoint(thread_db* tdbb, jrd_tra* trans)
: m_tdbb(tdbb), m_transaction(trans), m_released(false)
{
Savepoint::start(trans);
trans->startSavepoint();
}
AutoSavePoint::~AutoSavePoint()
@ -612,7 +592,7 @@ StableCursorSavePoint::StableCursorSavePoint(thread_db* tdbb, jrd_tra* trans, bo
if (!trans->tra_save_point)
return;
const Savepoint* const savepoint = Savepoint::start(trans);
const Savepoint* const savepoint = trans->startSavepoint();
m_number = savepoint->getNumber();
}

View File

@ -138,6 +138,13 @@ namespace Jrd
}
}
void init(SavNumber number, bool root, Savepoint* next)
{
m_number = number;
m_flags |= root ? SAV_root : 0;
m_next = next;
}
VerbAction* getAction(const jrd_rel* relation) const
{
for (VerbAction* action = m_actions; action; action = action->vct_next)

View File

@ -624,14 +624,10 @@ void EXE_receive(thread_db* tdbb,
fb_assert(!request->req_proc_sav_point);
}
else
{
Savepoint::start(transaction);
}
transaction->startSavepoint();
}
else
{
Savepoint::start(transaction);
}
transaction->startSavepoint();
}
const JrdStatement* statement = request->getStatement();
@ -1033,7 +1029,7 @@ static void execute_looper(thread_db* tdbb,
if (!(request->req_flags & req_proc_fetch) && request->req_transaction)
{
if (transaction && !(transaction->tra_flags & TRA_system))
Savepoint::start(transaction);
transaction->startSavepoint();
}
request->req_flags &= ~req_stall;

View File

@ -2446,7 +2446,7 @@ static void retain_context(thread_db* tdbb, jrd_tra* transaction, bool commit, i
// All savepoint were already released in TRA_commit/TRA_rollback except, may be, empty transaction-level one
if (!transaction->tra_save_point && !(transaction->tra_flags & TRA_no_auto_undo))
Savepoint::start(transaction, true); // start new savepoint if necessary
transaction->startSavepoint(true); // start new savepoint if necessary
if (transaction->tra_flags & TRA_precommitted)
{
@ -3321,7 +3321,7 @@ static void transaction_start(thread_db* tdbb, jrd_tra* trans)
// undo the transaction if it rolls back.
if (!(trans->tra_flags & TRA_system) && !(trans->tra_flags & TRA_no_auto_undo))
Savepoint::start(trans, true);
trans->startSavepoint(true);
// if the user asked us to restart all requests in this attachment,
// do so now using the new transaction
@ -3519,6 +3519,32 @@ void jrd_tra::releaseAutonomousPool(MemoryPool* toRelease)
}
}
Savepoint* jrd_tra::startSavepoint(bool root)
/**************************************
*
* s t a r t S a v e p o i n t
*
**************************************
*
* Functional description
* Start a new savepoint. Reuse some priorly allocated one, if exists.
*
**************************************/
{
Savepoint* savepoint = tra_save_free;
if (savepoint)
tra_save_free = savepoint->getNext();
else
savepoint = FB_NEW_POOL(*tra_pool) Savepoint(this);
const SavNumber number = ++tra_save_point_number;
savepoint->init(number, root, tra_save_point);
tra_save_point = savepoint;
return savepoint;
}
void jrd_tra::rollbackSavepoint(thread_db* tdbb)
/**************************************
*

View File

@ -361,6 +361,7 @@ public:
MappingList* getMappingList();
Record* findNextUndo(VerbAction* before_this, jrd_rel* relation, SINT64 number);
void listStayingUndo(jrd_rel* relation, SINT64 number, RecordStack &staying);
Savepoint* startSavepoint(bool root = false);
void rollbackSavepoint(thread_db* tdbb);
void rollbackToSavepoint(thread_db* tdbb, SavNumber number);
void rollforwardSavepoint(thread_db* tdbb);