From 00c557b9c4e77845e7dfefb4f01962d5f38ecd00 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 2 Jul 2003 13:03:59 +0300 Subject: [PATCH 01/11] sync0sync.c: Make execution with UNIV_SYNC_DEBUG faster --- innobase/sync/sync0sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c index 32615ce88ac..773b239189c 100644 --- a/innobase/sync/sync0sync.c +++ b/innobase/sync/sync0sync.c @@ -159,7 +159,7 @@ struct sync_thread_struct{ }; /* Number of slots reserved for each OS thread in the sync level array */ -#define SYNC_THREAD_N_LEVELS 10000 +#define SYNC_THREAD_N_LEVELS 250 struct sync_level_struct{ void* latch; /* pointer to a mutex or an rw-lock; NULL means that From 0ba742ed3be55ff062a73fdb86104925c7550d26 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 2 Jul 2003 13:15:45 +0300 Subject: [PATCH 02/11] innodb.test, innodb.result: Remove nondeterministic EXPLAIN SELECT which gives on 64-bit platforms a slightly different estimate (sometimes we should study why we get different results on 64-bit and 32-bit) --- mysql-test/r/innodb.result | 3 --- mysql-test/t/innodb.test | 1 - 2 files changed, 4 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 465d4faf0bc..bb237e2e406 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1238,9 +1238,6 @@ explain select * from t1 where c between 1 and 10000; table type possible_keys key key_len ref rows Extra t1 range c c 5 NULL 1 Using where update t1 set c=a; -explain select * from t1 where c between 1 and 10000; -table type possible_keys key key_len ref rows Extra -t1 ALL c NULL NULL NULL 27682 Using where drop table t1,t2; create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb; insert into t1 (id) values (null),(null),(null),(null),(null); diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index cf203d87c8b..05b4370d0e0 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -830,7 +830,6 @@ insert into t1 (a) select b from t2; select count(*) from t1; explain select * from t1 where c between 1 and 10000; update t1 set c=a; -explain select * from t1 where c between 1 and 10000; drop table t1,t2; # From 1df6492c7d5036e0553191d8da86df7db220a70c Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 2 Jul 2003 14:57:40 +0300 Subject: [PATCH 03/11] Fix for a problem with : CREATE / INSERT ... (SELECT ...) UNION (SELECT ...) LIMIT; --- mysql-test/r/union.result | 12 ++---------- mysql-test/t/union.test | 4 ++-- sql/sql_yacc.yy | 4 +++- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 2072b045563..51d9f2d17ca 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -271,9 +271,9 @@ insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); CREATE TABLE t2 (a int not null, b char (10) not null); insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); create table t3 select a,b from t1 union select a,b from t2; -create table t4 (select a,b from t1) union (select a,b from t2); +create table t4 (select a,b from t1) union (select a,b from t2) limit 2; insert into t4 select a,b from t1 union select a,b from t2; -insert into t3 (select a,b from t1) union (select a,b from t2); +insert into t3 (select a,b from t1) union (select a,b from t2) limit 2; select * from t3; a b 1 a @@ -284,18 +284,10 @@ a b 6 e 1 a 2 b -3 c -4 d -5 f -6 e select * from t4; a b 1 a 2 b -3 c -4 d -5 f -6 e 1 a 2 b 3 c diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index dcf2f79e5bf..5f7eba83755 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -164,9 +164,9 @@ insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); CREATE TABLE t2 (a int not null, b char (10) not null); insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e'); create table t3 select a,b from t1 union select a,b from t2; -create table t4 (select a,b from t1) union (select a,b from t2); +create table t4 (select a,b from t1) union (select a,b from t2) limit 2; insert into t4 select a,b from t1 union select a,b from t2; -insert into t3 (select a,b from t1) union (select a,b from t2); +insert into t3 (select a,b from t1) union (select a,b from t2) limit 2; select * from t3; select * from t4; drop table t1,t2,t3,t4; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cf580b3f3df..cf94532ac86 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -762,7 +762,7 @@ create: lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type; } create2 - {} + {Lex->select= &Lex->select_lex;} | CREATE opt_unique_or_fulltext INDEX ident ON table_ident { LEX *lex=Lex; @@ -2585,6 +2585,7 @@ insert: opt_ignore insert2 { set_lock_for_tables($3); + Lex->select= &Lex->select_lex; } insert_field_spec {} @@ -2600,6 +2601,7 @@ replace: replace_lock_option insert2 { set_lock_for_tables($3); + Lex->select= &Lex->select_lex; } insert_field_spec {} From dcd13cf264ee07f2b7014bc1fdedd7de98689400 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Wed, 2 Jul 2003 17:12:50 +0200 Subject: [PATCH 04/11] bug #504: in "datetime op int" comparison int wasn't converted to datetime --- mysql-test/r/type_datetime.result | 9 ++++++++- mysql-test/t/type_datetime.test | 5 ++++- sql/item_cmpfunc.cc | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 4785f790069..5df4f355cfb 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -52,10 +52,17 @@ a 0000-00-00 00:00:00 drop table t1; create table t1 (id int, dt datetime); -insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"); +insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30"); select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15'); id dt 1 2001-08-14 00:00:00 +create index dt on t1 (dt); +select * from t1 where dt > 20021020; +id dt +4 2003-09-15 01:20:30 +select * from t1 ignore index (dt) where dt > 20021020; +id dt +4 2003-09-15 01:20:30 drop table t1; CREATE TABLE `t1` ( `date` datetime NOT NULL default '0000-00-00 00:00:00', diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index f5103958979..51b65d00243 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -36,8 +36,11 @@ drop table t1; # create table t1 (id int, dt datetime); -insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"); +insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30"); select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15'); +create index dt on t1 (dt); +select * from t1 where dt > 20021020; +select * from t1 ignore index (dt) where dt > 20021020; drop table t1; # diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 78a63d84c61..5d47fa302f3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -46,7 +46,7 @@ longlong Item_func_not::val_int() static bool convert_constant_item(Field *field, Item **item) { - if ((*item)->const_item() && (*item)->type() != Item::INT_ITEM) + if ((*item)->const_item()) { if (!(*item)->save_in_field(field, 1) && !((*item)->null_value)) From 55e046a807d3dc27420b18f5939cc0b96271b21a Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Wed, 2 Jul 2003 16:56:27 -0400 Subject: [PATCH 05/11] fixed bug #672 --- client/mysqlbinlog.cc | 2 +- sql/sql_parse.cc | 3 ++- sql/sql_repl.cc | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 75b875b4f4e..109e9095b7a 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -360,7 +360,7 @@ static void dump_remote_log_entries(const char* logname) len = net_safe_read(mysql); if (len == packet_error) die("Error reading packet from server: %s", mysql_error(mysql)); - if (len == 1 && net->read_pos[0] == 254) + if (len < 8 && net->read_pos[0] == 254) break; // end of data DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n", len, net->read_pos[5])); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d9060b4b26e..233644feb4e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1147,7 +1147,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, pos = uint4korr(packet); flags = uint2korr(packet + 4); thd->server_id=0; /* avoid suicide */ - kill_zombie_dump_threads(slave_server_id = uint4korr(packet+6)); + if ((slave_server_id= uint4korr(packet+6))) + kill_zombie_dump_threads(slave_server_id); thd->server_id = slave_server_id; mysql_binlog_send(thd, thd->strdup(packet + 10), (my_off_t) pos, flags); unregister_slave(thd,1,1); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 283dd20a56c..bc833d7e759 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -503,6 +503,11 @@ Increase max_allowed_packet on master"; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data in binary log")); + if (thd->server_id==0) + { + pthread_mutex_unlock(log_lock); + goto end; + } if (!thd->killed) { /* Note that the following call unlocks lock_log */ @@ -590,6 +595,7 @@ Increase max_allowed_packet on master"; } } +end: end_io_cache(&log); (void)my_close(file, MYF(MY_WME)); @@ -600,7 +606,7 @@ Increase max_allowed_packet on master"; pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; - err: +err: thd->proc_info = "waiting to finalize termination"; end_io_cache(&log); /* From 6bbe7b80758e66d3c162a900bafbe4ea2c090d11 Mon Sep 17 00:00:00 2001 From: "vva@eagle.mysql.r18.ru" <> Date: Wed, 2 Jul 2003 19:08:31 -0400 Subject: [PATCH 06/11] add comment for BUG 672 --- sql/sql_parse.cc | 2 +- sql/sql_repl.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b2e1e56dc8f..c5b08c6121a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1160,7 +1160,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, pos = uint4korr(packet); flags = uint2korr(packet + 4); thd->server_id=0; /* avoid suicide */ - if ((slave_server_id= uint4korr(packet+6))) + if ((slave_server_id= uint4korr(packet+6))) // mysqlbinlog.server_id==0 kill_zombie_dump_threads(slave_server_id); thd->server_id = slave_server_id; mysql_binlog_send(thd, thd->strdup(packet + 10), (my_off_t) pos, flags); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 12228ec3ac8..bf4b1eb0c70 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -522,7 +522,7 @@ Increase max_allowed_packet on master"; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data in binary log")); - if (thd->server_id==0) + if (thd->server_id==0) // for mysqlbinlog (mysqlbinlog.server_id==0) { pthread_mutex_unlock(log_lock); goto end; From 7f4fe0b0f3e1b1d8c862fb2be6d41f3635cf6bd9 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 3 Jul 2003 02:08:33 +0300 Subject: [PATCH 07/11] innodb.result, innodb.test: Remove all nondeterministic tests from innodb.test; but I have to study why on 64 bits we get different estimates --- mysql-test/r/innodb.result | 51 -------------------------------------- mysql-test/t/innodb.test | 16 ------------ 2 files changed, 67 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index bb237e2e406..6ab55bbf924 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -157,11 +157,6 @@ level id parent_id optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 id A 87 NULL NULL BTREE -t1 1 parent_id 1 parent_id A 43 NULL NULL BTREE -t1 1 level 1 level A 6 NULL NULL BTREE drop table t1; CREATE TABLE t1 ( gesuchnr int(11) DEFAULT '0' NOT NULL, @@ -200,9 +195,6 @@ insert into t1 values (3,""), (4,"testing"); analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 1 skr 1 a A 3 NULL NULL YES BTREE drop table t1; create table t1 (a int,b varchar(20),key(a)) type=innodb; insert into t1 values (1,""), (2,"testing"); @@ -343,14 +335,6 @@ user_id name phone ref_email detail drop table t1; CREATE TABLE t1 (a int not null, b int not null,c int not null, key(a),primary key(a,b), unique(c),key(a),unique(b)); -show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A NULL NULL NULL BTREE -t1 0 PRIMARY 2 b A 0 NULL NULL BTREE -t1 0 c 1 c A 0 NULL NULL BTREE -t1 0 b 1 b A 0 NULL NULL BTREE -t1 1 a 1 a A NULL NULL NULL BTREE -t1 1 a_2 1 a A NULL NULL NULL BTREE drop table t1; create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); alter table t1 type=innodb; @@ -713,9 +697,6 @@ hello 1 optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK -show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 a A 2 NULL NULL BTREE drop table t1; create table t1 (i int, j int ) TYPE=innodb; insert into t1 values (1,2); @@ -745,9 +726,6 @@ a DROP TABLE t1; create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb; insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -explain select * from t1 where a > 0 and a < 50; -table type possible_keys key key_len ref rows Extra -t1 range PRIMARY PRIMARY 4 NULL 1 Using where drop table t1; create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb; insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL'); @@ -835,8 +813,6 @@ create table mysqltest.t3 (a int not null) type= heap; insert into mysqltest.t3 values(1); commit; drop database mysqltest; -show tables from mysqltest; -Got one of the listed errors set autocommit=0; create table t1 (a int not null) type= innodb; insert into t1 values(1),(2); @@ -869,30 +845,6 @@ a drop table t1; create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb; insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); -explain select * from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 4 -explain select * from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 -explain select * from t1 order by c; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 Using filesort -explain select a from t1 order by a; -table type possible_keys key key_len ref rows Extra -t1 index NULL PRIMARY 4 NULL 4 Using index -explain select b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index -explain select a,b from t1 order by b; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index -explain select a,b from t1; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 4 Using index -explain select a,b,c from t1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 4 drop table t1; create table t1 (t int not null default 1, key (t)) type=innodb; desc t1; @@ -1234,9 +1186,6 @@ insert into t1 (a) select b from t2; select count(*) from t1; count(*) 29267 -explain select * from t1 where c between 1 and 10000; -table type possible_keys key key_len ref rows Extra -t1 range c c 5 NULL 1 Using where update t1 set c=a; drop table t1,t2; create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 05b4370d0e0..7b36a675a31 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -46,7 +46,6 @@ select * from t1 where parent_id=102; select level,id from t1 where level=1; select level,id,parent_id from t1 where level=1; optimize table t1; -show keys from t1; drop table t1; # @@ -84,7 +83,6 @@ select * from t1; create index skr on t1 (a); insert into t1 values (3,""), (4,"testing"); analyze table t1; -show keys from t1; drop table t1; @@ -222,7 +220,6 @@ drop table t1; CREATE TABLE t1 (a int not null, b int not null,c int not null, key(a),primary key(a,b), unique(c),key(a),unique(b)); -show index from t1; drop table t1; # @@ -396,7 +393,6 @@ create table t1 (a varchar(100) not null, primary key(a), b int not null) type=i insert into t1 values("hello",1),("world",2); select * from t1 order by b desc; optimize table t1; -show keys from t1; drop table t1; # @@ -441,7 +437,6 @@ DROP TABLE t1; create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb; insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); -explain select * from t1 where a > 0 and a < 50; drop table t1; # @@ -519,8 +514,6 @@ insert into mysqltest.t3 values(1); commit; drop database mysqltest; # Don't check error message ---error 12,12 -show tables from mysqltest; # # Test truncate table with and without auto_commit @@ -558,14 +551,6 @@ drop table t1; create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb; insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); -explain select * from t1 order by a; -explain select * from t1 order by b; -explain select * from t1 order by c; -explain select a from t1 order by a; -explain select b from t1 order by b; -explain select a,b from t1 order by b; -explain select a,b from t1; -explain select a,b,c from t1; drop table t1; # @@ -828,7 +813,6 @@ insert into t1 (a) select b from t2; insert into t2 (a) select b from t1; insert into t1 (a) select b from t2; select count(*) from t1; -explain select * from t1 where c between 1 and 10000; update t1 set c=a; drop table t1,t2; From b3f153507e6503c17db0579105c3b92d2fc0bceb Mon Sep 17 00:00:00 2001 From: "pem@mysql.com" <> Date: Thu, 3 Jul 2003 01:08:34 +0200 Subject: [PATCH 08/11] Added missing (char*) casts in bzero calls. (Needed for platforms with the traditional bzero prototype.) Fixes BUG#460. --- sql/slave.cc | 4 ++-- sql/slave.h | 2 +- sql/sql_acl.cc | 4 ++-- sql/sql_lex.cc | 2 +- sql/sql_yacc.yy | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 851c6ba4f02..bc9528ae2c7 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1710,8 +1710,8 @@ st_relay_log_info::st_relay_log_info() last_slave_error[0]=0; - bzero(&info_file,sizeof(info_file)); - bzero(&cache_buf, sizeof(cache_buf)); + bzero((char *)&info_file,sizeof(info_file)); + bzero((char *)&cache_buf, sizeof(cache_buf)); pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&log_space_lock, MY_MUTEX_INIT_FAST); diff --git a/sql/slave.h b/sql/slave.h index 66000f45e69..6a73c86d304 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -282,7 +282,7 @@ typedef struct st_master_info abort_slave(0),slave_running(0), slave_run_id(0) { host[0] = 0; user[0] = 0; password[0] = 0; - bzero(&file, sizeof(file)); + bzero((char *)&file, sizeof(file)); pthread_mutex_init(&run_lock, MY_MUTEX_INIT_FAST); pthread_mutex_init(&data_lock, MY_MUTEX_INIT_FAST); pthread_cond_init(&data_cond, NULL); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 90497cc8b43..225d84f4751 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -275,7 +275,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) else { user.ssl_type=SSL_TYPE_NONE; - bzero(&(user.user_resource),sizeof(user.user_resource)); + bzero((char *)&(user.user_resource),sizeof(user.user_resource)); #ifndef TO_BE_REMOVED if (table->fields <= 13) { // Without grant @@ -506,7 +506,7 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, *priv_user=(char*) user; DBUG_ENTER("acl_getroot"); - bzero(mqh,sizeof(USER_RESOURCES)); + bzero((char *)mqh,sizeof(USER_RESOURCES)); if (!initialized) { // If no data allow anything diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d5a225d95dd..d62edf83c11 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -152,7 +152,7 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) lex->ignore_space=test(thd->sql_mode & MODE_IGNORE_SPACE); lex->slave_thd_opt=0; lex->sql_command=SQLCOM_END; - bzero(&lex->mi,sizeof(lex->mi)); + bzero((char *)&lex->mi,sizeof(lex->mi)); return lex; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index cf94532ac86..4022dd89797 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3685,7 +3685,7 @@ grant: lex->select->db= 0; lex->ssl_type= SSL_TYPE_NOT_SPECIFIED; lex->ssl_cipher= lex->x509_subject= lex->x509_issuer= 0; - bzero(&(lex->mqh),sizeof(lex->mqh)); + bzero((char *)&(lex->mqh),sizeof(lex->mqh)); } grant_privileges ON opt_table TO_SYM user_list require_clause grant_options From ace8a06323af77401cc5bcdc8b17043fc6081b66 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Thu, 3 Jul 2003 01:08:36 +0200 Subject: [PATCH 09/11] I committed the same changeset in my tree yesterday, but broke the tree since, so I commit again in a fresh tree. Fix for bug#763 (Relay_log_space too big by 4 bytes), plus comments and DBUG_PRINT, and we don't start replication if --bootstrap. --- mysql-test/r/rpl_log.result | 2 +- mysql-test/r/rpl_log_pos.result | 2 +- sql/mysqld.cc | 2 ++ sql/slave.cc | 27 +++++++++++++++++++++++++-- sql/sql_acl.cc | 2 +- sql/sql_repl.cc | 19 +++++++++++++++++++ 6 files changed, 49 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 316bf1f3dd0..616ad319880 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -93,6 +93,6 @@ slave-bin.002 62 Query 1 168 use test; insert into t1 values (1) slave-bin.002 122 Query 1 228 use test; drop table t1 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.002 276 slave-relay-bin.002 1563 master-bin.002 Yes Yes 0 0 276 1567 +127.0.0.1 root MASTER_PORT 1 master-bin.002 276 slave-relay-bin.002 1563 master-bin.002 Yes Yes 0 0 276 1563 show binlog events in 'slave-bin.005' from 4; Error when executing command SHOW BINLOG EVENTS: Could not find target log diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index 3224e84fa31..f7e59e55577 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -9,7 +9,7 @@ File Position Binlog_do_db Binlog_ignore_db master-bin.001 79 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 124 +127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 120 slave stop; change master to master_log_pos=73; slave start; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f27ba435729..4f6f55bce0b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2293,6 +2293,8 @@ int main(int argc, char **argv) if (!opt_noacl) udf_init(); #endif + if (opt_bootstrap) /* If running with bootstrap, do not start replication. */ + opt_skip_slave_start= 1; /* init_slave() must be called after the thread keys are created */ init_slave(); diff --git a/sql/slave.cc b/sql/slave.cc index bc9528ae2c7..aa9dd14b1c7 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1424,6 +1424,12 @@ static int count_relay_log_space(RELAY_LOG_INFO* rli) if (add_relay_log(rli,&linfo)) DBUG_RETURN(1); } while (!rli->relay_log.find_next_log(&linfo, 1)); + /* + As we have counted everything, including what may have written in a + preceding write, we must reset bytes_written, or we may count some space + twice. + */ + rli->relay_log.reset_bytes_written(); DBUG_RETURN(0); } @@ -3213,8 +3219,25 @@ Log_event* next_event(RELAY_LOG_INFO* rli) hot_log=0; // Using old binary log } } - DBUG_ASSERT(my_b_tell(cur_log) >= BIN_LOG_HEADER_SIZE); - DBUG_ASSERT(my_b_tell(cur_log) == rli->relay_log_pos + rli->pending); +#ifndef DBUG_OFF + { + DBUG_ASSERT(my_b_tell(cur_log) >= BIN_LOG_HEADER_SIZE); + /* The next assertion sometimes (very rarely) fails, let's try to track it */ + char llbuf1[22], llbuf2[22]; + /* Merging man, please be careful with this; in 4.1, the assertion below is + replaced by + DBUG_ASSERT(my_b_tell(cur_log) == rli->event_relay_log_pos); + so you should not merge blindly (fortunately it won't build then), and + instead modify the merged code. Thanks. */ + DBUG_PRINT("info", ("Before assert, my_b_tell(cur_log)=%s \ +rli->relay_log_pos=%s rli->pending=%lu", + llstr(my_b_tell(cur_log),llbuf1), + llstr(rli->relay_log_pos,llbuf2), + rli->pending)); + DBUG_ASSERT(my_b_tell(cur_log) == rli->relay_log_pos + rli->pending); + } +#endif + /* Relay log is always in new format - if the master is 3.23, the I/O thread will convert the format for us diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 225d84f4751..697b5d8ffd6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2250,7 +2250,7 @@ int mysql_grant (THD *thd, const char *db, List &list, if (!initialized) { send_error(&(thd->net), ER_UNKNOWN_COM_ERROR); /* purecov: tested */ - return 1; /* purecov: tested */ + DBUG_RETURN(1); /* purecov: tested */ } if (lower_case_table_names && db) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index bf4b1eb0c70..8fb82798a45 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -796,6 +796,25 @@ err: DBUG_RETURN(error); } +/* + + Kill all Binlog_dump threads which previously talked to the same slave + ("same" means with the same server id). Indeed, if the slave stops, if the + Binlog_dump thread is waiting (pthread_cond_wait) for binlog update, then it + will keep existing until a query is written to the binlog. If the master is + idle, then this could last long, and if the slave reconnects, we could have 2 + Binlog_dump threads in SHOW PROCESSLIST, until a query is written to the + binlog. To avoid this, when the slave reconnects and sends COM_BINLOG_DUMP, + the master kills any existing thread with the slave's server id (if this id is + not zero; it will be true for real slaves, but false for mysqlbinlog when it + sends COM_BINLOG_DUMP to get a remote binlog dump). + + SYNOPSIS + kill_zombie_dump_threads() + slave_server_id the slave's server id + +*/ + void kill_zombie_dump_threads(uint32 slave_server_id) { From 7fd579148dc2568187add8e3edab24bc56116b4b Mon Sep 17 00:00:00 2001 From: "miguel@hegel.(none)" <> Date: Wed, 2 Jul 2003 20:34:19 -0400 Subject: [PATCH 10/11] Fix VC++ compiler error on Windows --- mysys/thr_alarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 2a16eeec215..2289f8208bc 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -718,7 +718,7 @@ sig_handler process_alarm(int sig __attribute__((unused))) } -bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm) +my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm) { (*alrm)= &alarm->alarmed; if (alarm_aborted) From 67b6ba21c3d9dbbdab29a254b7497c14d9f82a6d Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Thu, 3 Jul 2003 03:34:20 +0300 Subject: [PATCH 11/11] lock0lock.c: Remove outdated comment and the corresponding assertion in debug version code --- innobase/lock/lock0lock.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index 397a8158bee..3f9b5316185 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -83,10 +83,6 @@ x-lock also has an explicit non-gap record x-lock. Therefore, as locks are released, we can grant locks to waiting lock requests purely by looking at the explicit lock requests in the queue. -RULE 2: Granted non-gap locks on a record are always ahead in the queue -------- -of waiting non-gap locks on a record. - RULE 3: Different transactions cannot have conflicting granted non-gap locks ------- on a record at the same time. However, they can have conflicting granted gap @@ -4271,7 +4267,6 @@ lock_rec_queue_validate( { trx_t* impl_trx; lock_t* lock; - ibool is_waiting; ut_a(rec); @@ -4332,8 +4327,6 @@ lock_rec_queue_validate( } } - is_waiting = FALSE; - lock = lock_rec_get_first(rec); while (lock) { @@ -4346,8 +4339,6 @@ lock_rec_queue_validate( } if (!lock_rec_get_gap(lock) && !lock_get_wait(lock)) { - - ut_a(!is_waiting); if (lock_get_mode(lock) == LOCK_S) { ut_a(!lock_rec_other_has_expl_req(LOCK_X, @@ -4359,7 +4350,6 @@ lock_rec_queue_validate( } else if (lock_get_wait(lock) && !lock_rec_get_gap(lock)) { - is_waiting = TRUE; ut_a(lock_rec_has_to_wait_in_queue(lock)); }