Commit 10d1a0da authored by Kristofer Pettersson's avatar Kristofer Pettersson

automerge

parents 68995e48 b202a986
...@@ -6907,6 +6907,16 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, ...@@ -6907,6 +6907,16 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
*/ */
} }
/*
Need to grab affected rows information before getting
warnings here
*/
ulonglong affected_rows;
LINT_INIT(affected_rows);
if (!disable_info)
affected_rows= mysql_affected_rows(mysql);
if (!disable_warnings) if (!disable_warnings)
{ {
/* Get the warnings from execute */ /* Get the warnings from execute */
...@@ -6931,7 +6941,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, ...@@ -6931,7 +6941,7 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command,
} }
if (!disable_info) if (!disable_info)
append_info(ds, mysql_affected_rows(mysql), mysql_info(mysql)); append_info(ds, affected_rows, mysql_info(mysql));
} }
......
...@@ -6,5 +6,5 @@ rpl.rpl_row_create_table* # Bug#45576: rpl_row_create_table fails ...@@ -6,5 +6,5 @@ rpl.rpl_row_create_table* # Bug#45576: rpl_row_create_table fails
rpl_ndb.rpl_ndb_log # Bug#38998 rpl_ndb.rpl_ndb_log # Bug#38998
rpl.rpl_innodb_bug28430* @solaris # Bug#46029 rpl.rpl_innodb_bug28430* @solaris # Bug#46029
rpl.rpl_get_master_version_and_clock* # Bug#46931 2009-08-26 alik rpl.rpl_get_master_version_and_clock fails on hpux11.31 rpl.rpl_get_master_version_and_clock* # Bug#46931 2009-08-26 alik rpl.rpl_get_master_version_and_clock fails on hpux11.31
innodb-autoinc # Bug#47809 2009-10-04 joro innodb-autoinc.test fails with valgrind errors with the innodb plugin main.innodb-autoinc* # Bug#47809 2009-10-04 joro innodb-autoinc.test fails with valgrind errors with the innodb plugin
rpl.rpl_trigger # Bug#47810 2009-10-04 joro rpl.rpl_trigger.test fails with valgrind errors with the innodb plugin rpl.rpl_trigger* # Bug#47810 2009-10-04 joro rpl.rpl_trigger.test fails with valgrind errors with the innodb plugin
...@@ -442,6 +442,8 @@ INSERT INTO t1(id, dept, age, name) VALUES ...@@ -442,6 +442,8 @@ INSERT INTO t1(id, dept, age, name) VALUES
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
DELETE FROM t1; DELETE FROM t1;
--echo # Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746).
--replace_column 9 #
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
......
...@@ -507,6 +507,10 @@ sub collect_one_suite($) ...@@ -507,6 +507,10 @@ sub collect_one_suite($)
next if ($test->{'name'} eq 'sys_vars.innodb_lock_wait_timeout_basic'); next if ($test->{'name'} eq 'sys_vars.innodb_lock_wait_timeout_basic');
# Diff around innodb_thread_concurrency variable # Diff around innodb_thread_concurrency variable
next if ($test->{'name'} eq 'sys_vars.innodb_thread_concurrency_basic'); next if ($test->{'name'} eq 'sys_vars.innodb_thread_concurrency_basic');
# Disable for Innodb Plugin until the fix for Plugin is received
next if ($test->{'name'} eq 'main.innodb_bug46000');
# Disable for Innodb Plugin until the fix for Plugin is received
next if ($test->{'name'} eq 'main.innodb_bug44369');
# Copy test options # Copy test options
my $new_test= My::Test->new(); my $new_test= My::Test->new();
while (my ($key, $value) = each(%$test)) while (my ($key, $value) = each(%$test))
......
create table bug44369 (DB_ROW_ID int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
create table bug44369 (db_row_id int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
show errors;
Level Code Message
Error 1005 Error creating table 'test/bug44369' with column name 'db_row_id'. 'db_row_id' is a reserved name. Please try to re-create the table with a different column name.
Error 1005 Can't create table 'test.bug44369' (errno: -1)
create table bug44369 (db_TRX_Id int) engine=innodb;
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
show errors;
Level Code Message
Error 1005 Error creating table 'test/bug44369' with column name 'db_TRX_Id'. 'db_TRX_Id' is a reserved name. Please try to re-create the table with a different column name.
Error 1005 Can't create table 'test.bug44369' (errno: -1)
create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb;
ERROR HY000: Can't create table 'test.bug46000' (errno: -1)
create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb;
ERROR HY000: Can't create table 'test.bug46000' (errno: -1)
show errors;
Level Code Message
Error 1005 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Error 1005 Can't create table 'test.bug46000' (errno: -1)
create table bug46000(id int) engine=innodb;
create index GEN_CLUST_INDEX on bug46000(id);
ERROR HY000: Can't create table '#sql-temporary' (errno: -1)
show errors;
Level Code Message
Error 1005 Cannot Create Index with name 'GEN_CLUST_INDEX'. The name is reserved for the system default primary index.
Error 1005 Can't create table '#sql-temporary' (errno: -1)
create index idx on bug46000(id);
drop table bug46000;
...@@ -385,9 +385,10 @@ name dept ...@@ -385,9 +385,10 @@ name dept
rs5 cs10 rs5 cs10
rs5 cs9 rs5 cs9
DELETE FROM t1; DELETE FROM t1;
# Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746).
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range name name 44 NULL 2 Using where; Using index for group-by 1 SIMPLE t1 range name name 44 NULL # Using where; Using index for group-by
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
name dept name dept
DROP TABLE t1; DROP TABLE t1;
......
# This is the test for bug 44369. We should
# block table creation with columns match
# some innodb internal reserved key words,
# both case sensitively and insensitely.
--source include/have_innodb.inc
# This create table operation should fail.
--error ER_CANT_CREATE_TABLE
create table bug44369 (DB_ROW_ID int) engine=innodb;
# This create should fail as well
--error ER_CANT_CREATE_TABLE
create table bug44369 (db_row_id int) engine=innodb;
show errors;
--error ER_CANT_CREATE_TABLE
create table bug44369 (db_TRX_Id int) engine=innodb;
show errors;
# This is the test for bug 46000. We shall
# block any index creation with the name of
# "GEN_CLUST_INDEX", which is the reserved
# name for innodb default primary index.
--source include/have_innodb.inc
# This 'create table' operation should fail because of
# using the reserve name as its index name.
--error ER_CANT_CREATE_TABLE
create table bug46000(`id` int,key `GEN_CLUST_INDEX`(`id`))engine=innodb;
# Mixed upper/lower case of the reserved key words
--error ER_CANT_CREATE_TABLE
create table bug46000(`id` int, key `GEN_clust_INDEX`(`id`))engine=innodb;
show errors;
create table bug46000(id int) engine=innodb;
# This 'create index' operation should fail.
--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
--error ER_CANT_CREATE_TABLE
create index GEN_CLUST_INDEX on bug46000(id);
--replace_regex /'[^']*test.#sql-[0-9a-f_]*'/'#sql-temporary'/
show errors;
# This 'create index' operation should succeed, no
# temp table left from last failed create index
# operation.
create index idx on bug46000(id);
drop table bug46000;
...@@ -1268,7 +1268,7 @@ dict_col_name_is_reserved( ...@@ -1268,7 +1268,7 @@ dict_col_name_is_reserved(
ulint i; ulint i;
for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) { for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) {
if (strcmp(name, reserved_names[i]) == 0) { if (innobase_strcasecmp(name, reserved_names[i]) == 0) {
return(TRUE); return(TRUE);
} }
......
...@@ -164,8 +164,27 @@ static handler *innobase_create_handler(handlerton *hton, ...@@ -164,8 +164,27 @@ static handler *innobase_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
MEM_ROOT *mem_root); MEM_ROOT *mem_root);
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if index name matches a
reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name); /* in: table name */
static const char innobase_hton_name[]= "InnoDB"; static const char innobase_hton_name[]= "InnoDB";
/* "GEN_CLUST_INDEX" is the name reserved for Innodb default
system primary index. */
static const char innobase_index_reserve_name[]= "GEN_CLUST_INDEX";
/** @brief Initialize the default value of innodb_commit_concurrency. /** @brief Initialize the default value of innodb_commit_concurrency.
Once InnoDB is running, the innodb_commit_concurrency must not change Once InnoDB is running, the innodb_commit_concurrency must not change
...@@ -818,7 +837,22 @@ innobase_get_cset_width( ...@@ -818,7 +837,22 @@ innobase_get_cset_width(
*mbminlen = cs->mbminlen; *mbminlen = cs->mbminlen;
*mbmaxlen = cs->mbmaxlen; *mbmaxlen = cs->mbmaxlen;
} else { } else {
if (current_thd
&& (thd_sql_command(current_thd) == SQLCOM_DROP_TABLE)) {
/* Fix bug#46256: allow tables to be dropped if the
collation is not found, but issue a warning. */
if ((global_system_variables.log_warnings)
&& (cset != 0)){
sql_print_warning(
"Unknown collation #%lu.", cset);
}
} else {
ut_a(cset == 0); ut_a(cset == 0);
}
*mbminlen = *mbmaxlen = 0; *mbminlen = *mbmaxlen = 0;
} }
} }
...@@ -5147,6 +5181,28 @@ create_table_def( ...@@ -5147,6 +5181,28 @@ create_table_def(
} }
} }
/* First check whether the column to be added has a
system reserved name. */
if (dict_col_name_is_reserved(field->field_name)){
push_warning_printf(
(THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_CANT_CREATE_TABLE,
"Error creating table '%s' with "
"column name '%s'. '%s' is a "
"reserved name. Please try to "
"re-create the table with a "
"different column name.",
table->name, (char*) field->field_name,
(char*) field->field_name);
dict_mem_table_free(table);
trx_commit_for_mysql(trx);
error = DB_ERROR;
goto error_ret;
}
dict_mem_table_add_col(table, table->heap, dict_mem_table_add_col(table, table->heap,
(char*) field->field_name, (char*) field->field_name,
col_type, col_type,
...@@ -5162,6 +5218,7 @@ create_table_def( ...@@ -5162,6 +5218,7 @@ create_table_def(
innodb_check_for_record_too_big_error(flags & DICT_TF_COMPACT, error); innodb_check_for_record_too_big_error(flags & DICT_TF_COMPACT, error);
error_ret:
error = convert_error_code_to_mysql(error, NULL); error = convert_error_code_to_mysql(error, NULL);
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -5199,6 +5256,9 @@ create_index( ...@@ -5199,6 +5256,9 @@ create_index(
n_fields = key->key_parts; n_fields = key->key_parts;
/* Assert that "GEN_CLUST_INDEX" cannot be used as non-primary index */
ut_a(innobase_strcasecmp(key->name, innobase_index_reserve_name) != 0);
ind_type = 0; ind_type = 0;
if (key_num == form->s->primary_key) { if (key_num == form->s->primary_key) {
...@@ -5311,8 +5371,8 @@ create_clustered_index_when_no_primary( ...@@ -5311,8 +5371,8 @@ create_clustered_index_when_no_primary(
/* We pass 0 as the space id, and determine at a lower level the space /* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */ id where to store the table */
index = dict_mem_index_create(table_name,
index = dict_mem_index_create(table_name, "GEN_CLUST_INDEX", innobase_index_reserve_name,
0, DICT_CLUSTERED, 0); 0, DICT_CLUSTERED, 0);
error = row_create_index_for_mysql(index, trx, NULL); error = row_create_index_for_mysql(index, trx, NULL);
...@@ -5444,14 +5504,6 @@ ha_innobase::create( ...@@ -5444,14 +5504,6 @@ ha_innobase::create(
flags |= DICT_TF_COMPACT; flags |= DICT_TF_COMPACT;
} }
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
flags);
if (error) {
goto cleanup;
}
/* Look for a primary key */ /* Look for a primary key */
primary_key_no= (form->s->primary_key != MAX_KEY ? primary_key_no= (form->s->primary_key != MAX_KEY ?
...@@ -5463,6 +5515,22 @@ ha_innobase::create( ...@@ -5463,6 +5515,22 @@ ha_innobase::create(
DBUG_ASSERT(primary_key_no == -1 || primary_key_no == 0); DBUG_ASSERT(primary_key_no == -1 || primary_key_no == 0);
/* Check for name conflicts (with reserved name) for
any user indices to be created. */
if (innobase_index_name_is_reserved(trx, form, norm_name)) {
error = -1;
goto cleanup;
}
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
flags);
if (error) {
goto cleanup;
}
/* Create the keys */ /* Create the keys */
if (form->s->keys == 0 || primary_key_no == -1) { if (form->s->keys == 0 || primary_key_no == -1) {
...@@ -8409,6 +8477,46 @@ static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) ...@@ -8409,6 +8477,46 @@ static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
return 0; return 0;
} }
/***********************************************************************
This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
this function pushes an error message to the client, and returns true. */
static
bool
innobase_index_name_is_reserved(
/*============================*/
/* out: true if an index name
matches the reserved name */
const trx_t* trx, /* in: InnoDB transaction handle */
const TABLE* form, /* in: information on table
columns and indexes */
const char* norm_name) /* in: table name */
{
KEY* key;
uint key_num; /* index number */
for (key_num = 0; key_num < form->s->keys; key_num++) {
key = form->key_info + key_num;
if (innobase_strcasecmp(key->name,
innobase_index_reserve_name) == 0) {
/* Push warning to mysql */
push_warning_printf((THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_CANT_CREATE_TABLE,
"Cannot Create Index with name "
"'%s'. The name is reserved "
"for the system default primary "
"index.",
innobase_index_reserve_name);
return(true);
}
}
return(false);
}
static SHOW_VAR innodb_status_variables_export[]= { static SHOW_VAR innodb_status_variables_export[]= {
{"Innodb", (char*) &show_innodb_vars, SHOW_FUNC}, {"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
{NullS, NullS, SHOW_LONG} {NullS, NullS, SHOW_LONG}
......
...@@ -1788,7 +1788,6 @@ row_create_table_for_mysql( ...@@ -1788,7 +1788,6 @@ row_create_table_for_mysql(
const char* table_name; const char* table_name;
ulint table_name_len; ulint table_name_len;
ulint err; ulint err;
ulint i;
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
...@@ -1827,18 +1826,6 @@ row_create_table_for_mysql( ...@@ -1827,18 +1826,6 @@ row_create_table_for_mysql(
return(DB_ERROR); return(DB_ERROR);
} }
/* Check that no reserved column names are used. */
for (i = 0; i < dict_table_get_n_user_cols(table); i++) {
if (dict_col_name_is_reserved(
dict_table_get_col_name(table, i))) {
dict_mem_table_free(table);
trx_commit_for_mysql(trx);
return(DB_ERROR);
}
}
trx_start_if_not_started(trx); trx_start_if_not_started(trx);
/* The table name is prefixed with the database name and a '/'. /* The table name is prefixed with the database name and a '/'.
......
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