From 73ec339dbdb0134d687bedc2123e9b2ed2dc9573 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Jul 2005 17:34:20 +0500 Subject: [PATCH 1/7] Fix for bug #12177 (error file isn't closed) libmysqld/lib_sql.cc: now errorlog is closed during mysql_server_end --- libmysqld/lib_sql.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 0ec7d161f24..4b05dd70e35 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -320,7 +320,8 @@ extern "C" static my_bool org_my_init_done; my_bool server_inited; -char ** copy_arguments_ptr= 0; +char ** copy_arguments_ptr= 0; +static FILE *errorlog_file=0; int STDCALL mysql_server_init(int argc, char **argv, char **groups) { @@ -421,7 +422,7 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups) opt_error_log= 1; // Too long file name else { - freopen(log_error_file, "a+", stderr); + errorlog_file= freopen(log_error_file, "a+", stderr); } } @@ -626,6 +627,8 @@ void STDCALL mysql_server_end() my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR)); copy_arguments_ptr=0; clean_up(0); + if (errorlog_file) + fclose(errorlog_file); /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) my_end(0); From 153353fd29d94e2c466fea54643323c2c25d049b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Jul 2005 19:39:59 +0500 Subject: [PATCH 2/7] addition to the fix for bug #12177(error log file isn't closed) libmysqld/lib_sql.cc: we should set errorlog_file=0 to make consequent mysql_server_init work properly --- libmysqld/lib_sql.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 4b05dd70e35..b71b442b4ca 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -628,7 +628,10 @@ void STDCALL mysql_server_end() copy_arguments_ptr=0; clean_up(0); if (errorlog_file) + { fclose(errorlog_file); + errorlog_file=0; + } /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) my_end(0); From b863330d43334f70bfd2720a0e7b09d584d09994 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Jul 2005 21:54:02 +0500 Subject: [PATCH 3/7] Fix for bug #11083 (myisam test fails witout-geometry) mysql-test/r/myisam.result: test result fixed mysql-test/t/myisam.test: we can get two kings of errors here --- mysql-test/r/myisam.result | 2 +- mysql-test/t/myisam.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 4def82e5752..38273c01a98 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -499,7 +499,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL PRIMARY 4 NULL 2 Using index; Distinct drop table t1,t2; CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM; -ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX' +Got one of the listed errors create table t1 (a int, b varchar(200), c text not null) checksum=1; create table t2 (a int, b varchar(200), c text not null) checksum=0; insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 7d7985fd8ac..928ed194ebd 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -476,7 +476,7 @@ drop table t1,t2; # # Test RTREE index # ---error 1235 +--error 1235, 1289 CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM; # INSERT INTO t1 VALUES (1,1),(1,1); # DELETE FROM rt WHERE a<1; From 7e7bd6a43561dd8d3343935e1744ee9452eef084 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 17:18:24 +0500 Subject: [PATCH 4/7] Additional fix for #12177 (stderr isn't closed) libmysqld/lib_sql.cc: my_end() needs stderr to be active --- libmysqld/lib_sql.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index b71b442b4ca..d607e1dcf43 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -627,14 +627,14 @@ void STDCALL mysql_server_end() my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR)); copy_arguments_ptr=0; clean_up(0); + /* If library called my_init(), free memory allocated by it */ + if (!org_my_init_done) + my_end(0); if (errorlog_file) { fclose(errorlog_file); errorlog_file=0; } - /* If library called my_init(), free memory allocated by it */ - if (!org_my_init_done) - my_end(0); } my_bool STDCALL mysql_thread_init() From e0010838fd1b64e0d99ae78d6bc81a3d8509118c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Jul 2005 19:25:48 +0500 Subject: [PATCH 5/7] Fix for bug #10226 (mysql_get_client_version not implemented) libmysqld/libmysqld.c: mysql_get_client_version implementation added --- libmysqld/libmysqld.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 9c79536b2e0..aa8932f798b 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -1795,6 +1795,10 @@ mysql_get_client_info(void) return MYSQL_SERVER_VERSION; } +ulong STDCALL mysql_get_client_version(void) +{ + return MYSQL_VERSION_ID; +} int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) From 6d63bc0eedab9292535e78840f29a39186545593 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Jul 2005 17:14:21 +0500 Subject: [PATCH 6/7] Fix for bug #9508 (query_cache test fails) notembedded-specific part moved to the new test mysql-test/r/query_cache.result: test result fixed mysql-test/t/query_cache.test: notembedded-only part of the test removed --- mysql-test/r/query_cache.result | 76 ------------------- mysql-test/r/query_cache_notembedded.result | 83 +++++++++++++++++++++ mysql-test/t/query_cache.test | 62 --------------- mysql-test/t/query_cache_notembedded.test | 81 ++++++++++++++++++++ 4 files changed, 164 insertions(+), 138 deletions(-) create mode 100644 mysql-test/r/query_cache_notembedded.result create mode 100644 mysql-test/t/query_cache_notembedded.test diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 2884b9b3fe4..13ba2f3b0ca 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -152,82 +152,6 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 drop table t1, t2, t3; -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -select * from t1; -a -1 -2 -3 -select * from t2; -a -1 -2 -3 -insert into t1 values (4); -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 2 -flush query cache; -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -drop table t1, t2; -create table t1 (a text not null); -create table t11 (a text not null); -create table t2 (a text not null); -create table t21 (a text not null); -create table t3 (a text not null); -insert into t1 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t11 select * from t1; -insert into t21 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t3 select * from t1; -insert into t3 select * from t2; -insert into t3 select * from t1; -select * from t11; -select * from t21; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 7 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -insert into t11 values(""); -select * from t3; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 8 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -flush query cache; -show status like "Qcache_total_blocks"; -Variable_name Value -Qcache_total_blocks 7 -show status like "Qcache_free_blocks"; -Variable_name Value -Qcache_free_blocks 1 -drop table t1, t2, t3, t11, t21; set query_cache_type=demand; create table t1 (a int not null); insert into t1 values (1),(2),(3); diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result new file mode 100644 index 00000000000..16a397f78b6 --- /dev/null +++ b/mysql-test/r/query_cache_notembedded.result @@ -0,0 +1,83 @@ +set GLOBAL query_cache_size=1355776; +flush query cache; +flush query cache; +reset query cache; +flush status; +drop table if exists t1, t2, t3, t11, t21; +create table t1 (a int not null); +insert into t1 values (1),(2),(3); +create table t2 (a int not null); +insert into t2 values (1),(2),(3); +select * from t1; +a +1 +2 +3 +select * from t2; +a +1 +2 +3 +insert into t1 values (4); +show status like "Qcache_free_blocks"; +Variable_name Value +Qcache_free_blocks 2 +flush query cache; +show status like "Qcache_free_blocks"; +Variable_name Value +Qcache_free_blocks 1 +drop table t1, t2; +create table t1 (a text not null); +create table t11 (a text not null); +create table t2 (a text not null); +create table t21 (a text not null); +create table t3 (a text not null); +insert into t1 values("1111111111111111111111111111111111111111111111111111"); +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t11 select * from t1; +insert into t21 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t3 select * from t1; +insert into t3 select * from t2; +insert into t3 select * from t1; +select * from t11; +select * from t21; +show status like "Qcache_total_blocks"; +Variable_name Value +Qcache_total_blocks 7 +show status like "Qcache_free_blocks"; +Variable_name Value +Qcache_free_blocks 1 +insert into t11 values(""); +select * from t3; +show status like "Qcache_total_blocks"; +Variable_name Value +Qcache_total_blocks 8 +show status like "Qcache_free_blocks"; +Variable_name Value +Qcache_free_blocks 1 +flush query cache; +show status like "Qcache_total_blocks"; +Variable_name Value +Qcache_total_blocks 7 +show status like "Qcache_free_blocks"; +Variable_name Value +Qcache_free_blocks 1 +drop table t1, t2, t3, t11, t21; +set GLOBAL query_cache_size=0; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index b44c517acb9..4c2711ae833 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -79,68 +79,6 @@ delete from t3 where a=10; show status like "Qcache_queries_in_cache"; drop table t1, t2, t3; # -# FLUSH QUERY CACHE -# -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -select * from t1; -select * from t2; -insert into t1 values (4); -show status like "Qcache_free_blocks"; -flush query cache; -show status like "Qcache_free_blocks"; -drop table t1, t2; -# With join results... -create table t1 (a text not null); -create table t11 (a text not null); -create table t2 (a text not null); -create table t21 (a text not null); -create table t3 (a text not null); -insert into t1 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -# t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE) -insert into t11 select * from t1; -insert into t21 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -#results of t3 must be > 0.5Mb -insert into t3 select * from t1; -insert into t3 select * from t2; -insert into t3 select * from t1; -disable_result_log; -select * from t11; -select * from t21; -enable_result_log; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -disable_result_log; -insert into t11 values(""); -select * from t3; -enable_result_log; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -flush query cache; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -drop table t1, t2, t3, t11, t21; -# # SELECT SQL_CACHE ... # set query_cache_type=demand; diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test new file mode 100644 index 00000000000..d29dc10ccae --- /dev/null +++ b/mysql-test/t/query_cache_notembedded.test @@ -0,0 +1,81 @@ +-- source include/have_query_cache.inc +-- source include/not_embedded.inc + +# +# Tests with query cache +# +set GLOBAL query_cache_size=1355776; + +# Reset query cache variables. + +flush query cache; # This crashed in some versions +flush query cache; # This crashed in some versions +reset query cache; +flush status; +--disable_warnings +drop table if exists t1, t2, t3, t11, t21; +--enable_warnings +# +# FLUSH QUERY CACHE +# +create table t1 (a int not null); +insert into t1 values (1),(2),(3); +create table t2 (a int not null); +insert into t2 values (1),(2),(3); +select * from t1; +select * from t2; +insert into t1 values (4); +show status like "Qcache_free_blocks"; +flush query cache; +show status like "Qcache_free_blocks"; +drop table t1, t2; +# With join results... +create table t1 (a text not null); +create table t11 (a text not null); +create table t2 (a text not null); +create table t21 (a text not null); +create table t3 (a text not null); +insert into t1 values("1111111111111111111111111111111111111111111111111111"); +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +# t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE) +insert into t11 select * from t1; +insert into t21 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +#results of t3 must be > 0.5Mb +insert into t3 select * from t1; +insert into t3 select * from t2; +insert into t3 select * from t1; +disable_result_log; +select * from t11; +select * from t21; +enable_result_log; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +disable_result_log; +insert into t11 values(""); +select * from t3; +enable_result_log; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +flush query cache; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +drop table t1, t2, t3, t11, t21; + +set GLOBAL query_cache_size=0; From 36a2a092ab7ab26d5e90f73003a48db8e313df2f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Aug 2005 15:23:21 +0500 Subject: [PATCH 7/7] Fix for bug #12177 (errorlog file isn't closed) 4.1 version of the patch libmysql/libmysql.c: here we close errorlog file sql/mysql_priv.h: stderror_file declared sql/mysqld.cc: stderror_file saved --- libmysql/libmysql.c | 7 +++++++ sql/mysql_priv.h | 1 + sql/mysqld.cc | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index e5681edd3d8..7c6d140d2ef 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -188,6 +188,13 @@ void STDCALL mysql_server_end() mysql_thread_end(); free_charsets(); mysql_client_init= org_my_init_done= 0; +#ifdef EMBEDDED_SERVER + if (stderror_file) + { + fclose(stderror_file); + stderror_file= 0; + } +#endif } static MYSQL_PARAMETERS mysql_internal_parameters= diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6969433649f..c8a4c4740ef 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -941,6 +941,7 @@ extern char *default_tz_name; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern FILE *bootstrap_file; +extern FILE *stderror_file; extern pthread_key(MEM_ROOT**,THR_MALLOC); extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6bbd6f79aa2..9177703599c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -382,6 +382,7 @@ Le_creator le_creator; FILE *bootstrap_file; +FILE *stderror_file=0; I_List replicate_rewrite_db; I_List replicate_do_db, replicate_ignore_db; @@ -2767,7 +2768,7 @@ server."); #ifndef EMBEDDED_LIBRARY if (freopen(log_error_file, "a+", stdout)) #endif - freopen(log_error_file, "a+", stderr); + stderror_file= freopen(log_error_file, "a+", stderr); } }