Skip to content

Commit

Permalink
Fix blocking MyISAM tables when IF NOT EXISTS is used
Browse files Browse the repository at this point in the history
Summary:
The check to block creating MyISAM tables suffered
from an error with operator precedence, which prevented it
from blocking creation when the user specified IF NOT EXISTS.

Test Plan: Modified existing test to include case.

Reviewers: santoshb

Reviewed By: santoshb
  • Loading branch information
jtolmer committed Mar 27, 2015
1 parent 942fd24 commit 85dc2db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mysql-test/r/create_myisam_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ create table myisam_table (a int) ENGINE=MYISAM;
ERROR HY000: Non-temporary MyISAM tables cannot be created outside mysql schema.
create table mysql.myisam_table (a int) ENGINE=MYISAM;
create table innodb_table (a int) ENGINE=INNODB;
create table if not exists mysql.myisam_table (a int) ENGINE=MYISAM;
Warnings:
Note 1050 Table 'myisam_table' already exists
create table if not exists mysql.myisam_table2 (a int) ENGINE=MYISAM;
create table if not exists myisam_table (a int) ENGINE=MYISAM;
ERROR HY000: Non-temporary MyISAM tables cannot be created outside mysql schema.
alter table innodb_table ENGINE=MYISAM;
ERROR HY000: Non-temporary MyISAM tables cannot be created outside mysql schema.
alter table mysql.mysql_table ENGINE=MYISAM;
Expand All @@ -19,3 +25,4 @@ alter table test.innodb_table ENGINE=MYISAM;
ERROR HY000: Non-temporary MyISAM tables cannot be created outside mysql schema.
drop table mysql_table;
drop table myisam_table;
drop table myisam_table2;
7 changes: 7 additions & 0 deletions mysql-test/t/create_myisam_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ create table myisam_table (a int) ENGINE=MYISAM;
create table mysql.myisam_table (a int) ENGINE=MYISAM;
create table innodb_table (a int) ENGINE=INNODB;

# Check behavior when called with IF NOT EXISTS
create table if not exists mysql.myisam_table (a int) ENGINE=MYISAM;
create table if not exists mysql.myisam_table2 (a int) ENGINE=MYISAM;
-- error ER_BLOCK_MYISAM_TABLES
create table if not exists myisam_table (a int) ENGINE=MYISAM;

-- error ER_BLOCK_MYISAM_TABLES
alter table innodb_table ENGINE=MYISAM;
alter table mysql.mysql_table ENGINE=MYISAM;
Expand All @@ -21,3 +27,4 @@ use mysql;
alter table test.innodb_table ENGINE=MYISAM;
drop table mysql_table;
drop table myisam_table;
drop table myisam_table2;
2 changes: 1 addition & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8473,7 +8473,7 @@ bool block_myisam_tables(HA_CREATE_INFO *create_info,
strcmp(table_list->db, "mtr") &&
create_info->db_type &&
create_info->db_type->db_type == DB_TYPE_MYISAM &&
!create_info->options & HA_LEX_CREATE_TMP_TABLE)
!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
return true;
return false;
}
Expand Down

0 comments on commit 85dc2db

Please sign in to comment.