summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-27 12:25:30 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-29 16:54:05 +0300
commit622d21e2b8418eca6609a31f060bf9523c2d81dc (patch)
treea2f1846e9ad200b20b4d9294636e0b67d728694e
parentb922741074bd2bf2b56b0381d1f32af0a3df4063 (diff)
downloadmariadb-git-622d21e2b8418eca6609a31f060bf9523c2d81dc.tar.gz
row_drop_table_for_mysql(): Use a constant string
It does not hurt to delete non-existing records from SYS_TABLESPACES and SYS_DATAFILES. Because MariaDB does not support CREATE TABLESPACE, only the system tablespace (space_id=0) can contain multiple tables. But, there are no entries for the system tablespace in these tables (which actually are stored inside the system tablespace).
-rw-r--r--storage/innobase/row/row0mysql.cc64
1 files changed, 29 insertions, 35 deletions
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index cd3e7253298..1a065123ed7 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -3638,48 +3638,46 @@ row_drop_table_for_mysql(
pars_info_add_str_literal(info, "table_name", name);
- std::basic_string<char, std::char_traits<char>,
- ut_allocator<char> > sql;
- sql.reserve(2000);
-
- sql = "PROCEDURE DROP_TABLE_PROC () IS\n"
+ err = que_eval_sql(
+ info,
+ "PROCEDURE DROP_TABLE_PROC () IS\n"
"sys_foreign_id CHAR;\n"
"table_id CHAR;\n"
"index_id CHAR;\n"
"foreign_id CHAR;\n"
"space_id INT;\n"
- "found INT;\n";
+ "found INT;\n"
- sql += "DECLARE CURSOR cur_fk IS\n"
+ "DECLARE CURSOR cur_fk IS\n"
"SELECT ID FROM SYS_FOREIGN\n"
"WHERE FOR_NAME = :table_name\n"
"AND TO_BINARY(FOR_NAME)\n"
" = TO_BINARY(:table_name)\n"
- "LOCK IN SHARE MODE;\n";
+ "LOCK IN SHARE MODE;\n"
- sql += "DECLARE CURSOR cur_idx IS\n"
+ "DECLARE CURSOR cur_idx IS\n"
"SELECT ID FROM SYS_INDEXES\n"
"WHERE TABLE_ID = table_id\n"
- "LOCK IN SHARE MODE;\n";
+ "LOCK IN SHARE MODE;\n"
- sql += "BEGIN\n";
+ "BEGIN\n"
- sql += "SELECT ID INTO table_id\n"
+ "SELECT ID INTO table_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = :table_name\n"
"LOCK IN SHARE MODE;\n"
"IF (SQL % NOTFOUND) THEN\n"
" RETURN;\n"
- "END IF;\n";
+ "END IF;\n"
- sql += "SELECT SPACE INTO space_id\n"
+ "SELECT SPACE INTO space_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = :table_name;\n"
"IF (SQL % NOTFOUND) THEN\n"
" RETURN;\n"
- "END IF;\n";
+ "END IF;\n"
- sql += "found := 1;\n"
+ "found := 1;\n"
"SELECT ID INTO sys_foreign_id\n"
"FROM SYS_TABLES\n"
"WHERE NAME = 'SYS_FOREIGN'\n"
@@ -3693,9 +3691,9 @@ row_drop_table_for_mysql(
"IF (:table_name = 'SYS_FOREIGN_COLS') \n"
"THEN\n"
" found := 0;\n"
- "END IF;\n";
+ "END IF;\n"
- sql += "OPEN cur_fk;\n"
+ "OPEN cur_fk;\n"
"WHILE found = 1 LOOP\n"
" FETCH cur_fk INTO foreign_id;\n"
" IF (SQL % NOTFOUND) THEN\n"
@@ -3708,9 +3706,9 @@ row_drop_table_for_mysql(
" WHERE ID = foreign_id;\n"
" END IF;\n"
"END LOOP;\n"
- "CLOSE cur_fk;\n";
+ "CLOSE cur_fk;\n"
- sql += "found := 1;\n"
+ "found := 1;\n"
"OPEN cur_idx;\n"
"WHILE found = 1 LOOP\n"
" FETCH cur_idx INTO index_id;\n"
@@ -3724,26 +3722,22 @@ row_drop_table_for_mysql(
" AND TABLE_ID = table_id;\n"
" END IF;\n"
"END LOOP;\n"
- "CLOSE cur_idx;\n";
+ "CLOSE cur_idx;\n"
- sql += "DELETE FROM SYS_COLUMNS\n"
+ "DELETE FROM SYS_COLUMNS\n"
"WHERE TABLE_ID = table_id;\n"
"DELETE FROM SYS_TABLES\n"
- "WHERE NAME = :table_name;\n";
-
- if (dict_table_is_file_per_table(table)) {
- sql += "DELETE FROM SYS_TABLESPACES\n"
- "WHERE SPACE = space_id;\n"
- "DELETE FROM SYS_DATAFILES\n"
- "WHERE SPACE = space_id;\n";
- }
-
- sql += "DELETE FROM SYS_VIRTUAL\n"
- "WHERE TABLE_ID = table_id;\n";
+ "WHERE NAME = :table_name;\n"
- sql += "END;\n";
+ "DELETE FROM SYS_TABLESPACES\n"
+ "WHERE SPACE = space_id;\n"
+ "DELETE FROM SYS_DATAFILES\n"
+ "WHERE SPACE = space_id;\n"
- err = que_eval_sql(info, sql.c_str(), FALSE, trx);
+ "DELETE FROM SYS_VIRTUAL\n"
+ "WHERE TABLE_ID = table_id;\n"
+ "END;\n",
+ FALSE, trx);
} else {
page_no = page_nos;
for (dict_index_t* index = dict_table_get_first_index(table);