[Commits] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (monty:2894)

#At lp:maria based on revid:monty@askmonty.org-20100806131230-xix7bvu1xt4qeg42 2894 Michael Widenius 2010-08-07 This patch fixes LP#613408 Memory corruption with (M)aria storage engine and virtual columns in MariaDB 5.2 Fixed compiler warnings Disabled some tests that doesn't work on windows (uses shell tools or strange characters) modified: client/mysqlshow.c client/mysqlslap.c mysql-test/mysql-test-run.pl mysql-test/suite/maria/r/maria.result mysql-test/suite/maria/t/maria.test mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test mysql-test/suite/percona/percona_log_slow_slave_statements.test mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test mysql-test/suite/percona/percona_slow_query_log-long_query_time.test mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test mysql-test/t/ctype_filesystem.test mysql-test/t/events_time_zone.test mysql-test/t/show_check-master.opt storage/maria/ma_check.c storage/maria/ma_state.c storage/maria/trnman.c per-file messages: client/mysqlshow.c Fixed compiler warnings client/mysqlslap.c Fixed compiler warnings mysql-test/mysql-test-run.pl Use an error file instead of /dev/null (Fixes problem on Windows and the output may be usefull) mysql-test/suite/maria/r/maria.result Test case for bug LP#613408 (not complete) mysql-test/suite/maria/t/maria.test Test case for bug LP#613408 (not complete) mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_log_slow_slave_statements.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-long_query_time.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test This test doesn't work one windows (needs shell tools) mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test This test doesn't work one windows (needs shell tools) mysql-test/t/ctype_filesystem.test This test doesn't work one windows (problem with character sets) mysql-test/t/events_time_zone.test Use longer times to get predictable tests mysql-test/t/show_check-master.opt set long query time to get more predictable tests storage/maria/ma_check.c Restore info->s->lock_key_trees after repair. Disable logging to temp tables for all repair cases (safety fix) storage/maria/ma_state.c Ensurethat info->state_start doesn't point to freed memory. (Could happen after running an internal repair to fast create indexes) storage/maria/trnman.c Added longer comment === modified file 'client/mysqlshow.c' --- a/client/mysqlshow.c 2010-06-10 20:16:43 +0000 +++ b/client/mysqlshow.c 2010-08-07 14:42:30 +0000 @@ -164,7 +164,7 @@ static struct my_option my_long_options[ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", 'c', "Directory for character set files.", - &charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, + (char**) &charsets_dir, (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", &default_charset, === modified file 'client/mysqlslap.c' --- a/client/mysqlslap.c 2010-08-06 12:39:37 +0000 +++ b/client/mysqlslap.c 2010-08-07 14:42:30 +0000 @@ -600,7 +600,7 @@ static struct my_option my_long_options[ &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", 'F', "Delimiter to use in SQL statements supplied in file or command line.", - &delimiter, &delimiter, 0, GET_STR, REQUIRED_ARG, + (char**) &delimiter, (char**) &delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"detach", OPT_SLAP_DETACH, "Detach (close and reopen) connections after X number of requests.", === modified file 'mysql-test/mysql-test-run.pl' --- a/mysql-test/mysql-test-run.pl 2010-08-05 11:40:54 +0000 +++ b/mysql-test/mysql-test-run.pl 2010-08-07 14:42:30 +0000 @@ -4540,7 +4540,7 @@ sub mysqld_stop { name => "mysqladmin shutdown ".$mysqld->name(), path => $exe_mysqladmin, args => \$args, - error => "/dev/null", + error => "$opt_vardir/log/mysqladmin.err", ); } === modified file 'mysql-test/suite/maria/r/maria.result' --- a/mysql-test/suite/maria/r/maria.result 2010-08-06 12:39:37 +0000 +++ b/mysql-test/suite/maria/r/maria.result 2010-08-07 14:42:30 +0000 @@ -2613,3 +2613,14 @@ INSERT t1 ( f1 , f2 , f3 , f4 ) VALUES ( INSERT t1 ( f4 , f2 ) VALUES ( 4 , 92 ) ; DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 ; drop table t1; +CREATE TABLE t1 ( +f1 CHAR(255) BINARY , +f2 CHAR(255) BINARY NOT NULL DEFAULT '0', +f3 CHAR(255) BINARY NOT NULL , +f4 CHAR(255) BINARY NOT NULL DEFAULT '0' , +v3 CHAR(255) BINARY NOT NULL DEFAULT '0' , +KEY (v3) +) ENGINE=Maria; +INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1; +DELETE FROM t1; +drop table t1; === modified file 'mysql-test/suite/maria/t/maria.test' --- a/mysql-test/suite/maria/t/maria.test 2010-08-06 12:39:37 +0000 +++ b/mysql-test/suite/maria/t/maria.test 2010-08-07 14:42:30 +0000 @@ -1894,6 +1894,23 @@ DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 drop table t1; # +# Test for LP#61465 Memory corruption with (M)aria storage engine and +# virtual columns +# + +CREATE TABLE t1 ( + f1 CHAR(255) BINARY , + f2 CHAR(255) BINARY NOT NULL DEFAULT '0', + f3 CHAR(255) BINARY NOT NULL , + f4 CHAR(255) BINARY NOT NULL DEFAULT '0' , + v3 CHAR(255) BINARY NOT NULL DEFAULT '0' , + KEY (v3) +) ENGINE=Maria; +INSERT INTO t1 ( f1 , f2 , f3 , f4 ) SELECT f1 , f4 , f1 , f4 FROM t1; +DELETE FROM t1; +drop table t1; + +# # End of test # # Set defaults back === modified file 'mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test' --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test 2010-08-04 08:39:53 +0000 +++ b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +-- source include/not_windows.inc + -- echo # Activate master-slave replication -- source include/master-slave.inc === modified file 'mysql-test/suite/percona/percona_log_slow_slave_statements.test' --- a/mysql-test/suite/percona/percona_log_slow_slave_statements.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_log_slow_slave_statements.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +-- source include/not_windows.inc + -- echo # Activate master-slave replication -- source include/master-slave.inc === modified file 'mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test' --- a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +--source include/not_windows.inc + source include/have_innodb.inc; SELECT sleep(2); set global log_slow_verbosity=innodb; === modified file 'mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test' --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +-- source include/not_windows.inc + source include/have_innodb.inc; SET GLOBAL SLOW_QUERY_LOG=OFF; === modified file 'mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test' --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +-- source include/not_windows.inc + source include/have_innodb.inc; SELECT sleep(2); === modified file 'mysql-test/suite/percona/percona_slow_query_log-long_query_time.test' --- a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test 2010-08-06 07:46:51 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,4 @@ +source include/not_windows.inc; source include/have_innodb.inc; SELECT sleep(1); === modified file 'mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test' --- a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,4 @@ +source include/not_windows.inc; source include/have_innodb.inc; SELECT sleep(2); === modified file 'mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test' --- a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,4 @@ +source include/not_windows.inc; source include/have_innodb.inc; SET GLOBAL SLOW_QUERY_LOG=OFF; === modified file 'mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test' --- a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test 2010-08-05 09:28:19 +0000 +++ b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,4 @@ +source include/not_windows.inc; source include/have_innodb.inc; SELECT sleep(1); === modified file 'mysql-test/t/ctype_filesystem.test' --- a/mysql-test/t/ctype_filesystem.test 2008-12-01 11:34:53 +0000 +++ b/mysql-test/t/ctype_filesystem.test 2010-08-07 14:42:30 +0000 @@ -1,3 +1,5 @@ +--source include/not_windows.inc + SET CHARACTER SET utf8; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR SHOW VARIABLES like 'character_sets_dir'; === modified file 'mysql-test/t/events_time_zone.test' --- a/mysql-test/t/events_time_zone.test 2010-08-02 16:39:45 +0000 +++ b/mysql-test/t/events_time_zone.test 2010-08-07 14:42:30 +0000 @@ -5,7 +5,7 @@ # to wait for operation to complete. Should be positive. Test runs # about 25*N seconds (it sleeps most of the time, so CPU speed is not # relevant). -let $N = 5; +let $N = 6; # # 2. Some subtests # - create a new time zone === modified file 'mysql-test/t/show_check-master.opt' --- a/mysql-test/t/show_check-master.opt 2010-01-27 21:53:08 +0000 +++ b/mysql-test/t/show_check-master.opt 2010-08-07 14:42:30 +0000 @@ -1 +1 @@ ---log-output=file --slow-query-log --log-long-format --log-queries-not-using-indexes --myisam-recover="" --general-log --general-log-file="foo" --slow-query-log-file="" +--log-output=file --slow-query-log --log-long-format --log-queries-not-using-indexes --myisam-recover="" --general-log --general-log-file="foo" --slow-query-log-file="" --long_query_time=20 === modified file 'storage/maria/ma_check.c' --- a/storage/maria/ma_check.c 2010-07-30 07:45:27 +0000 +++ b/storage/maria/ma_check.c 2010-08-07 14:42:30 +0000 @@ -2270,10 +2270,14 @@ static int initialize_variables_for_repa MARIA_SORT_INFO *sort_info, MARIA_SORT_PARAM *sort_param, MARIA_HA *info, - my_bool rep_quick) + my_bool rep_quick, + MARIA_SHARE *org_share) { MARIA_SHARE *share= info->s; + /* Ro allow us to restore state and check how state changed */ + memcpy(org_share, share, sizeof(*share)); + /* Repair code relies on share->state.state so we have to update it here */ if (share->lock.update_status) (*share->lock.update_status)(info); @@ -2333,6 +2337,23 @@ static int initialize_variables_for_repa } +/* + During initialize_variables_for_repair and related functions we set some + variables to values that makes sence during repair. + This function restores these values to their original values so that we can + use the handler in MariaDB without having to close and open the table. +*/ + +static void restore_table_state_after_repair(MARIA_HA *info, + MARIA_SHARE *org_share) +{ + maria_versioning(info, info->s->have_versioning); + info->s->lock_key_trees= org_share->lock_key_trees; +} + + + + /** @brief Drop all indexes @@ -2481,11 +2502,11 @@ int maria_repair(HA_CHECK *param, regist char llbuff[22],llbuff2[22]; MARIA_SORT_INFO sort_info; MARIA_SORT_PARAM sort_param; - my_bool block_record, scan_inited= 0, - reenable_logging= share->now_transactional; + my_bool block_record, scan_inited= 0, reenable_logging= 0; enum data_file_type org_data_file_type= share->data_file_type; myf sync_dir= ((share->now_transactional && !share->temporary) ? MY_SYNC_DIR : 0); + MARIA_SHARE backup_share; DBUG_ENTER("maria_repair"); got_error= 1; @@ -2498,10 +2519,10 @@ int maria_repair(HA_CHECK *param, regist } if (initialize_variables_for_repair(param, &sort_info, &sort_param, info, - rep_quick)) + rep_quick, &backup_share)) goto err; - if (reenable_logging) + if ((reenable_logging= share->now_transactional)) _ma_tmp_disable_logging_for_table(info, 0); sort_param.current_filepos= sort_param.filepos= new_header_length= @@ -2780,6 +2801,7 @@ err: /* If caller had disabled logging it's not up to us to re-enable it */ if (reenable_logging) _ma_reenable_logging_for_table(info, FALSE); + restore_table_state_after_repair(info, &backup_share); my_free(sort_param.rec_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR)); @@ -3550,7 +3572,8 @@ int maria_repair_by_sort(HA_CHECK *param ulonglong key_map; myf sync_dir= ((share->now_transactional && !share->temporary) ? MY_SYNC_DIR : 0); - my_bool scan_inited= 0; + my_bool scan_inited= 0, reenable_logging= 0; + MARIA_SHARE backup_share; DBUG_ENTER("maria_repair_by_sort"); LINT_INIT(key_map); @@ -3564,9 +3587,12 @@ int maria_repair_by_sort(HA_CHECK *param } if (initialize_variables_for_repair(param, &sort_info, &sort_param, info, - rep_quick)) + rep_quick, &backup_share)) goto err; + if ((reenable_logging= share->now_transactional)) + _ma_tmp_disable_logging_for_table(info, 0); + org_header_length= share->pack.header_length; new_header_length= (param->testflag & T_UNPACK) ? 0 : org_header_length; sort_param.filepos= new_header_length; @@ -3972,6 +3998,11 @@ err: share->state.changed&= ~(STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_ZEROFILLED | STATE_NOT_MOVABLE); + /* If caller had disabled logging it's not up to us to re-enable it */ + if (reenable_logging) + _ma_reenable_logging_for_table(info, FALSE); + restore_table_state_after_repair(info, &backup_share); + my_free(sort_param.rec_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_info.key_block, MYF(MY_ALLOW_ZERO_PTR)); @@ -4042,10 +4073,12 @@ int maria_repair_parallel(HA_CHECK *para IO_CACHE new_data_cache; /* For non-quick repair. */ IO_CACHE_SHARE io_share; MARIA_SORT_INFO sort_info; + MARIA_SHARE backup_share; ulonglong key_map; pthread_attr_t thr_attr; myf sync_dir= ((share->now_transactional && !share->temporary) ? MY_SYNC_DIR : 0); + my_bool reenable_logging= 0; DBUG_ENTER("maria_repair_parallel"); LINT_INIT(key_map); @@ -4059,9 +4092,12 @@ int maria_repair_parallel(HA_CHECK *para } if (initialize_variables_for_repair(param, &sort_info, &tmp_sort_param, info, - rep_quick)) + rep_quick, &backup_share)) goto err; + if ((reenable_logging= share->now_transactional)) + _ma_tmp_disable_logging_for_table(info, 0); + new_header_length= ((param->testflag & T_UNPACK) ? 0 : share->pack.header_length); @@ -4489,6 +4525,11 @@ err: pthread_cond_destroy (&sort_info.cond); pthread_mutex_destroy(&sort_info.mutex); + /* If caller had disabled logging it's not up to us to re-enable it */ + if (reenable_logging) + _ma_reenable_logging_for_table(info, FALSE); + restore_table_state_after_repair(info, &backup_share); + my_free(sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param,MYF(MY_ALLOW_ZERO_PTR)); === modified file 'storage/maria/ma_state.c' --- a/storage/maria/ma_state.c 2010-06-15 22:00:51 +0000 +++ b/storage/maria/ma_state.c 2010-08-07 14:42:30 +0000 @@ -678,6 +678,7 @@ void maria_versioning(MARIA_HA *info, my info->lock.type= versioning ? TL_WRITE_CONCURRENT_INSERT : TL_WRITE; _ma_block_get_status((void*) info, versioning); info->lock.type= save_lock_type; + info->state= info->state_start= &info->s->state.common; } } === modified file 'storage/maria/trnman.c' --- a/storage/maria/trnman.c 2010-07-30 07:45:27 +0000 +++ b/storage/maria/trnman.c 2010-08-07 14:42:30 +0000 @@ -176,7 +176,8 @@ int trnman_init(TrID initial_trid) trnman_active_transactions= 0; trnman_committed_transactions= 0; trnman_allocated_transactions= 0; - dummy_transaction_object.min_read_from= ~(TrID) 0; /* for recovery */ + /* This is needed for recovery and repair */ + dummy_transaction_object.min_read_from= ~(TrID) 0; pool= 0; global_trid_generator= initial_trid;
participants (1)
-
Michael Widenius