3613 Mats Kindahl 2012-02-20
WL#5223: Binary Log Group Commit
Fixes to make it compile on Windows and Solaris.
- Switched to using a normal loop instead of legacy_iterator.
- Removed include/my_iterator.h containing legacy_iterator.
- Updated perfschema.relaylog result file.
removed:
include/my_iterator.h
modified:
mysql-test/suite/perfschema/r/relaylog.result
sql/binlog.cc
sql/handler.cc
sql/handler.h
3612 Nuno Carvalho 2012-02-20
WL#5223
Fixed some debug messages.
modified:
sql/binlog.cc
=== removed file 'include/my_iterator.h'
--- a/include/my_iterator.h 2011-09-09 11:54:38 +0000
+++ b/include/my_iterator.h 1970-01-01 00:00:00 +0000
@@ -1,179 +0,0 @@
-#ifndef MY_ITERATOR_INCLUDED
-#define MY_ITERATOR_INCLUDED
-
-/**
- Base class implementing common support for iterators over legacy
- lists.
- */
-template <class Type>
-class legit_base {
-public:
- typedef std::forward_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
-
- legit_base(Type* start)
- : m_ptr(start)
- {
- }
-
- legit_base(const legit_base& other)
- : m_ptr(other.m_ptr)
- {
- }
-
- Type& operator *() { return *m_ptr; }
- Type* operator ->() const { return m_ptr; }
-
- void swap(legit_base& other) {
- std::swap(m_ptr, other.m_ptr);
- }
-
- bool operator !=(const legit_base& other) {
- return m_ptr != other.m_ptr;
- }
-
- legit_base& operator=(legit_base other) {
- swap(other);
- return *this;
- }
-
-protected:
- Type* m_ptr;
-};
-
-/**
- Template class to support legacy lists using a member variable for
- the next element.
- */
-template < class Type, Type *Type::*TNext>
-class legit_memvar : public legit_base<Type> {
-public:
- legit_memvar(Type* start)
- : legit_base<Type>(start)
- {
- }
-
- legit_memvar(const legit_memvar& other)
- : legit_base<Type>(other)
- {
- }
-
- legit_memvar& operator ++() {
- if (this->m_ptr)
- this->m_ptr = this->m_ptr->*TNext;
- return *this;
- }
-};
-
-/**@{*/
-/**
- Template classes to support legacy lists using a member function for
- the next element.
- */
-template < class Type, Type *(Type::*TNext)()>
-class legit_memfun : public legit_base<Type> {
-public:
- legit_memfun(Type * start)
- : legit_base<Type>(start)
- {
- }
-
- legit_memfun(const legit_memfun& other)
- : legit_base<Type>(other)
- {
- }
-
- legit_memfun& operator ++() {
- if (this->m_ptr)
- this->m_ptr = (this->m_ptr->*TNext)();
- return *this;
- }
-};
-
-template < class Type, Type *(Type::*TNext)() const>
-class legit_const_memfun : public legit_base<Type> {
-public:
- legit_const_memfun(Type * start)
- : legit_base<Type>(start)
- {
- }
-
- legit_const_memfun(const legit_const_memfun& other)
- : legit_base<Type>(other)
- {
- }
-
- legit_const_memfun& operator ++() {
- if (this->m_ptr)
- this->m_ptr = (this->m_ptr->*TNext)();
- return *this;
- }
-};
-
-/**@{*/
-/**
- Iterators over legacy linked lists.
-
- This iteratory class is used to create forward iterator over
- traditional linked lists that has a next pointer and is terminated
- with the next pointer being NULL. The template class can be
- parameterized over what member to use as the next-in-list pointer,
- but defaults to the <code>next</code> member. The member can be
- either a member function or a member variable and SFINAE together
- with template functions are used to pick the right one.
-
- It works similar to the istream iterators, so the following will
- allow a function to be called for each element of the chain:
-
- @code
- std::for_each(legacy_iterator<AList>(table_list), legacy_iterator<AList>(),
- do_something);
- @endcode
-
- Using the iterator class with a structure that has a different
- next-in-line member (variable or function) can be done in this way:
-
- @code
- std::for_each(legacy_iterator<BList, &BList::next_in_line>(first),
- legacy_iterator<BList, &BList::next_in_line>(),
- do_something);
- @endcode
- */
-template <class Type>
-legit_memfun<Type,&Type::next> legacy_iterator(Type* ptr = 0)
-{
- return legit_memfun<Type,&Type::next>(ptr);
-}
-
-template <class Type>
-legit_const_memfun<Type,&Type::next> legacy_iterator(Type* ptr = 0)
-{
- return legit_const_memfun<Type,&Type::next>(ptr);
-}
-
-template <class Type>
-legit_memvar<Type,&Type::next> legacy_iterator(Type* ptr = 0)
-{
- return legit_memvar<Type,&Type::next>(ptr);
-}
-
-template <class Type, Type *(Type::*TNext)()>
-legit_memfun<Type,TNext> legacy_iterator(Type* ptr = 0)
-{
- return legit_memfun<Type,TNext>(ptr);
-}
-
-template <class Type, Type *(Type::*TNext)() const>
-legit_const_memfun<Type,TNext> legacy_iterator(Type* ptr = 0)
-{
- return legit_const_memfun<Type,TNext>(ptr);
-}
-
-template <class Type, Type *Type::*TNext>
-legit_memvar<Type,TNext> legacy_iterator(Type* ptr = 0)
-{
- return legit_memvar<Type,TNext>(ptr);
-}
-/**@}*/
-
-#endif /* MY_ITERATOR_INCLUDED */
=== modified file 'mysql-test/suite/perfschema/r/relaylog.result'
--- a/mysql-test/suite/perfschema/r/relaylog.result 2011-11-07 16:17:30 +0000
+++ b/mysql-test/suite/perfschema/r/relaylog.result 2012-02-20 12:15:01 +0000
@@ -59,9 +59,11 @@ where event_name like "%MYSQL_BIN_LOG%"
and event_name not like "%MYSQL_BIN_LOG::update_cond"
order by event_name;
EVENT_NAME COUNT_STAR
-wait/synch/cond/sql/MYSQL_BIN_LOG::COND_prep_xids NONE
+wait/synch/cond/sql/MYSQL_BIN_LOG::COND_durable NONE
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_available MANY
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_durable MANY
wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_index MANY
-wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_prep_xids NONE
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_queue MANY
"Expect no slave relay log"
select * from performance_schema.file_summary_by_instance
where event_name like "%relaylog%" order by file_name;
@@ -76,7 +78,10 @@ where event_name like "%MYSQL_RELAY_LOG%
and event_name not like "%MYSQL_RELAY_LOG::update_cond"
order by event_name;
EVENT_NAME COUNT_STAR SUM_TIMER_WAIT MIN_TIMER_WAIT AVG_TIMER_WAIT MAX_TIMER_WAIT
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_available 0 0 0 0 0
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_durable 0 0 0 0 0
wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_index 0 0 0 0 0
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_queue 0 0 0 0 0
"============ Performance schema on slave ============"
select * from performance_schema.file_summary_by_instance
where file_name like "%master-%" order by file_name;
@@ -133,9 +138,11 @@ where event_name like "%MYSQL_BIN_LOG%"
and event_name not like "%MYSQL_BIN_LOG::update_cond"
order by event_name;
EVENT_NAME COUNT_STAR
-wait/synch/cond/sql/MYSQL_BIN_LOG::COND_prep_xids NONE
+wait/synch/cond/sql/MYSQL_BIN_LOG::COND_durable NONE
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_available MANY
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_durable MANY
wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_index MANY
-wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_prep_xids NONE
+wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_queue MANY
"Expect a slave relay log"
select
substring(file_name, locate("slave-", file_name)) as FILE_NAME,
@@ -172,5 +179,8 @@ where event_name like "%MYSQL_RELAY_LOG%
and event_name not like "%MYSQL_RELAY_LOG::update_cond"
order by event_name;
EVENT_NAME COUNT_STAR
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_available MANY
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_durable MANY
wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_index MANY
+wait/synch/mutex/sql/MYSQL_RELAY_LOG::LOCK_queue MANY
include/stop_slave.inc
=== modified file 'sql/binlog.cc'
--- a/sql/binlog.cc 2012-02-20 09:17:32 +0000
+++ b/sql/binlog.cc 2012-02-20 12:15:01 +0000
@@ -5619,9 +5619,6 @@ int MYSQL_BIN_LOG::log_xid(THD *thd, my_
mysql_mutex_assert_not_owner(&LOCK_available);
mysql_mutex_assert_not_owner(&LOCK_log);
mysql_mutex_assert_not_owner(&LOCK_durable);
-#if 0
- DBUG_ASSERT(cache_mngr->stmt_cache.empty());
-#endif
int error= !cache_mngr->flush(thd);
DBUG_RETURN(error);
}
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2012-02-19 20:51:19 +0000
+++ b/sql/handler.cc 2012-02-20 12:15:01 +0000
@@ -43,8 +43,6 @@
#include "ha_partition.h"
#endif
-#include "my_iterator.h"
-
using std::min;
using std::max;
@@ -74,9 +72,6 @@ public:
Persist(THD *thd, bool all) : m_thd(thd), m_all(all) { }
void operator()(const Ha_trx_info& info) {
- handlerton *ht = info.ht();
- if (ht->persist)
- ht->persist(ht, m_thd, m_all);
}
private:
@@ -1301,12 +1296,7 @@ int ha_commit_trans(THD *thd, bool all)
if (error == 0)
{
- /*
- Call the persist operation for each storage engine.
- */
- std::for_each(legacy_iterator<Ha_trx_info>(trans->ha_list),
- legacy_iterator<Ha_trx_info>(),
- Persist(thd, all));
+ ha_persist_htons(thd, all);
}
if (error || (is_real_trans && xid &&
@@ -1386,9 +1376,6 @@ int ha_commit_htons(THD *thd, bool all)
ha_commit_htons() can be called with an empty
transaction.all.ha_list, see why in trans_register_ha()).
*/
-#if 0
- bool is_real_trans=all || thd->transaction.all.ha_list == 0;
-#endif
Ha_trx_info *ha_info= trans->ha_list, *ha_info_next;
DBUG_ENTER("ha_commit_htons");
@@ -1424,6 +1411,24 @@ int ha_commit_htons(THD *thd, bool all)
}
+void ha_persist_htons(THD *thd, bool all)
+{
+ THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
+ Ha_trx_info *ha_info= trans->ha_list;
+
+ if (ha_info)
+ {
+ for (; ha_info; ha_info= ha_info->next())
+ {
+ if (! ha_info->is_trx_read_write())
+ continue;
+ handlerton *ht = ha_info->ht();
+ if (ht->persist)
+ ht->persist(ht, thd, all);
+ }
+ }
+}
+
int ha_rollback_trans(THD *thd, bool all)
{
DBUG_ENTER("ha_rollback_trans");
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2012-02-19 20:40:25 +0000
+++ b/sql/handler.h 2012-02-20 12:15:01 +0000
@@ -2595,6 +2595,7 @@ int ha_commit_htons(THD *thd, bool all);
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
int ha_commit_trans(THD *thd, bool all);
int ha_prepare(THD *thd, bool all);
+void ha_persist_htons(THD *thd, bool all);
int ha_recover(HASH *commit_list);
int ha_rollback_htons(THD *thd, bool all);
int ha_rollback_trans(THD *thd, bool all);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (mats.kindahl:3612 to 3613) WL#5223 | Mats Kindahl | 20 Feb |