From 9740e4b5712c63ff6f355ab3d6dd4532b6f234b4 Mon Sep 17 00:00:00 2001 From: Serge Kozlov Date: Sun, 26 Oct 2008 21:53:21 +0300 Subject: [PATCH 1/3] Bug#22442. 1. Replace --sleep by wait_* primitive 2. Vertical output for SHOW SLAVE STATUS 3. Updated result file --- mysql-test/r/rpl_flush_log_loop.result | 35 ++++++++++++++++++++++++-- mysql-test/t/rpl_flush_log_loop.test | 19 +++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index 3b1db804da9..271e37247d4 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -20,5 +20,36 @@ master_password='',master_port=SLAVE_PORT; start slave; flush logs; show slave status; -Slave_IO_State 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 Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 208 # # slave-bin.000001 Yes Yes 0 0 208 # None 0 No # +Slave_IO_State # +Master_Host 127.0.0.1 +Master_User root +Master_Port 9306 +Connect_Retry 1 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos 98 +Relay_Log_File # +Relay_Log_Pos # +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table # +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos 98 +Relay_Log_Space # +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master # diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test index f0b368c285b..0092ec3875e 100644 --- a/mysql-test/t/rpl_flush_log_loop.test +++ b/mysql-test/t/rpl_flush_log_loop.test @@ -12,16 +12,27 @@ stop slave; eval change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=$MASTER_MYPORT; start slave; + connection master; --replace_result $SLAVE_MYPORT SLAVE_PORT eval change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=$SLAVE_MYPORT; start slave; -sleep 5; +--source include/wait_for_slave_to_start.inc + +# Calculate file name of relay log after flush logs +let $relay_file= query_get_value(show slave status, Relay_Log_File,1); +let $relay_name= `select substring_index('$relay_file','.',1);`; +let $relay_index= `select substring_index('$relay_file','.',-1);`; +let $relay_index_len= `select length(substring_index('$relay_file','.',-1));`; +let $relay_index_next=`select $relay_index+1`; +let $relay_file=`select concat('$relay_name','.',repeat('0',($relay_index_len-length($relay_index_next))),$relay_index_next);`; flush logs; -sleep 5; +let $slave_param= Relay_Log_File; +let $slave_param_value= $relay_file; +source include/wait_for_slave_param.inc; --replace_result $SLAVE_MYPORT SLAVE_PORT ---replace_column 1 # 8 # 9 # 23 # 33 # -show slave status; +--replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 # +--query_vertical show slave status # End of 4.1 tests From c0db5ae4ea7a1a5f230c6edd1dee585d1555d59d Mon Sep 17 00:00:00 2001 From: Serge Kozlov Date: Sun, 26 Oct 2008 22:34:24 +0300 Subject: [PATCH 2/3] Bug#22442, removed number of port --- mysql-test/r/rpl_flush_log_loop.result | 2 +- mysql-test/t/rpl_flush_log_loop.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result index 271e37247d4..d9bb93810d0 100644 --- a/mysql-test/r/rpl_flush_log_loop.result +++ b/mysql-test/r/rpl_flush_log_loop.result @@ -23,7 +23,7 @@ show slave status; Slave_IO_State # Master_Host 127.0.0.1 Master_User root -Master_Port 9306 +Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 Read_Master_Log_Pos 98 diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test index 0092ec3875e..c3707372e08 100644 --- a/mysql-test/t/rpl_flush_log_loop.test +++ b/mysql-test/t/rpl_flush_log_loop.test @@ -31,7 +31,7 @@ flush logs; let $slave_param= Relay_Log_File; let $slave_param_value= $relay_file; source include/wait_for_slave_param.inc; ---replace_result $SLAVE_MYPORT SLAVE_PORT +--replace_result $SLAVE_MYPORT SLAVE_PORT $MASTER_MYPORT MASTER_PORT --replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 # --query_vertical show slave status From f3a4a1864034bf5996541f60bc1d230a506862d9 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Mon, 27 Oct 2008 14:22:38 +0400 Subject: [PATCH 3/3] Bug#39040 valgrind errors/crash when creating views with binlog logging enabled A string buffers which were included in the 'view' data structure were allocated on the stack, causing an invalid pointer when used after the function returned. The fix: use copy of values for view->md5 & view->queries --- mysql-test/r/view.result | 2 ++ mysql-test/t/view.test | 9 +++++++++ sql/sql_view.cc | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index eb7a89c3d12..8cbe3fc36cf 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3677,6 +3677,8 @@ DROP VIEW v1; # -- End of test case for Bug#35193. +CREATE VIEW v1 AS SELECT 1; +DROP VIEW v1; # ----------------------------------------------------------------- # -- End of 5.0 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 9fa981ccb9a..bcf31a4501d 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3560,6 +3560,15 @@ DROP VIEW v1; ########################################################################### +# +# Bug#39040: valgrind errors/crash when creating views with binlog logging +# enabled +# +# Bug is visible only when running in valgrind with binary logging. +CREATE VIEW v1 AS SELECT 1; +DROP VIEW v1; + + --echo # ----------------------------------------------------------------- --echo # -- End of 5.0 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/sql_view.cc b/sql/sql_view.cc index dffad0cc575..8e6d3ed583a 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -774,8 +774,13 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, DBUG_PRINT("info", ("View: %s", str.ptr())); /* fill structure */ - view->query.str= str.c_ptr_safe(); - view->query.length= str.length(); + if (!make_lex_string(thd, &view->query, str.ptr(), str.length(), false)) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + error= -1; + goto err; + } + view->source.str= thd->query + thd->lex->create_view_select_start; view->source.length= (char *)skip_rear_comments(thd->charset(), (char *)view->source.str, @@ -784,7 +789,12 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, view->source.str; view->file_version= 1; view->calc_md5(md5); - view->md5.str= md5; + if (!(view->md5.str= thd->memdup(md5, 32))) + { + my_error(ER_OUT_OF_RESOURCES, MYF(0)); + error= -1; + goto err; + } view->md5.length= 32; can_be_merged= lex->can_be_merged(); if (lex->create_view_algorithm == VIEW_ALGORITHM_MERGE &&