Merge into mysql-trunk-merge..

This commit is contained in:
Davi Arnaut 2010-07-19 16:03:59 -03:00
commit ce2403e6ee
8 changed files with 98 additions and 12 deletions

View File

@ -0,0 +1,3 @@
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);
ERROR HY000: Can't create table 'test.table_54044' (errno: -1)

View File

@ -2538,6 +2538,14 @@ ORDER BY f1 DESC LIMIT 5;
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 f2,f4 f4 1 NULL 11 Using where 1 SIMPLE t1 range f2,f4 f4 1 NULL 11 Using where
DROP TABLE t1; DROP TABLE t1;
#
# Bug#54117 crash in thr_multi_unlock, temporary table
#
CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB;
LOCK TABLES t1 READ;
ALTER TABLE t1 COMMENT 'test';
UNLOCK TABLES;
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
# #
# Test for bug #39932 "create table fails if column for FK is in different # Test for bug #39932 "create table fails if column for FK is in different

View File

@ -0,0 +1,11 @@
# This is the test for bug #54044. Special handle MYSQL_TYPE_NULL type
# during create table, so it will not trigger assertion failure.
--source include/have_innodb.inc
# This 'create table' operation should fail because of
# using NULL datatype
--error ER_CANT_CREATE_TABLE
CREATE TEMPORARY TABLE table_54044 ENGINE = INNODB
AS SELECT IF(NULL IS NOT NULL, NULL, NULL);

View File

@ -737,6 +737,20 @@ ORDER BY f1 DESC LIMIT 5;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#54117 crash in thr_multi_unlock, temporary table
--echo #
CREATE TEMPORARY TABLE t1(a INT) ENGINE = InnoDB;
LOCK TABLES t1 READ;
ALTER TABLE t1 COMMENT 'test';
UNLOCK TABLES;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests

View File

@ -7339,13 +7339,23 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (table->s->tmp_table != NO_TMP_TABLE) if (table->s->tmp_table != NO_TMP_TABLE)
{ {
/* Close lock if this is a transactional table */ /* Close lock if this is a transactional table */
if (thd->lock && if (thd->lock)
! (thd->locked_tables_mode == LTM_LOCK_TABLES || {
thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) if (thd->locked_tables_mode != LTM_LOCK_TABLES &&
thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES)
{ {
mysql_unlock_tables(thd, thd->lock); mysql_unlock_tables(thd, thd->lock);
thd->lock=0; thd->lock=0;
} }
else
{
/*
If LOCK TABLES list is not empty and contains this table,
unlock the table and remove the table from this list.
*/
mysql_lock_remove(thd, thd->lock, table);
}
}
/* Remove link to old table and rename the new one */ /* Remove link to old table and rename the new one */
close_temporary_table(thd, table, 1, 1); close_temporary_table(thd, table, 1, 1);
/* Should pass the 'new_name' as we store table name in the cache */ /* Should pass the 'new_name' as we store table name in the cache */

View File

@ -240,17 +240,29 @@ dict_build_table_def_step(
ibool is_path; ibool is_path;
mtr_t mtr; mtr_t mtr;
ulint space = 0; ulint space = 0;
ibool file_per_table;
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
table = node->table; table = node->table;
dict_hdr_get_new_id(&table->id, NULL, /* Cache the global variable "srv_file_per_table" to
srv_file_per_table ? &space : NULL); a local variable before using it. Please note
"srv_file_per_table" is not under dict_sys mutex
protection, and could be changed while executing
this function. So better to cache the current value
to a local variable, and all future reference to
"srv_file_per_table" should use this local variable. */
file_per_table = srv_file_per_table;
dict_hdr_get_new_id(&table->id, NULL, NULL);
thr_get_trx(thr)->table_id = table->id; thr_get_trx(thr)->table_id = table->id;
if (srv_file_per_table) { if (file_per_table) {
/* Get a new space id if srv_file_per_table is set */
dict_hdr_get_new_id(NULL, NULL, &space);
if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) { if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) {
return(DB_ERROR); return(DB_ERROR);
} }

View File

@ -4128,6 +4128,11 @@ get_innobase_type_from_mysql_type(
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
return(DATA_BLOB); return(DATA_BLOB);
case MYSQL_TYPE_NULL:
/* MySQL currently accepts "NULL" datatype, but will
reject such datatype in the next release. We will cope
with it and not trigger assertion failure in 5.1 */
break;
default: default:
ut_error; ut_error;
} }
@ -6176,6 +6181,21 @@ create_table_def(
col_type = get_innobase_type_from_mysql_type(&unsigned_type, col_type = get_innobase_type_from_mysql_type(&unsigned_type,
field); field);
if (!col_type) {
push_warning_printf(
(THD*) trx->mysql_thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
ER_CANT_CREATE_TABLE,
"Error creating table '%s' with "
"column '%s'. Please check its "
"column type and try to re-create "
"the table with an appropriate "
"column type.",
table->name, (char*) field->field_name);
goto err_col;
}
if (field->null_ptr) { if (field->null_ptr) {
nulls_allowed = 0; nulls_allowed = 0;
} else { } else {
@ -6233,7 +6253,7 @@ create_table_def(
if (dict_col_name_is_reserved(field->field_name)){ if (dict_col_name_is_reserved(field->field_name)){
my_error(ER_WRONG_COLUMN_NAME, MYF(0), my_error(ER_WRONG_COLUMN_NAME, MYF(0),
field->field_name); field->field_name);
err_col:
dict_mem_table_free(table); dict_mem_table_free(table);
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);

View File

@ -1445,7 +1445,11 @@ try_again:
/* When srv_file_per_table is on, file creation failure may not /* When srv_file_per_table is on, file creation failure may not
be critical to the whole instance. Do not crash the server in be critical to the whole instance. Do not crash the server in
case of unknown errors. */ case of unknown errors.
Please note "srv_file_per_table" is a global variable with
no explicit synchronization protection. It could be
changed during this execution path. It might not have the
same value as the one when building the table definition */
if (srv_file_per_table) { if (srv_file_per_table) {
retry = os_file_handle_error_no_exit(name, retry = os_file_handle_error_no_exit(name,
create_mode == OS_FILE_CREATE ? create_mode == OS_FILE_CREATE ?
@ -1532,7 +1536,11 @@ try_again:
/* When srv_file_per_table is on, file creation failure may not /* When srv_file_per_table is on, file creation failure may not
be critical to the whole instance. Do not crash the server in be critical to the whole instance. Do not crash the server in
case of unknown errors. */ case of unknown errors.
Please note "srv_file_per_table" is a global variable with
no explicit synchronization protection. It could be
changed during this execution path. It might not have the
same value as the one when building the table definition */
if (srv_file_per_table) { if (srv_file_per_table) {
retry = os_file_handle_error_no_exit(name, retry = os_file_handle_error_no_exit(name,
create_mode == OS_FILE_CREATE ? create_mode == OS_FILE_CREATE ?