Commit a5cd4960 authored by Michael Widenius's avatar Michael Widenius

Merge with MariaDB 5.1

parents e4d0338a a93dea4f
......@@ -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
......
......@@ -2029,6 +2029,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
......@@ -2036,12 +2040,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;
}
......
......@@ -1245,6 +1245,7 @@ class handler :public Sql_alloc
bool locked;
bool implicit_emptied; /* Can be !=0 only if HEAP */
bool mark_trx_done;
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
......@@ -1288,7 +1289,7 @@ class handler :public Sql_alloc
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(FALSE), mark_trx_done(FALSE),
locked(FALSE), implicit_emptied(FALSE), mark_trx_done(FALSE), cloned(0),
pushed_cond(0), next_insert_id(0), insert_id_for_cur_row(0),
auto_inc_intervals_count(0)
{
......
......@@ -826,7 +826,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;
}
......@@ -1078,6 +1082,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;
......@@ -1156,6 +1161,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;
}
......@@ -1379,11 +1386,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";
......@@ -1391,6 +1400,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);
......@@ -1404,6 +1416,7 @@ int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
HA_CHECK param;
if (!file)
return HA_ADMIN_INTERNAL_ERROR;
......@@ -1420,6 +1433,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;
}
......@@ -1433,6 +1447,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");
/*
......@@ -1594,6 +1609,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 :
......@@ -2331,6 +2349,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
......@@ -2356,7 +2376,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)
......@@ -2451,6 +2473,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)
{
/*
......
......@@ -18321,14 +18321,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,
......@@ -18364,8 +18364,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