mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 22:34:18 +01:00
branches/zip: Report duplicate table names
to the client connection, not to the error log. This change will allow innodb-index.test to be re-enabled. It was previously disabled, because mysql-test-run does not like output in the error log. row_create_table_for_mysql(): Do not output anything to the error log when reporting DB_DUPLICATE_KEY. Let the caller report the error. Add a TODO comment that the dict_table_t object is apparently not freed when an error occurs. create_table_def(): Convert InnoDB table names to the character set of the client connection for reporting. Use my_error(ER_WRONG_COLUMN_NAME) for reporting reserved column names. Report my_error(ER_TABLE_EXISTS_ERROR) when row_create_table_for_mysql() returns DB_DUPLICATE_KEY. rb://206
This commit is contained in:
parent
f3efc5f306
commit
06dafb4a39
7 changed files with 20 additions and 118 deletions
|
@ -5731,17 +5731,8 @@ 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_WARN,
|
||||
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);
|
||||
my_error(ER_WRONG_COLUMN_NAME, MYF(0),
|
||||
field->field_name);
|
||||
|
||||
dict_mem_table_free(table);
|
||||
trx_commit_for_mysql(trx);
|
||||
|
@ -5763,6 +5754,14 @@ create_table_def(
|
|||
|
||||
error = row_create_table_for_mysql(table, trx);
|
||||
|
||||
if (error == DB_DUPLICATE_KEY) {
|
||||
char buf[100];
|
||||
innobase_convert_identifier(buf, sizeof buf,
|
||||
table_name, strlen(table_name),
|
||||
trx->mysql_thd, TRUE);
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), buf);
|
||||
}
|
||||
|
||||
error_ret:
|
||||
error = convert_error_code_to_mysql(error, flags, NULL);
|
||||
|
||||
|
|
|
@ -3088,7 +3088,7 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|||
commit;
|
||||
drop table t1, t2, t3, t5, t6, t8, t9;
|
||||
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
|
||||
ERROR HY000: Can't create table 'test.t1' (errno: -1)
|
||||
ERROR 42000: Incorrect column name 'DB_ROW_ID'
|
||||
CREATE TABLE t1 (
|
||||
a BIGINT(20) NOT NULL,
|
||||
PRIMARY KEY (a)
|
||||
|
|
|
@ -2264,7 +2264,7 @@ disconnect j;
|
|||
drop table t1, t2, t3, t5, t6, t8, t9;
|
||||
|
||||
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
|
||||
--error 1005
|
||||
--error ER_WRONG_COLUMN_NAME
|
||||
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
|
||||
|
||||
#
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
create table bug44369 (DB_ROW_ID int) engine=innodb;
|
||||
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
|
||||
ERROR 42000: Incorrect column name 'DB_ROW_ID'
|
||||
create table bug44369 (db_row_id int) engine=innodb;
|
||||
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 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)
|
||||
ERROR 42000: Incorrect column name 'db_row_id'
|
||||
create table bug44369 (db_TRX_Id int) engine=innodb;
|
||||
ERROR HY000: Can't create table 'test.bug44369' (errno: -1)
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 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)
|
||||
ERROR 42000: Incorrect column name 'db_TRX_Id'
|
||||
|
|
|
@ -6,16 +6,12 @@
|
|||
--source include/have_innodb.inc
|
||||
|
||||
# This create table operation should fail.
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
--error ER_WRONG_COLUMN_NAME
|
||||
create table bug44369 (DB_ROW_ID int) engine=innodb;
|
||||
|
||||
# This create should fail as well
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
--error ER_WRONG_COLUMN_NAME
|
||||
create table bug44369 (db_row_id int) engine=innodb;
|
||||
|
||||
show warnings;
|
||||
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
--error ER_WRONG_COLUMN_NAME
|
||||
create table bug44369 (db_TRX_Id int) engine=innodb;
|
||||
|
||||
show warnings;
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
This part of the innodb-index test causes mysqld to print some warnings
|
||||
and subsequently the whole mysql-test suite to fail.
|
||||
|
||||
A permanent solution is probably to remove the printouts from the source
|
||||
code or to somehow tell the mysql-test suite that warnings are expected.
|
||||
Currently we simply do not execute the problematic tests. Please
|
||||
coordinate a permanent solution with Marko, who added those tests.
|
||||
|
||||
This cannot be proposed to MySQL because it touches files that are not
|
||||
in the MySQL source repository.
|
||||
|
||||
Index: storage/innobase/mysql-test/innodb-index.result
|
||||
===================================================================
|
||||
--- storage/innobase/mysql-test/innodb-index.result (revision 2870)
|
||||
+++ storage/innobase/mysql-test/innodb-index.result (working copy)
|
||||
@@ -43,19 +43,12 @@ t1 CREATE TABLE `t1` (
|
||||
`b` int(11) DEFAULT NULL,
|
||||
`c` char(10) NOT NULL,
|
||||
`d` varchar(20) DEFAULT NULL,
|
||||
KEY `d2` (`d`),
|
||||
KEY `b` (`b`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
-CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
-alter table t1 add unique index (c), add index (d);
|
||||
-ERROR HY000: Table 'test.t1#1' already exists
|
||||
-rename table `t1#1` to `t1#2`;
|
||||
-alter table t1 add unique index (c), add index (d);
|
||||
-ERROR HY000: Table 'test.t1#2' already exists
|
||||
-drop table `t1#2`;
|
||||
alter table t1 add unique index (c), add index (d);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) NOT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
Index: storage/innobase/mysql-test/innodb-index.test
|
||||
===================================================================
|
||||
--- storage/innobase/mysql-test/innodb-index.test (revision 2870)
|
||||
+++ storage/innobase/mysql-test/innodb-index.test (working copy)
|
||||
@@ -14,22 +14,12 @@ select * from t1 force index (d2) order
|
||||
--error ER_DUP_ENTRY
|
||||
alter table t1 add unique index (b);
|
||||
show create table t1;
|
||||
alter table t1 add index (b);
|
||||
show create table t1;
|
||||
|
||||
-# Check how existing tables interfere with temporary tables.
|
||||
-CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
-
|
||||
---error 156
|
||||
-alter table t1 add unique index (c), add index (d);
|
||||
-rename table `t1#1` to `t1#2`;
|
||||
---error 156
|
||||
-alter table t1 add unique index (c), add index (d);
|
||||
-drop table `t1#2`;
|
||||
-
|
||||
alter table t1 add unique index (c), add index (d);
|
||||
show create table t1;
|
||||
explain select * from t1 force index(c) order by c;
|
||||
alter table t1 add primary key (a), drop index c;
|
||||
show create table t1;
|
||||
--error ER_MULTIPLE_PRI_KEY
|
|
@ -1880,6 +1880,8 @@ err_exit:
|
|||
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
|
||||
trx->error_state = DB_SUCCESS;
|
||||
trx_general_rollback_for_mysql(trx, NULL);
|
||||
/* TO DO: free table? The code below will dereference
|
||||
table->name, though. */
|
||||
}
|
||||
|
||||
switch (err) {
|
||||
|
@ -1898,31 +1900,6 @@ err_exit:
|
|||
break;
|
||||
|
||||
case DB_DUPLICATE_KEY:
|
||||
ut_print_timestamp(stderr);
|
||||
fputs(" InnoDB: Error: table ", stderr);
|
||||
ut_print_name(stderr, trx, TRUE, table->name);
|
||||
fputs(" already exists in InnoDB internal\n"
|
||||
"InnoDB: data dictionary. Have you deleted"
|
||||
" the .frm file\n"
|
||||
"InnoDB: and not used DROP TABLE?"
|
||||
" Have you used DROP DATABASE\n"
|
||||
"InnoDB: for InnoDB tables in"
|
||||
" MySQL version <= 3.23.43?\n"
|
||||
"InnoDB: See the Restrictions section"
|
||||
" of the InnoDB manual.\n"
|
||||
"InnoDB: You can drop the orphaned table"
|
||||
" inside InnoDB by\n"
|
||||
"InnoDB: creating an InnoDB table with"
|
||||
" the same name in another\n"
|
||||
"InnoDB: database and copying the .frm file"
|
||||
" to the current database.\n"
|
||||
"InnoDB: Then MySQL thinks the table exists,"
|
||||
" and DROP TABLE will\n"
|
||||
"InnoDB: succeed.\n"
|
||||
"InnoDB: You can look for further help from\n"
|
||||
"InnoDB: " REFMAN "innodb-troubleshooting.html\n",
|
||||
stderr);
|
||||
|
||||
/* We may also get err == DB_ERROR if the .ibd file for the
|
||||
table already exists */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue