Commit 3bb2045f authored by Michael Widenius's avatar Michael Widenius

Merge with 5.1 to get bug fix for LP#613408 Memory corruption with (M)aria...

Merge with 5.1 to get bug fix for LP#613408 Memory corruption with (M)aria storage engine and virtual columns
Fixed test case to test for virtual columns
parents 165eb118 0d3039d4
...@@ -164,7 +164,7 @@ static struct my_option my_long_options[] = ...@@ -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}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"character-sets-dir", 'c', "Directory for character set files.", {"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}, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET, {"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", &default_charset, "Set the default character set.", &default_charset,
......
...@@ -600,7 +600,7 @@ static struct my_option my_long_options[] = ...@@ -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}, &debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", 'F', {"delimiter", 'F',
"Delimiter to use in SQL statements supplied in file or command line.", "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}, 0, 0, 0, 0, 0, 0},
{"detach", OPT_SLAP_DETACH, {"detach", OPT_SLAP_DETACH,
"Detach (close and reopen) connections after X number of requests.", "Detach (close and reopen) connections after X number of requests.",
......
...@@ -4537,7 +4537,7 @@ sub mysqld_stop { ...@@ -4537,7 +4537,7 @@ sub mysqld_stop {
name => "mysqladmin shutdown ".$mysqld->name(), name => "mysqladmin shutdown ".$mysqld->name(),
path => $exe_mysqladmin, path => $exe_mysqladmin,
args => \$args, 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 ) ; ...@@ -2613,3 +2613,14 @@ INSERT t1 ( f1 , f2 , f3 , f4 ) VALUES ( 0 , f2 , 8 , f3 ) ;
INSERT t1 ( f4 , f2 ) VALUES ( 4 , 92 ) ; INSERT t1 ( f4 , f2 ) VALUES ( 4 , 92 ) ;
DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 ; DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 ;
drop table t1; 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 AS ( ( f1 NOT LIKE '%' ) ) PERSISTENT,
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 ) ; ...@@ -1893,6 +1893,23 @@ INSERT t1 ( f4 , f2 ) VALUES ( 4 , 92 ) ;
DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 ; DELETE FROM t1 WHERE v3 = 173 OR v4 = 9 ;
drop table t1; 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 AS ( ( f1 NOT LIKE '%' ) ) PERSISTENT,
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 # End of test
# #
......
-- source include/not_windows.inc
-- echo # Activate master-slave replication -- echo # Activate master-slave replication
-- source include/master-slave.inc -- source include/master-slave.inc
......
-- source include/not_windows.inc
-- echo # Activate master-slave replication -- echo # Activate master-slave replication
-- source include/master-slave.inc -- source include/master-slave.inc
......
--source include/not_windows.inc
source include/have_innodb.inc; source include/have_innodb.inc;
SELECT sleep(2); SELECT sleep(2);
set global log_slow_verbosity=innodb; set global log_slow_verbosity=innodb;
......
-- source include/not_windows.inc
source include/have_innodb.inc; source include/have_innodb.inc;
SET GLOBAL SLOW_QUERY_LOG=OFF; SET GLOBAL SLOW_QUERY_LOG=OFF;
......
-- source include/not_windows.inc
source include/have_innodb.inc; source include/have_innodb.inc;
SELECT sleep(2); SELECT sleep(2);
......
source include/not_windows.inc;
source include/have_innodb.inc; source include/have_innodb.inc;
SELECT sleep(1); SELECT sleep(1);
......
source include/not_windows.inc;
source include/have_innodb.inc; source include/have_innodb.inc;
SELECT sleep(2); SELECT sleep(2);
......
source include/not_windows.inc;
source include/have_innodb.inc; source include/have_innodb.inc;
SET GLOBAL SLOW_QUERY_LOG=OFF; SET GLOBAL SLOW_QUERY_LOG=OFF;
......
source include/not_windows.inc;
source include/have_innodb.inc; source include/have_innodb.inc;
SELECT sleep(1); SELECT sleep(1);
......
--source include/not_windows.inc
SET CHARACTER SET utf8; SET CHARACTER SET utf8;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
SHOW VARIABLES like 'character_sets_dir'; SHOW VARIABLES like 'character_sets_dir';
......
--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
...@@ -4410,8 +4410,7 @@ static my_bool read_long_data2(MARIA_HA *info, uchar *to, ulong length, ...@@ -4410,8 +4410,7 @@ static my_bool read_long_data2(MARIA_HA *info, uchar *to, ulong length,
MARIA_EXTENT_CURSOR *extent, MARIA_EXTENT_CURSOR *extent,
uchar **data, uchar **end_of_data) uchar **data, uchar **end_of_data)
{ {
uint left_length; uint left_length= (uint) (*end_of_data - *data);
left_length= (uint) (*end_of_data - *data);
DBUG_ENTER("read_long_data2"); DBUG_ENTER("read_long_data2");
DBUG_PRINT("enter", ("length: %lu left_length: %u", DBUG_PRINT("enter", ("length: %lu left_length: %u",
length, left_length)); length, left_length));
......
...@@ -2270,10 +2270,14 @@ static int initialize_variables_for_repair(HA_CHECK *param, ...@@ -2270,10 +2270,14 @@ static int initialize_variables_for_repair(HA_CHECK *param,
MARIA_SORT_INFO *sort_info, MARIA_SORT_INFO *sort_info,
MARIA_SORT_PARAM *sort_param, MARIA_SORT_PARAM *sort_param,
MARIA_HA *info, MARIA_HA *info,
my_bool rep_quick) my_bool rep_quick,
MARIA_SHARE *org_share)
{ {
MARIA_SHARE *share= info->s; 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 */ /* Repair code relies on share->state.state so we have to update it here */
if (share->lock.update_status) if (share->lock.update_status)
(*share->lock.update_status)(info); (*share->lock.update_status)(info);
...@@ -2333,6 +2337,23 @@ static int initialize_variables_for_repair(HA_CHECK *param, ...@@ -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 @brief Drop all indexes
...@@ -2481,11 +2502,11 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, ...@@ -2481,11 +2502,11 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
char llbuff[22],llbuff2[22]; char llbuff[22],llbuff2[22];
MARIA_SORT_INFO sort_info; MARIA_SORT_INFO sort_info;
MARIA_SORT_PARAM sort_param; MARIA_SORT_PARAM sort_param;
my_bool block_record, scan_inited= 0, my_bool block_record, scan_inited= 0, reenable_logging= 0;
reenable_logging= share->now_transactional;
enum data_file_type org_data_file_type= share->data_file_type; enum data_file_type org_data_file_type= share->data_file_type;
myf sync_dir= ((share->now_transactional && !share->temporary) ? myf sync_dir= ((share->now_transactional && !share->temporary) ?
MY_SYNC_DIR : 0); MY_SYNC_DIR : 0);
MARIA_SHARE backup_share;
DBUG_ENTER("maria_repair"); DBUG_ENTER("maria_repair");
got_error= 1; got_error= 1;
...@@ -2498,10 +2519,10 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, ...@@ -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, if (initialize_variables_for_repair(param, &sort_info, &sort_param, info,
rep_quick)) rep_quick, &backup_share))
goto err; goto err;
if (reenable_logging) if ((reenable_logging= share->now_transactional))
_ma_tmp_disable_logging_for_table(info, 0); _ma_tmp_disable_logging_for_table(info, 0);
sort_param.current_filepos= sort_param.filepos= new_header_length= sort_param.current_filepos= sort_param.filepos= new_header_length=
...@@ -2780,6 +2801,7 @@ err: ...@@ -2780,6 +2801,7 @@ err:
/* If caller had disabled logging it's not up to us to re-enable it */ /* If caller had disabled logging it's not up to us to re-enable it */
if (reenable_logging) if (reenable_logging)
_ma_reenable_logging_for_table(info, FALSE); _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.rec_buff, MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_param.record,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, ...@@ -3550,7 +3572,8 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
ulonglong key_map; ulonglong key_map;
myf sync_dir= ((share->now_transactional && !share->temporary) ? myf sync_dir= ((share->now_transactional && !share->temporary) ?
MY_SYNC_DIR : 0); 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"); DBUG_ENTER("maria_repair_by_sort");
LINT_INIT(key_map); LINT_INIT(key_map);
...@@ -3564,9 +3587,12 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, ...@@ -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, if (initialize_variables_for_repair(param, &sort_info, &sort_param, info,
rep_quick)) rep_quick, &backup_share))
goto err; goto err;
if ((reenable_logging= share->now_transactional))
_ma_tmp_disable_logging_for_table(info, 0);
org_header_length= share->pack.header_length; org_header_length= share->pack.header_length;
new_header_length= (param->testflag & T_UNPACK) ? 0 : org_header_length; new_header_length= (param->testflag & T_UNPACK) ? 0 : org_header_length;
sort_param.filepos= new_header_length; sort_param.filepos= new_header_length;
...@@ -3972,6 +3998,11 @@ err: ...@@ -3972,6 +3998,11 @@ err:
share->state.changed&= ~(STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_ZEROFILLED | share->state.changed&= ~(STATE_NOT_OPTIMIZED_ROWS | STATE_NOT_ZEROFILLED |
STATE_NOT_MOVABLE); 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.rec_buff, MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_param.record,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)); 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, ...@@ -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 new_data_cache; /* For non-quick repair. */
IO_CACHE_SHARE io_share; IO_CACHE_SHARE io_share;
MARIA_SORT_INFO sort_info; MARIA_SORT_INFO sort_info;
MARIA_SHARE backup_share;
ulonglong key_map; ulonglong key_map;
pthread_attr_t thr_attr; pthread_attr_t thr_attr;
myf sync_dir= ((share->now_transactional && !share->temporary) ? myf sync_dir= ((share->now_transactional && !share->temporary) ?
MY_SYNC_DIR : 0); MY_SYNC_DIR : 0);
my_bool reenable_logging= 0;
DBUG_ENTER("maria_repair_parallel"); DBUG_ENTER("maria_repair_parallel");
LINT_INIT(key_map); LINT_INIT(key_map);
...@@ -4059,9 +4092,12 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, ...@@ -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, if (initialize_variables_for_repair(param, &sort_info, &tmp_sort_param, info,
rep_quick)) rep_quick, &backup_share))
goto err; goto err;
if ((reenable_logging= share->now_transactional))
_ma_tmp_disable_logging_for_table(info, 0);
new_header_length= ((param->testflag & T_UNPACK) ? 0 : new_header_length= ((param->testflag & T_UNPACK) ? 0 :
share->pack.header_length); share->pack.header_length);
...@@ -4489,6 +4525,11 @@ err: ...@@ -4489,6 +4525,11 @@ err:
pthread_cond_destroy (&sort_info.cond); pthread_cond_destroy (&sort_info.cond);
pthread_mutex_destroy(&sort_info.mutex); 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.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_info.key_block,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)); my_free(sort_param,MYF(MY_ALLOW_ZERO_PTR));
......
...@@ -678,6 +678,7 @@ void maria_versioning(MARIA_HA *info, my_bool versioning) ...@@ -678,6 +678,7 @@ void maria_versioning(MARIA_HA *info, my_bool versioning)
info->lock.type= versioning ? TL_WRITE_CONCURRENT_INSERT : TL_WRITE; info->lock.type= versioning ? TL_WRITE_CONCURRENT_INSERT : TL_WRITE;
_ma_block_get_status((void*) info, versioning); _ma_block_get_status((void*) info, versioning);
info->lock.type= save_lock_type; 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) ...@@ -176,7 +176,8 @@ int trnman_init(TrID initial_trid)
trnman_active_transactions= 0; trnman_active_transactions= 0;
trnman_committed_transactions= 0; trnman_committed_transactions= 0;
trnman_allocated_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; pool= 0;
global_trid_generator= initial_trid; 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