diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2018-05-17 22:03:53 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2018-05-17 22:03:53 +0530 |
commit | f38d8c17010642b038cb886bb8a40389c91f996d (patch) | |
tree | f924b26e9d32e9d3221be51e94298875f1ad499b /storage | |
parent | 15425767e8370725e4f80e26da05d93067cf534d (diff) | |
download | mariadb-git-f38d8c17010642b038cb886bb8a40389c91f996d.tar.gz |
MDEV-16201 CREATE TABLE creates extra transaction
InnoDB does not allow FOREIGN KEY constraints to exist for TEMPORARY TABLE.
InnoDB introduced a dedicated tablespace for temporary tables, and actually
stopped creating persistent metadata and data for temporary tables.
row_table_add_foreign_constraints(): Do not create a persistent
transaction.
dict_create_foreign_constraints_low(): Add the persistent transaction to
the update the foreign key relation in dictionary.
dict_create_foreign_constraints_low(): Remove a duplicated check for
partitioned tables.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 22 | ||||
-rw-r--r-- | storage/innobase/row/row0mysql.cc | 6 |
2 files changed, 5 insertions, 23 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 873cfbe009b..c570efb1aba 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -4635,6 +4635,11 @@ loop: /**********************************************************/ /* The following call adds the foreign key constraints to the data dictionary system tables on disk */ + trx->op_info = "adding foreign keys"; + + trx_start_if_not_started_xa(trx, true); + + trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); error = dict_create_add_foreigns_to_dictionary( local_fk_set, table, trx); @@ -4849,23 +4854,6 @@ col_loop1: return(DB_CANNOT_ADD_CONSTRAINT); } - /* Don't allow foreign keys on partitioned tables yet. */ - ptr1 = dict_scan_to(ptr, "PARTITION"); - if (ptr1) { - ptr1 = dict_accept(cs, ptr1, "PARTITION", &success); - if (success && my_isspace(cs, *ptr1)) { - ptr2 = dict_accept(cs, ptr1, "BY", &success); - if (success) { - my_error(ER_FOREIGN_KEY_ON_PARTITIONED,MYF(0)); - return(DB_CANNOT_ADD_CONSTRAINT); - } - } - } - if (dict_table_is_partition(table)) { - my_error(ER_FOREIGN_KEY_ON_PARTITIONED,MYF(0)); - return(DB_CANNOT_ADD_CONSTRAINT); - } - /* Let us create a constraint struct */ foreign = dict_mem_foreign_create(); diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 2efef72d9da..cf072530020 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -2651,12 +2651,6 @@ row_table_add_foreign_constraints( ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X)); ut_a(sql_string); - trx->op_info = "adding foreign keys"; - - trx_start_if_not_started_xa(trx, true); - - trx_set_dict_operation(trx, TRX_DICT_OP_TABLE); - err = dict_create_foreign_constraints( trx, sql_string, sql_length, name, reject_fks); |