Skip to content
Snippets Groups Projects
Commit 2634306f authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Konstantin Osipov
Browse files

txn: zap txn_savepoint->is_first flag

This flag isn't necessary as we can set txn_savepoint->stmt to NULL when
a savepoint is created inside an empty transaction. Using a separate
flag for this purpose obscures the code flow and complicates further
progress so let's remove it.
parent 7bd84cc5
No related branches found
No related tags found
No related merge requests found
......@@ -456,12 +456,7 @@ box_txn_savepoint()
"region", "struct txn_savepoint");
return NULL;
}
if (stailq_empty(&txn->stmts)) {
svp->is_first = true;
return svp;
}
svp->is_first = false;
svp->stmt = txn_last_stmt(txn);
svp->stmt = stailq_last(&txn->stmts);
svp->in_sub_stmt = txn->in_sub_stmt;
return svp;
}
......@@ -474,14 +469,22 @@ box_txn_rollback_to_savepoint(box_txn_savepoint_t *svp)
diag_set(ClientError, ER_SAVEPOINT_NO_TRANSACTION);
return -1;
}
struct txn_stmt *stmt = svp->stmt;
if (!svp->is_first && (stmt == NULL || stmt->space == NULL ||
svp->in_sub_stmt != txn->in_sub_stmt)) {
struct txn_stmt *stmt = svp->stmt == NULL ? NULL :
stailq_entry(svp->stmt, struct txn_stmt, next);
if (stmt != NULL && stmt->space == NULL) {
/*
* The statement at which this savepoint was
* created has been rolled back.
*/
diag_set(ClientError, ER_NO_SUCH_SAVEPOINT);
return -1;
}
if (svp->in_sub_stmt != txn->in_sub_stmt) {
diag_set(ClientError, ER_NO_SUCH_SAVEPOINT);
return -1;
}
struct stailq rollback_stmts;
if (svp->is_first) {
if (stmt == NULL) {
rollback_stmts = txn->stmts;
stailq_create(&txn->stmts);
} else {
......
......@@ -82,13 +82,10 @@ struct txn_savepoint {
/**
* Statement, on which a savepoint is created. On rollback
* to this savepoint all newer statements are rolled back.
* Initialized to NULL in case a savepoint is created in
* an empty transaction.
*/
struct txn_stmt *stmt;
/**
* True, if a savepoint is created when a transaction is
* empty. In such a case stmt can not be used.
*/
bool is_first;
struct stailq_entry *stmt;
};
extern double too_long_threshold;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment