diff options
author | unknown <marko@hundin.mysql.fi> | 2005-04-07 12:16:41 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-04-07 12:16:41 +0300 |
commit | f7356d73910f3df3dedf99d2fafd6413cdb6d33d (patch) | |
tree | 7034173189c0c268893de96cb77f0e5983ac1a94 /sql/ha_innodb.cc | |
parent | 0d17aea729e9f33071eee20fbc0b91fd002ca9bb (diff) | |
download | mariadb-git-f7356d73910f3df3dedf99d2fafd6413cdb6d33d.tar.gz |
InnoDB: Prevent ALTER TABLE ... ENGINE=...
if there are foreign key constraints on the table. (Bug #5574)
sql/ha_innodb.cc:
Add method can_switch_engines()
sql/ha_innodb.h:
Add method can_switch_engines()
sql/handler.h:
Add method can_switch_engines()
sql/sql_table.cc:
Check handler::can_switch_engines() before switching storage engines
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r-- | sql/ha_innodb.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 3e3a48f4ab9..322d5188a75 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4789,6 +4789,32 @@ ha_innobase::get_foreign_key_create_info(void) return(str); } +/********************************************************************* +Checks if ALTER TABLE may change the storage engine of the table. +Changing storage engines is not allowed for tables for which there +are foreign key constraints (parent or child tables). */ + +bool +ha_innobase::can_switch_engines(void) +/*=================================*/ +{ + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + bool can_switch; + + DBUG_ENTER("ha_innobase::can_switch_engines"); + prebuilt->trx->op_info = + "determining if there are foreign key constraints"; + row_mysql_lock_data_dictionary(prebuilt->trx); + + can_switch = !UT_LIST_GET_FIRST(prebuilt->table->referenced_list) + && !UT_LIST_GET_FIRST(prebuilt->table->foreign_list); + + row_mysql_unlock_data_dictionary(prebuilt->trx); + prebuilt->trx->op_info = ""; + + DBUG_RETURN(can_switch); +} + /*********************************************************************** Checks if a table is referenced by a foreign key. The MySQL manual states that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a |