3485 Tor Didriksen 2011-10-06
Code cleanup.
Reading register_item_tree_chage/rollback_item_tree_changes was
quite confusing, until I realized that append() was actually push_front()....
@ unittest/gunit/sql_list-t.cc
New unit test.
modified:
libmysqld/lib_sql.cc
sql/event_scheduler.cc
sql/mysqld.cc
sql/rpl_slave.cc
sql/sql_class.cc
sql/sql_insert.cc
sql/sql_list.h
sql/sql_show.cc
unittest/gunit/sql_list-t.cc
3484 Mattias Jonsson 2011-10-06 [merge]
merge
modified:
mysql-test/r/partition_myisam.result
mysql-test/t/partition_myisam.test
sql/ha_partition.cc
sql/ha_partition.h
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc 2011-07-28 08:52:25 +0000
+++ b/libmysqld/lib_sql.cc 2011-10-06 11:06:34 +0000
@@ -690,7 +690,7 @@ void *create_embedded_thd(int client_fla
memset(&thd->net, 0, sizeof(thd->net));
thread_count++;
- threads.append(thd);
+ threads.push_front(thd);
thd->mysys_var= 0;
return thd;
err:
=== modified file 'sql/event_scheduler.cc'
--- a/sql/event_scheduler.cc 2011-07-28 10:54:44 +0000
+++ b/sql/event_scheduler.cc 2011-10-06 11:06:34 +0000
@@ -134,7 +134,7 @@ post_init_event_thread(THD *thd)
}
mysql_mutex_lock(&LOCK_thread_count);
- threads.append(thd);
+ threads.push_front(thd);
thread_count++;
inc_thread_running();
mysql_mutex_unlock(&LOCK_thread_count);
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2011-10-03 11:16:06 +0000
+++ b/sql/mysqld.cc 2011-10-06 11:06:34 +0000
@@ -2180,7 +2180,7 @@ static bool cache_thread()
*/
thd->mysys_var->abort= 0;
thd->thr_create_utime= my_micro_time();
- threads.append(thd);
+ threads.push_front(thd);
return(1);
}
}
@@ -5372,7 +5372,7 @@ void handle_connection_in_main_thread(TH
{
mysql_mutex_assert_owner(&LOCK_thread_count);
thread_cache_size=0; // Safety
- threads.append(thd);
+ threads.push_front(thd);
mysql_mutex_unlock(&LOCK_thread_count);
thd->start_utime= my_micro_time();
do_handle_one_connection(thd);
@@ -5388,7 +5388,7 @@ void create_thread_to_handle_connection(
if (cached_thread_count > wake_thread)
{
/* Get thread from cache */
- thread_cache.append(thd);
+ thread_cache.push_front(thd);
wake_thread++;
mysql_cond_signal(&COND_thread_cache);
}
@@ -5398,7 +5398,7 @@ void create_thread_to_handle_connection(
/* Create new thread to handle connection */
int error;
thread_created++;
- threads.append(thd);
+ threads.push_front(thd);
DBUG_PRINT("info",(("creating thread %lu"), thd->thread_id));
thd->prior_thr_create_utime= thd->start_utime= my_micro_time();
if ((error= mysql_thread_create(key_thread_one_connection,
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-09-26 15:39:00 +0000
+++ b/sql/rpl_slave.cc 2011-10-06 11:06:34 +0000
@@ -3398,7 +3398,7 @@ pthread_handler_t handle_slave_io(void *
goto err;
}
mysql_mutex_lock(&LOCK_thread_count);
- threads.append(thd);
+ threads.push_front(thd);
mysql_mutex_unlock(&LOCK_thread_count);
mi->slave_running = 1;
mi->abort_slave = 0;
@@ -3817,7 +3817,7 @@ pthread_handler_t handle_slave_worker(vo
}
thd->init_for_queries();
mysql_mutex_lock(&LOCK_thread_count);
- threads.append(thd);
+ threads.push_front(thd);
mysql_mutex_unlock(&LOCK_thread_count);
if (w->update_is_transactional())
@@ -4636,7 +4636,7 @@ pthread_handler_t handle_slave_sql(void
thd->temporary_tables = rli->save_temporary_tables; // restore temp tables
set_thd_in_use_temporary_tables(rli); // (re)set sql_thd in use for saved temp tables
mysql_mutex_lock(&LOCK_thread_count);
- threads.append(thd);
+ threads.push_front(thd);
mysql_mutex_unlock(&LOCK_thread_count);
/* MTS: starting the worker pool */
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2011-09-23 10:55:10 +0000
+++ b/sql/sql_class.cc 2011-10-06 11:06:34 +0000
@@ -342,7 +342,7 @@ void thd_new_connection_setup(THD *thd,
thd->set_time();
thd->prior_thr_create_utime= thd->thr_create_utime= thd->start_utime=
my_micro_time();
- threads.append(thd);
+ threads.push_front(thd);
thd_unlock_thread_count(thd);
DBUG_PRINT("info", ("init new connection. thd: 0x%lx fd: %d",
(ulong)thd, mysql_socket_getfd(thd->net.vio->mysql_socket)));
@@ -2077,7 +2077,7 @@ void THD::nocheck_register_item_tree_cha
change= new (change_mem) Item_change_record;
change->place= place;
change->old_value= old_value;
- change_list.append(change);
+ change_list.push_front(change);
}
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2011-08-16 19:33:03 +0000
+++ b/sql/sql_insert.cc 2011-10-06 11:06:34 +0000
@@ -2183,7 +2183,7 @@ bool delayed_get_table(THD *thd, MDL_req
goto end_create;
}
mysql_mutex_lock(&LOCK_delayed_insert);
- delayed_threads.append(di);
+ delayed_threads.push_front(di);
mysql_mutex_unlock(&LOCK_delayed_insert);
}
mysql_mutex_unlock(&LOCK_delayed_create);
@@ -2631,7 +2631,7 @@ pthread_handler_t handle_delayed_insert(
mysql_mutex_lock(&LOCK_thread_count);
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
thd->set_current_time();
- threads.append(thd);
+ threads.push_front(thd);
thd->killed=abort_loop ? THD::KILL_CONNECTION : THD::NOT_KILLED;
mysql_mutex_unlock(&LOCK_thread_count);
=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h 2011-07-21 12:54:54 +0000
+++ b/sql/sql_list.h 2011-10-06 11:06:34 +0000
@@ -638,7 +638,7 @@ public:
inline void empty() { first= &last; last.prev= &first; }
base_ilist() { empty(); }
inline bool is_empty() { return first == &last; }
- inline void append(ilink *a)
+ inline void push_front(ilink *a)
{
first->prev= &a->next;
a->next=first; a->prev= &first; first=a;
@@ -715,7 +715,7 @@ public:
I_List() :base_ilist() {}
inline void empty() { base_ilist::empty(); }
inline bool is_empty() { return base_ilist::is_empty(); }
- inline void append(T* a) { base_ilist::append(a); }
+ inline void push_front(T* a) { base_ilist::push_front(a); }
inline void push_back(T* a) { base_ilist::push_back(a); }
inline T* get() { return (T*) base_ilist::get(); }
inline T* head() { return (T*) base_ilist::head(); }
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2011-09-23 10:55:10 +0000
+++ b/sql/sql_show.cc 2011-10-06 11:06:34 +0000
@@ -2075,7 +2075,7 @@ void mysqld_list_processes(THD *thd,cons
}
mysql_mutex_unlock(&tmp->LOCK_thd_data);
thd_info->start_time= tmp->start_time;
- thread_infos.append(thd_info);
+ thread_infos.push_front(thd_info);
}
}
}
=== modified file 'unittest/gunit/sql_list-t.cc'
--- a/unittest/gunit/sql_list-t.cc 2011-07-21 12:54:54 +0000
+++ b/unittest/gunit/sql_list-t.cc 2011-10-06 11:06:34 +0000
@@ -216,6 +216,25 @@ TEST(SqlIlistTest, Iterate)
}
}
+// Another iteration test over intrusive lists.
+TEST(SqlIlistTest, PushFrontAndIterate)
+{
+ I_List<Linked_node> i_list;
+ I_List_iterator<Linked_node> i_list_iter(i_list);
+ int values[] = {11, 22, 33, 42, 5};
+ for (int ix= 0; ix < array_size(values); ++ix)
+ {
+ i_list.push_front(new Linked_node(values[ix]));
+ }
+
+ Linked_node *node;
+ int value_number= array_size(values) - 1;
+ while ((node= i_list_iter++))
+ {
+ EXPECT_EQ(values[value_number--], node->get_value());
+ }
+}
+
static int cmp_test(void *a, void *b, void *c)
{
EXPECT_EQ(c, (void *)0xFEE1BEEF);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (tor.didriksen:3484 to 3485) | Tor Didriksen | 7 Oct |