diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 842dfa28f88..b0175103840 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -327,7 +327,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/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)); } 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 diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index cb6c8397c5a..e9cdf962022 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -158,11 +158,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, @@ -201,9 +196,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"); @@ -344,14 +336,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; @@ -714,9 +698,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); @@ -746,9 +727,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'); @@ -836,8 +814,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); @@ -870,30 +846,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; @@ -1235,13 +1187,7 @@ 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; -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/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/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/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/innodb.test b/mysql-test/t/innodb.test index 509cae9c1dc..e46f5801418 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -48,7 +48,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; # @@ -86,7 +85,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; @@ -224,7 +222,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; # @@ -398,7 +395,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; # @@ -443,7 +439,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; # @@ -521,8 +516,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 @@ -560,14 +553,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; # @@ -830,9 +815,7 @@ 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; -explain select * from t1 where c between 1 and 10000; drop table t1,t2; # 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/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/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) 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)) 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 851c6ba4f02..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); } @@ -1710,8 +1716,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); @@ -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/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..697b5d8ffd6 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 @@ -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_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_parse.cc b/sql/sql_parse.cc index fef74262d22..f5ecb98b3be 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1160,7 +1160,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))) // 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); unregister_slave(thd,1,1); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ae9bd8b7727..8fb82798a45 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -522,6 +522,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) // for mysqlbinlog (mysqlbinlog.server_id==0) + { + pthread_mutex_unlock(log_lock); + goto end; + } if (!thd->killed) { /* Note that the following call unlocks lock_log */ @@ -611,6 +616,7 @@ Increase max_allowed_packet on master"; } } +end: end_io_cache(&log); (void)my_close(file, MYF(MY_WME)); @@ -621,7 +627,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); /* @@ -790,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) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 94beff074c5..b07dca91a20 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; @@ -2587,6 +2587,7 @@ insert: opt_ignore insert2 { set_lock_for_tables($3); + Lex->select= &Lex->select_lex; } insert_field_spec {} @@ -2602,6 +2603,7 @@ replace: replace_lock_option insert2 { set_lock_for_tables($3); + Lex->select= &Lex->select_lex; } insert_field_spec {} @@ -3685,7 +3687,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