Commit 2e46eb77 authored by Michael Widenius's avatar Michael Widenius

This patch fixes LP#613408 Memory corruption with (M)aria storage engine and...

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)



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
parent c7e1795a
......@@ -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,
......
......@@ -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.",
......
......@@ -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",
);
}
......
......@@ -2613,3 +2613,14 @@ INSERT t1 ( f1 , f2 , f3 , f4 ) VALUES ( 0 , f2 , 8 , f3 ) ;
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;
......@@ -1893,6 +1893,23 @@ INSERT t1 ( f4 , f2 ) VALUES ( 4 , 92 ) ;
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
#
......
-- source include/not_windows.inc
-- echo # Activate master-slave replication
-- source include/master-slave.inc
......
-- source include/not_windows.inc
-- echo # Activate master-slave replication
-- source include/master-slave.inc
......
--source include/not_windows.inc
source include/have_innodb.inc;
SELECT sleep(2);
set global log_slow_verbosity=innodb;
......
-- source include/not_windows.inc
source include/have_innodb.inc;
SET GLOBAL SLOW_QUERY_LOG=OFF;
......
-- source include/not_windows.inc
source include/have_innodb.inc;
SELECT sleep(2);
......
source include/not_windows.inc;
source include/have_innodb.inc;
SELECT sleep(1);
......
source include/not_windows.inc;
source include/have_innodb.inc;
SELECT sleep(2);
......
source include/not_windows.inc;
source include/have_innodb.inc;
SET GLOBAL SLOW_QUERY_LOG=OFF;
......
source include/not_windows.inc;
source include/have_innodb.inc;
SELECT sleep(1);
......
--source include/not_windows.inc
SET CHARACTER SET utf8;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
SHOW VARIABLES like 'character_sets_dir';
......
......@@ -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
......
--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
......@@ -2270,10 +2270,14 @@ static int initialize_variables_for_repair(HA_CHECK *param,
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_repair(HA_CHECK *param,
}
/*
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, register MARIA_HA *info,
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, register MARIA_HA *info,
}
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 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
/* 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, register MARIA_HA *info,
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, register MARIA_HA *info,
}
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 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
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 *param, register MARIA_HA *info,
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 *param, register MARIA_HA *info,
}
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 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
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));
......
......@@ -678,6 +678,7 @@ void maria_versioning(MARIA_HA *info, my_bool versioning)
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;
}
}
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment