Browse Source

[1891] (unrelated) regression fix: make sure multiple updates after rollback.

this is a fix to the similar bug as the one fixed in the previous commit,
but for the rollback case.
JINMEI Tatuya 13 years ago
parent
commit
d7cf5f81d9

+ 1 - 0
src/lib/datasrc/sqlite3_accessor.cc

@@ -1104,6 +1104,7 @@ SQLite3Accessor::rollback() {
     StatementProcessor(*dbparameters_, ROLLBACK,
                        "rollback an SQLite3 transaction").exec();
     dbparameters_->in_transaction = false;
+    dbparameters_->updating_zone = false;
     dbparameters_->updated_zone_id = -1;
 }
 

+ 4 - 0
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -1026,7 +1026,11 @@ TEST_F(SQLite3Update, addThenRollback) {
     expected_stored.push_back(new_data);
     checkRecords(*accessor, zone_id, "newdata.example.com.", expected_stored);
 
+    // Rollback the transaction, and confirm the zone reverts to the previous
+    // state.  We also start another update to check if the accessor can be
+    // reused for a new update after rollback.
     accessor->rollback();
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
     checkRecords(*accessor, zone_id, "newdata.example.com.", empty_stored);
 }