Commit 8ea80ecf authored by Annamalai Gurusami's avatar Annamalai Gurusami

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.
parent 259cf3dc
#
# 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`;
--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`;
......@@ -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
......
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