Commit 50b43cf8 authored by Michael Widenius's avatar Michael Widenius

Fix for LP#614265 Crash in _ma_unpin_all_pages / _ma_search on DELETE with Aria search engine

Fixed compiler warnings

client/mysqlslap.c:
  Fixed compiler warnings
mysql-test/suite/maria/r/maria.result:
  Test case for LP#614265
mysql-test/suite/maria/t/maria.test:
  Test case for LP#614265
mysql-test/suite/pbxt/t/skip_name_resolve-master.opt:
  Ensure that we get restart before test (as test uses show processlist)
sql/handler.cc:
  Added cloned marker if clone was called (for safety checks & debugging)
sql/handler.h:
  Added cloned marker if clone was called (for safety checks & debugging)
storage/maria/ha_maria.cc:
  In clone call, set file->trn if cloned file had this set. This is needed as maria_create_trn_for_mysql() and thus file->trn is never set for cloned table.
  Ensure that file->trn is properly reset after calls to repair/check/zerofill.
  Increment locked table count if file->trn is set (as we decrement this in the unlock call)
tests/mysql_client_test.c:
  Fixed compiler warnings
parent 8b48a0aa
......@@ -543,7 +543,7 @@ static struct my_option my_long_options[] =
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE,
"Specify test load type: mixed, update, write, key, or read; default is mixed.",
&auto_generate_sql_type, &auto_generate_sql_type,
(char**) &auto_generate_sql_type, (char**) &auto_generate_sql_type,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"auto-generate-sql-secondary-indexes",
OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES,
......@@ -574,13 +574,13 @@ static struct my_option my_long_options[] =
&opt_compress, &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
{"concurrency", 'c', "Number of clients to simulate for query to run.",
&concurrency_str, &concurrency_str, 0, GET_STR,
(char**) &concurrency_str, (char**) &concurrency_str, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.",
&create_string, &create_string, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.",
&create_schema_string, &create_schema_string, 0, GET_STR,
(char**) &create_schema_string, (char**) &create_schema_string, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"csv", OPT_SLAP_CSV,
"Generate CSV output to named file or to stdout if no file is named.",
......@@ -590,7 +590,7 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
#else
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
&default_dbug_option, &default_dbug_option, 0, GET_STR,
(char**) &default_dbug_option, (char**) &default_dbug_option, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
......@@ -618,11 +618,11 @@ static struct my_option my_long_options[] =
&iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"number-char-cols", 'x',
"Number of VARCHAR columns to create in table if specifying --auto-generate-sql.",
&num_char_cols_opt, &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
(char**) &num_char_cols_opt, (char**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"number-int-cols", 'y',
"Number of INT columns to create in table if specifying --auto-generate-sql.",
&num_int_cols_opt, &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG,
(char**) &num_int_cols_opt, (char**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"number-of-queries", OPT_MYSQL_NUMBER_OF_QUERY,
"Limit each client to this number of queries (this is not exact).",
......
......@@ -2607,3 +2607,9 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=0
drop table t1;
CREATE TABLE t1 ( f1 DOUBLE , f2 DOUBLE , f3 DOUBLE , f4 DOUBLE , v3 DOUBLE , v4 DOUBLE , KEY ( v3 ) , KEY ( v4 ) ) engine=maria;
REPLACE t1 ( f2 , f1 ) VALUES ( f2 , 56 ) ;
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;
......@@ -1881,6 +1881,21 @@ Create table t1 (a int) engine="aria";
show create table t1;
drop table t1;
#
# Test of LP#614265. This happens when we where using quick_range_select in
# delete
#
CREATE TABLE t1 ( f1 DOUBLE , f2 DOUBLE , f3 DOUBLE , f4 DOUBLE , v3 DOUBLE , v4 DOUBLE , KEY ( v3 ) , KEY ( v4 ) ) engine=maria;
REPLACE t1 ( f2 , f1 ) VALUES ( f2 , 56 ) ;
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;
#
# End of test
#
# Set defaults back
--disable_result_log
--disable_query_log
......
......@@ -2027,6 +2027,10 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
handler *handler::clone(MEM_ROOT *mem_root)
{
handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
if (!new_handler)
return NULL;
/*
Allocate handler->ref here because otherwise ha_open will allocate it
on this->table->mem_root and we will not be able to reclaim that memory
......@@ -2034,12 +2038,13 @@ handler *handler::clone(MEM_ROOT *mem_root)
*/
if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
return NULL;
if (new_handler && !new_handler->ha_open(table,
table->s->normalized_path.str,
table->db_stat,
HA_OPEN_IGNORE_IF_LOCKED))
return new_handler;
return NULL;
if (new_handler->ha_open(table,
table->s->normalized_path.str,
table->db_stat,
HA_OPEN_IGNORE_IF_LOCKED))
return NULL;
new_handler->cloned= 1; // Marker for debugging
return new_handler;
}
......
......@@ -1129,6 +1129,7 @@ public:
enum {NONE=0, INDEX, RND} inited;
bool locked;
bool implicit_emptied; /* Can be !=0 only if HEAP */
bool cloned; /* 1 if this was created with clone */
const COND *pushed_cond;
/**
next_insert_id is the next value which should be inserted into the
......@@ -1166,7 +1167,7 @@ public:
ref(0), key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
ref_length(sizeof(my_off_t)),
ft_handler(0), inited(NONE),
locked(FALSE), implicit_emptied(0),
locked(FALSE), implicit_emptied(0), cloned(0),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0),
auto_inc_intervals_count(0)
{}
......
......@@ -790,7 +790,11 @@ handler *ha_maria::clone(MEM_ROOT *mem_root)
{
ha_maria *new_handler= static_cast <ha_maria *>(handler::clone(mem_root));
if (new_handler)
{
new_handler->file->state= file->state;
/* maria_create_trn_for_mysql() is never called for clone() tables */
new_handler->file->trn= file->trn;
}
return new_handler;
}
......@@ -1042,6 +1046,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
HA_CHECK param;
MARIA_SHARE *share= file->s;
const char *old_proc_info= thd_proc_info(thd, "Checking table");
TRN *old_trn= file->trn;
maria_chk_init(&param);
param.thd= thd;
......@@ -1120,6 +1125,8 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
}
/* Reset trn, that may have been set by repair */
_ma_set_trn_for_table(file, old_trn);
thd_proc_info(thd, old_proc_info);
return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
}
......@@ -1343,11 +1350,13 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK param;
TRN *old_trn;
MARIA_SHARE *share= file->s;
if (!file)
return HA_ADMIN_INTERNAL_ERROR;
old_trn= file->trn;
maria_chk_init(&param);
param.thd= thd;
param.op_name= "zerofill";
......@@ -1355,6 +1364,9 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
error=maria_zerofill(&param, file, share->open_file_name.str);
/* Reset trn, that may have been set by repair */
_ma_set_trn_for_table(file, old_trn);
if (!error)
{
pthread_mutex_lock(&share->intern_lock);
......@@ -1368,6 +1380,7 @@ int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK param;
if (!file)
return HA_ADMIN_INTERNAL_ERROR;
......@@ -1384,6 +1397,7 @@ int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
param.testflag &= ~T_REP_BY_SORT;
error= repair(thd, &param, 1);
}
return error;
}
......@@ -1397,6 +1411,7 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
char fixed_name[FN_REFLEN];
MARIA_SHARE *share= file->s;
ha_rows rows= file->state->records;
TRN *old_trn= file->trn;
DBUG_ENTER("ha_maria::repair");
/*
......@@ -1558,6 +1573,9 @@ int ha_maria::repair(THD *thd, HA_CHECK *param, bool do_optimize)
thd_proc_info(thd, old_proc_info);
if (!thd->locked_tables)
maria_lock_database(file, F_UNLCK);
/* Reset trn, that may have been set by repair */
_ma_set_trn_for_table(file, old_trn);
error= error ? HA_ADMIN_FAILED :
(optimize_done ?
(write_log_record_for_repair(param, file) ? HA_ADMIN_FAILED :
......@@ -2295,6 +2313,8 @@ int ha_maria::info(uint flag, my_bool lock_table_share)
int ha_maria::extra(enum ha_extra_function operation)
{
int tmp;
TRN *old_trn= file->trn;
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD)
return 0;
#ifdef NOT_USED
......@@ -2320,7 +2340,9 @@ int ha_maria::extra(enum ha_extra_function operation)
TRN *trn= THD_TRN;
_ma_set_trn_for_table(file, trn);
}
return maria_extra(file, operation, 0);
tmp= maria_extra(file, operation, 0);
file->trn= old_trn; // Reset trn if was used
return tmp;
}
int ha_maria::reset(void)
......@@ -2415,6 +2437,13 @@ int ha_maria::external_lock(THD *thd, int lock_type)
*file->state= file->s->state.state;
}
if (file->trn)
{
/* This can only happen with tables created with clone() */
DBUG_ASSERT(cloned);
trnman_increment_locked_tables(file->trn);
}
if (!thd->transaction.on)
{
/*
......
......@@ -18320,14 +18320,14 @@ static char **defaults_argv;
static struct my_option client_test_long_options[] =
{
{"basedir", 'b', "Basedir for tests.", &opt_basedir,
&opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"basedir", 'b', "Basedir for tests.", (char**) &opt_basedir,
(char**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"count", 't', "Number of times test to be executed", &opt_count,
&opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"database", 'D', "Database to use", &opt_db, &opt_db,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log", &default_dbug_option,
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log", (char**) &default_dbug_option,
(char**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
0, 0, 0, 0, 0},
{"host", 'h', "Connect to host", &opt_host, &opt_host,
......@@ -18363,8 +18363,8 @@ static struct my_option client_test_long_options[] =
{"user", 'u', "User for login if not current user", &opt_user,
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"vardir", 'v', "Data dir for tests.", &opt_vardir,
&opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"vardir", 'v', "Data dir for tests.", (char**) &opt_vardir,
(char**) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"getopt-ll-test", 'g', "Option for testing bug in getopt library",
&opt_getopt_ll_test, &opt_getopt_ll_test, 0,
GET_LL, REQUIRED_ARG, 0, 0, LONGLONG_MAX, 0, 0, 0},
......
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