summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnamalai Gurusami <annamalai.gurusami@oracle.com>2015-09-22 06:21:13 +0200
committerAnnamalai Gurusami <annamalai.gurusami@oracle.com>2015-09-22 06:21:13 +0200
commit8ea80ecfeb88846ee47c65011eb9ff7eddab84b3 (patch)
tree493170cd809df24086c32bc045f471e21d06a1dc
parent259cf3dc607dd0112d44c4647b07a3024cee268e (diff)
downloadmariadb-git-8ea80ecfeb88846ee47c65011eb9ff7eddab84b3.tar.gz
Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE
Note: Backporting the patch from mysql-5.6. Problem: A CREATE TABLE with an invalid table name is detected at SQL layer. So the table name is reset to an empty string. But the storage engine is called with this empty table name. The table name is specified as "database/table". So, in the given scenario we get only "database/". Solution: Within InnoDB, detect this error and report it to higher layer. rb#9274 approved by jimmy.
-rw-r--r--mysql-test/suite/innodb/r/dropdb.result9
-rw-r--r--mysql-test/suite/innodb/t/dropdb.test12
-rw-r--r--storage/innobase/handler/ha_innodb.cc12
3 files changed, 32 insertions, 1 deletions
diff --git a/mysql-test/suite/innodb/r/dropdb.result b/mysql-test/suite/innodb/r/dropdb.result
new file mode 100644
index 00000000000..f8890784bfc
--- /dev/null
+++ b/mysql-test/suite/innodb/r/dropdb.result
@@ -0,0 +1,9 @@
+#
+# Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE
+#
+set session default_storage_engine=innodb;
+create database `b`;
+use `b`;
+create table `#mysql50#q.q` select 1;
+ERROR HY000: Can't create table 'b.#mysql50#q.q' (errno: 1103)
+drop database `b`;
diff --git a/mysql-test/suite/innodb/t/dropdb.test b/mysql-test/suite/innodb/t/dropdb.test
new file mode 100644
index 00000000000..d275b809d00
--- /dev/null
+++ b/mysql-test/suite/innodb/t/dropdb.test
@@ -0,0 +1,12 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE
+--echo #
+
+set session default_storage_engine=innodb;
+create database `b`;
+use `b`;
+--error ER_CANT_CREATE_TABLE
+create table `#mysql50#q.q` select 1;
+drop database `b`;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b8ec8f60f28..1c6763ef93a 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -6529,7 +6529,8 @@ create_table_def(
/* MySQL does the name length check. But we do additional check
on the name length here */
- if (strlen(table_name) > MAX_FULL_NAME_LEN) {
+ const size_t table_name_len = strlen(table_name);
+ if (table_name_len > MAX_FULL_NAME_LEN) {
push_warning_printf(
(THD*) trx->mysql_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_TABLE_NAME,
@@ -6538,6 +6539,15 @@ create_table_def(
DBUG_RETURN(ER_TABLE_NAME);
}
+ if (table_name[table_name_len - 1] == '/') {
+ push_warning_printf(
+ (THD*) trx->mysql_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_TABLE_NAME,
+ "InnoDB: Table name is empty");
+
+ DBUG_RETURN(ER_WRONG_TABLE_NAME);
+ }
+
n_cols = form->s->fields;
/* We pass 0 as the space id, and determine at a lower level the space