From ac28ad5dcab32a351bc0bc9e1ada806d3037fc8e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Aug 2005 18:05:27 -0700 Subject: [PATCH 1/5] Avoid problems on shutdown by shutting down replication slave threads after normal connection threads. (Bug #11796) sql/mysqld.cc: Move call to end_slave() after first loop through killing threads, to minimize chances of 'SHOW SLAVE STATUS' being called between the time the slave is shut down and connections are shut down. --- sql/mysqld.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 896114f98c6..394dd3294de 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -648,7 +648,6 @@ static void close_connections(void) } #endif end_thr_alarm(0); // Abort old alarms. - end_slave(); /* First signal all threads that it's time to die @@ -664,6 +663,9 @@ static void close_connections(void) { DBUG_PRINT("quit",("Informing thread %ld that it's time to die", tmp->thread_id)); + /* We skip slave threads on this first loop through. */ + if (tmp->slave_thread) continue; + tmp->killed= 1; if (tmp->mysys_var) { @@ -680,6 +682,8 @@ static void close_connections(void) } (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list + end_slave(); + if (thread_count) sleep(2); // Give threads time to die From bea4fbb052d47a1f98d15e5ed7127f39a2e2db54 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Aug 2005 18:02:36 -0700 Subject: [PATCH 2/5] Rename rest() macro in my_list.h to list_rest(). (Bug #12327) include/my_list.h: Rename rest() macro to list_rest(). mysys/list.c: rest() renamed to list_rest(). mysys/thr_lock.c: rest() renamed to list_rest(). sql/sql_test.cc: rest() renamed to list_rest(). --- include/my_list.h | 2 +- mysys/list.c | 2 +- mysys/thr_lock.c | 3 ++- sql/sql_test.cc | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/my_list.h b/include/my_list.h index f786621e311..92598696fc4 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -36,7 +36,7 @@ extern void list_free(LIST *root,unsigned int free_data); extern unsigned int list_length(LIST *); extern int list_walk(LIST *,list_walk_action action,gptr argument); -#define rest(a) ((a)->next) +#define list_rest(a) ((a)->next) #define list_push(a,b) (a)=list_cons((b),(a)) #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } diff --git a/mysys/list.c b/mysys/list.c index 64fca10dc0b..480c1080a45 100644 --- a/mysys/list.c +++ b/mysys/list.c @@ -109,7 +109,7 @@ int list_walk(LIST *list, list_walk_action action, gptr argument) { if ((error = (*action)(list->data,argument))) return error; - list=rest(list); + list=list_rest(list); } return 0; } diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index dc4959f23c1..d6443539216 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -1127,7 +1127,8 @@ void thr_print_locks(void) pthread_mutex_lock(&THR_LOCK_lock); puts("Current locks:"); - for (list=thr_lock_thread_list ; list && count++ < MAX_THREADS ; list=rest(list)) + for (list= thr_lock_thread_list; list && count++ < MAX_THREADS; + list= list_rest(list)) { THR_LOCK *lock=(THR_LOCK*) list->data; VOID(pthread_mutex_lock(&lock->mutex)); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index d992c93f8fc..8af7903a910 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -271,7 +271,7 @@ static void display_table_locks(void) VOID(my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),open_cache.records + 20,50)); VOID(pthread_mutex_lock(&THR_LOCK_lock)); - for (list=thr_lock_thread_list ; list ; list=rest(list)) + for (list= thr_lock_thread_list; list; list= list_rest(list)) { THR_LOCK *lock=(THR_LOCK*) list->data; From c1a7cfb7d5553ec9d1d2e993e29287b501284129 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Aug 2005 18:32:17 -0700 Subject: [PATCH 3/5] Fix mysql_info() returning bad data in the results of a multi-statement query that mixed statements that do and do not return info. (Bug #11688) mysql-test/r/metadata.result: Add new results mysql-test/t/metadata.test: Add new regression test sql-common/client.c: Clear mysql->info in free_old_query() --- mysql-test/r/metadata.result | 11 +++++++++++ mysql-test/t/metadata.test | 12 ++++++++++++ sql-common/client.c | 5 +++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/metadata.result b/mysql-test/r/metadata.result index 8f25e6b7f4a..6297f9cdcb5 100644 --- a/mysql-test/r/metadata.result +++ b/mysql-test/r/metadata.result @@ -85,3 +85,14 @@ def aaa 1 1 8 20 1 N 32769 0 63 1 1 drop table t1; +create table t1 (i int); +insert into t1 values (1),(2),(3); +select * from t1 where i = 2; +drop table t1;// +affected rows: 0 +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +i +2 +affected rows: 1 +affected rows: 0 diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test index b4edd15f5ef..65338448555 100644 --- a/mysql-test/t/metadata.test +++ b/mysql-test/t/metadata.test @@ -49,4 +49,16 @@ drop table t1; --disable_metadata +# +# Bug #11688: Bad mysql_info() results in multi-results +# +--enable_info +delimiter //; +create table t1 (i int); +insert into t1 values (1),(2),(3); +select * from t1 where i = 2; +drop table t1;// +delimiter ;// +--disable_info + # End of 4.1 tests diff --git a/sql-common/client.c b/sql-common/client.c index 860db63c531..73e136f7366 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -713,8 +713,9 @@ void free_old_query(MYSQL *mysql) if (mysql->fields) free_root(&mysql->field_alloc,MYF(0)); init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */ - mysql->fields=0; - mysql->field_count=0; /* For API */ + mysql->fields= 0; + mysql->field_count= 0; /* For API */ + mysql->info= 0; DBUG_VOID_RETURN; } From 4d0fad0dc28e3aada165db75755cd962aace7172 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Aug 2005 11:44:25 -0700 Subject: [PATCH 4/5] Make sure to clean up temporary files in myisampack even when the -T option is used. (Bug #12235) myisam/myisampack.c: Clean up temporary files when -T was used. --- myisam/myisampack.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 88f38be3c54..405c69544e7 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -609,14 +609,22 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table) else error=my_rename(new_name,org_name,MYF(MY_WME)); if (!error) + { VOID(my_copystat(temp_name,org_name,MYF(MY_COPYTIME))); + if (tmp_dir[0]) + VOID(my_delete(new_name,MYF(MY_WME))); + } } } else { if (tmp_dir[0]) + { error=my_copy(new_name,org_name, MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_COPYTIME)); + if (!error) + VOID(my_delete(new_name,MYF(MY_WME))); + } else error=my_redel(org_name,new_name,MYF(MY_WME | MY_COPYTIME)); } From 1c847f790e9005593688753ad31b598a2d22d27f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Aug 2005 17:53:38 +0200 Subject: [PATCH 5/5] BUG#12542: Prevous patch was incorrect. This removed the patch. --- sql/sql_parse.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9129cf584f9..cd87b097038 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1975,16 +1975,11 @@ mysql_execute_command(THD *thd) /* Skip if we are in the slave thread, some table rules have been given and the table list says the query should not be replicated. - - Exceptions are: - - - SET: we always execute it (e.g., SET ONE_SHOT TIME_ZONE = 'XYZ') - - - DROP TEMPORARY TABLE IF EXISTS: we always execute it (otherwise we - have stale files on slave caused by exclusion of one tmp table). + Exception is DROP TEMPORARY TABLE IF EXISTS: we always execute it + (otherwise we have stale files on slave caused by exclusion of one tmp + table). */ - if (lex->sql_command != SQLCOM_SET_OPTION && - !(lex->sql_command == SQLCOM_DROP_TABLE && + if (!(lex->sql_command == SQLCOM_DROP_TABLE && lex->drop_temporary && lex->drop_if_exists) && all_tables_not_ok(thd,tables)) {