mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-30 07:23:07 +03:00
Added is_empty() method to transaction class
Method is_empty() can be determined if there have no been changes to the transaction.
This commit is contained in:
@ -51,6 +51,7 @@ namespace wsrep
|
|||||||
|
|
||||||
const branch_type& root() const { return root_; }
|
const branch_type& root() const { return root_; }
|
||||||
void clear() { root_.clear(); }
|
void clear() { root_.clear(); }
|
||||||
|
bool empty() const { return root_.empty(); }
|
||||||
private:
|
private:
|
||||||
branch_type root_;
|
branch_type root_;
|
||||||
};
|
};
|
||||||
|
@ -98,6 +98,14 @@ namespace wsrep
|
|||||||
return (streaming_context_.fragments_certified() > 0);
|
return (streaming_context_.fragments_certified() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if transaction has not generated any changes.
|
||||||
|
*/
|
||||||
|
bool is_empty() const
|
||||||
|
{
|
||||||
|
return sr_keys_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
bool pa_unsafe() const { return pa_unsafe_; }
|
bool pa_unsafe() const { return pa_unsafe_; }
|
||||||
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }
|
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }
|
||||||
|
|
||||||
|
@ -1229,7 +1229,6 @@ int wsrep::transaction::certify_commit(
|
|||||||
append_sr_keys_for_commit();
|
append_sr_keys_for_commit();
|
||||||
flags(flags() | wsrep::provider::flag::pa_unsafe);
|
flags(flags() | wsrep::provider::flag::pa_unsafe);
|
||||||
}
|
}
|
||||||
sr_keys_.clear();
|
|
||||||
|
|
||||||
flags(flags() | wsrep::provider::flag::commit);
|
flags(flags() | wsrep::provider::flag::commit);
|
||||||
|
|
||||||
@ -1462,6 +1461,7 @@ void wsrep::transaction::cleanup()
|
|||||||
flags_ = 0;
|
flags_ = 0;
|
||||||
certified_ = false;
|
certified_ = false;
|
||||||
pa_unsafe_ = false;
|
pa_unsafe_ = false;
|
||||||
|
sr_keys_.clear();
|
||||||
streaming_context_.cleanup();
|
streaming_context_.cleanup();
|
||||||
client_service_.cleanup_transaction();
|
client_service_.cleanup_transaction();
|
||||||
debug_log_state("cleanup_leave");
|
debug_log_state("cleanup_leave");
|
||||||
|
@ -38,6 +38,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_append_key_data,
|
|||||||
{
|
{
|
||||||
cc.start_transaction(wsrep::transaction_id(1));
|
cc.start_transaction(wsrep::transaction_id(1));
|
||||||
BOOST_REQUIRE(tc.active());
|
BOOST_REQUIRE(tc.active());
|
||||||
|
BOOST_REQUIRE(tc.is_empty());
|
||||||
int vals[3] = {1, 2, 3};
|
int vals[3] = {1, 2, 3};
|
||||||
wsrep::key key(wsrep::key::exclusive);
|
wsrep::key key(wsrep::key::exclusive);
|
||||||
for (int i(0); i < 3; ++i)
|
for (int i(0); i < 3; ++i)
|
||||||
@ -45,6 +46,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_append_key_data,
|
|||||||
key.append_key_part(&vals[i], sizeof(vals[i]));
|
key.append_key_part(&vals[i], sizeof(vals[i]));
|
||||||
}
|
}
|
||||||
BOOST_REQUIRE(cc.append_key(key) == 0);
|
BOOST_REQUIRE(cc.append_key(key) == 0);
|
||||||
|
BOOST_REQUIRE(tc.is_empty() == false);
|
||||||
wsrep::const_buffer data(&vals[2], sizeof(vals[2]));
|
wsrep::const_buffer data(&vals[2], sizeof(vals[2]));
|
||||||
BOOST_REQUIRE(cc.append_data(data) == 0);
|
BOOST_REQUIRE(cc.append_data(data) == 0);
|
||||||
BOOST_REQUIRE(cc.before_commit() == 0);
|
BOOST_REQUIRE(cc.before_commit() == 0);
|
||||||
|
Reference in New Issue
Block a user