mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Merge following commit from 5.5:
commit ef92aaf9ec
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date: Wed Jun 22 22:37:28 2016 +0300
MDEV-10083: Orphan ibd file when playing with foreign keys
Analysis: row_drop_table_for_mysql did not allow dropping
referenced table even in case when actual creating of the
referenced table was not successfull if foreign_key_checks=1.
Fix: Allow dropping referenced table even if foreign_key_checks=1
if actual table create returned error.
This commit is contained in:
89
mysql-test/suite/innodb/r/innodb-fkcheck.result
Normal file
89
mysql-test/suite/innodb/r/innodb-fkcheck.result
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
set global innodb_file_per_table = 1;
|
||||||
|
drop table if exists b;
|
||||||
|
drop database if exists bug_fk;
|
||||||
|
create database bug_fk;
|
||||||
|
use bug_fk;
|
||||||
|
CREATE TABLE b (
|
||||||
|
b int unsigned NOT NULL,
|
||||||
|
d1 datetime NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
CREATE TABLE c (
|
||||||
|
b int unsigned NOT NULL,
|
||||||
|
d1 datetime NOT NULL,
|
||||||
|
d2 datetime NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1),
|
||||||
|
CONSTRAINT b_fk FOREIGN KEY (b) REFERENCES b (b)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
show warnings;
|
||||||
|
Level Code Message
|
||||||
|
set foreign_key_checks = 0;
|
||||||
|
DROP TABLE IF EXISTS b;
|
||||||
|
show create table c;
|
||||||
|
Table Create Table
|
||||||
|
c CREATE TABLE `c` (
|
||||||
|
`b` int(10) unsigned NOT NULL,
|
||||||
|
`d1` datetime NOT NULL,
|
||||||
|
`d2` datetime NOT NULL,
|
||||||
|
PRIMARY KEY (`b`,`d1`),
|
||||||
|
CONSTRAINT `b_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||||
|
CREATE TABLE b (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||||
|
show warnings;
|
||||||
|
Level Code Message
|
||||||
|
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||||
|
Warning 1215 Cannot add foreign key constraint
|
||||||
|
DROP TABLE IF EXISTS d;
|
||||||
|
Warnings:
|
||||||
|
Note 1051 Unknown table 'bug_fk.d'
|
||||||
|
CREATE TABLE d (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1),
|
||||||
|
CONSTRAINT bd_fk FOREIGN KEY (b) REFERENCES b (b)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
show warnings;
|
||||||
|
Level Code Message
|
||||||
|
set foreign_key_checks = 1;
|
||||||
|
show create table c;
|
||||||
|
Table Create Table
|
||||||
|
c CREATE TABLE `c` (
|
||||||
|
`b` int(10) unsigned NOT NULL,
|
||||||
|
`d1` datetime NOT NULL,
|
||||||
|
`d2` datetime NOT NULL,
|
||||||
|
PRIMARY KEY (`b`,`d1`),
|
||||||
|
CONSTRAINT `b_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||||
|
show create table d;
|
||||||
|
Table Create Table
|
||||||
|
d CREATE TABLE `d` (
|
||||||
|
`b` bigint(20) unsigned NOT NULL,
|
||||||
|
`d1` date NOT NULL,
|
||||||
|
PRIMARY KEY (`b`,`d1`),
|
||||||
|
CONSTRAINT `bd_fk` FOREIGN KEY (`b`) REFERENCES `b` (`b`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||||
|
CREATE TABLE b (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||||
|
show warnings;
|
||||||
|
Level Code Message
|
||||||
|
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||||
|
Warning 1215 Cannot add foreign key constraint
|
||||||
|
set foreign_key_checks=0;
|
||||||
|
drop table c;
|
||||||
|
drop table d;
|
||||||
|
create table b(id int) engine=innodb;
|
||||||
|
show warnings;
|
||||||
|
Level Code Message
|
||||||
|
b.frm
|
||||||
|
b.ibd
|
||||||
|
drop table if exists b;
|
||||||
|
drop database if exists bug_fk;
|
115
mysql-test/suite/innodb/t/innodb-fkcheck.test
Normal file
115
mysql-test/suite/innodb/t/innodb-fkcheck.test
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
#
|
||||||
|
# MDEV-10083: Orphan ibd file when playing with foreign keys
|
||||||
|
#
|
||||||
|
--disable_query_log
|
||||||
|
SET @start_global_fpt = @@global.innodb_file_per_table;
|
||||||
|
SET @start_global_fkc = @@global.foreign_key_checks;
|
||||||
|
--enable_query_log
|
||||||
|
|
||||||
|
set global innodb_file_per_table = 1;
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists b;
|
||||||
|
drop database if exists bug_fk;
|
||||||
|
--enable_warnings
|
||||||
|
|
||||||
|
let $MYSQLD_DATADIR = `select @@datadir`;
|
||||||
|
|
||||||
|
create database bug_fk;
|
||||||
|
use bug_fk;
|
||||||
|
|
||||||
|
CREATE TABLE b (
|
||||||
|
b int unsigned NOT NULL,
|
||||||
|
d1 datetime NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE c (
|
||||||
|
b int unsigned NOT NULL,
|
||||||
|
d1 datetime NOT NULL,
|
||||||
|
d2 datetime NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1),
|
||||||
|
CONSTRAINT b_fk FOREIGN KEY (b) REFERENCES b (b)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
show warnings;
|
||||||
|
|
||||||
|
set foreign_key_checks = 0;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS b;
|
||||||
|
|
||||||
|
show create table c;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Note that column b has different type in parent table
|
||||||
|
#
|
||||||
|
--error 1005
|
||||||
|
CREATE TABLE b (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
show warnings;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS d;
|
||||||
|
|
||||||
|
CREATE TABLE d (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1),
|
||||||
|
CONSTRAINT bd_fk FOREIGN KEY (b) REFERENCES b (b)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
show warnings;
|
||||||
|
|
||||||
|
set foreign_key_checks = 1;
|
||||||
|
|
||||||
|
show create table c;
|
||||||
|
show create table d;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Table c column b used on foreign key has different type
|
||||||
|
# compared referenced column b in table b, but this
|
||||||
|
# create still produced b.ibd file. This is because
|
||||||
|
# we row_drop_table_for_mysql was called and referenced
|
||||||
|
# table is not allowed to be dropped even in case
|
||||||
|
# when actual create is not successfull.
|
||||||
|
#
|
||||||
|
--error 1005
|
||||||
|
CREATE TABLE b (
|
||||||
|
b bigint unsigned NOT NULL,
|
||||||
|
d1 date NOT NULL,
|
||||||
|
PRIMARY KEY (b,d1)
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
show warnings;
|
||||||
|
|
||||||
|
--list_files $MYSQLD_DATADIR/bug_fk b*
|
||||||
|
|
||||||
|
set foreign_key_checks=0;
|
||||||
|
|
||||||
|
drop table c;
|
||||||
|
drop table d;
|
||||||
|
|
||||||
|
--list_files $MYSQLD_DATADIR/bug_fk b*
|
||||||
|
|
||||||
|
create table b(id int) engine=innodb;
|
||||||
|
show warnings;
|
||||||
|
|
||||||
|
--list_files $MYSQLD_DATADIR/bug_fk b*
|
||||||
|
|
||||||
|
#
|
||||||
|
# Cleanup
|
||||||
|
#
|
||||||
|
--disable_query_log
|
||||||
|
SET @@global.innodb_file_per_table = @start_global_fpt;
|
||||||
|
SET @@global.foreign_key_checks = @start_global_fkc;
|
||||||
|
--enable_query_log
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop table if exists b;
|
||||||
|
drop database if exists bug_fk;
|
||||||
|
--enable_warnings
|
@@ -1365,7 +1365,7 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_FOREIGN table.");
|
"SYS_FOREIGN table.");
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys_foreign_cols_err == DB_CORRUPTION) {
|
if (sys_foreign_cols_err == DB_CORRUPTION) {
|
||||||
@@ -1373,7 +1373,7 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_FOREIGN_COLS table.");
|
"SYS_FOREIGN_COLS table.");
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
@@ -1427,8 +1427,8 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
ut_ad(err == DB_OUT_OF_FILE_SPACE
|
ut_ad(err == DB_OUT_OF_FILE_SPACE
|
||||||
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE);
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE);
|
||||||
|
|
||||||
if (err == DB_OUT_OF_FILE_SPACE) {
|
if (err == DB_OUT_OF_FILE_SPACE) {
|
||||||
err = DB_MUST_GET_MORE_FILE_SPACE;
|
err = DB_MUST_GET_MORE_FILE_SPACE;
|
||||||
@@ -1853,7 +1853,7 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_TABLESPACES table.");
|
"SYS_TABLESPACES table.");
|
||||||
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys_datafiles_err == DB_CORRUPTION) {
|
if (sys_datafiles_err == DB_CORRUPTION) {
|
||||||
@@ -1861,7 +1861,7 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_DATAFILES table.");
|
"SYS_DATAFILES table.");
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ib_logf(IB_LOG_LEVEL_INFO,
|
ib_logf(IB_LOG_LEVEL_INFO,
|
||||||
@@ -1897,8 +1897,8 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
ut_a(err == DB_OUT_OF_FILE_SPACE
|
ut_a(err == DB_OUT_OF_FILE_SPACE
|
||||||
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE);
|
||||||
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE);
|
||||||
|
|
||||||
if (err == DB_OUT_OF_FILE_SPACE) {
|
if (err == DB_OUT_OF_FILE_SPACE) {
|
||||||
err = DB_MUST_GET_MORE_FILE_SPACE;
|
err = DB_MUST_GET_MORE_FILE_SPACE;
|
||||||
|
@@ -1918,7 +1918,7 @@ func_exit:
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table->name, trx, FALSE);
|
row_drop_table_for_mysql(table->name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx->error_state = DB_SUCCESS;
|
trx->error_state = DB_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -2070,7 +2070,7 @@ fts_create_index_tables_low(
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx->error_state = DB_SUCCESS;
|
trx->error_state = DB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -10686,7 +10686,8 @@ ha_innobase::delete_table(
|
|||||||
|
|
||||||
/* Drop the table in InnoDB */
|
/* Drop the table in InnoDB */
|
||||||
err = row_drop_table_for_mysql(
|
err = row_drop_table_for_mysql(
|
||||||
norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB);
|
norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
|
||||||
if (err == DB_TABLE_NOT_FOUND
|
if (err == DB_TABLE_NOT_FOUND
|
||||||
@@ -10717,7 +10718,8 @@ ha_innobase::delete_table(
|
|||||||
#endif
|
#endif
|
||||||
err = row_drop_table_for_mysql(
|
err = row_drop_table_for_mysql(
|
||||||
par_case_name, trx,
|
par_case_name, trx,
|
||||||
thd_sql_command(thd) == SQLCOM_DROP_DB);
|
thd_sql_command(thd) == SQLCOM_DROP_DB,
|
||||||
|
FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -488,6 +488,9 @@ row_drop_table_for_mysql(
|
|||||||
const char* name, /*!< in: table name */
|
const char* name, /*!< in: table name */
|
||||||
trx_t* trx, /*!< in: dictionary transaction handle */
|
trx_t* trx, /*!< in: dictionary transaction handle */
|
||||||
bool drop_db,/*!< in: true=dropping whole database */
|
bool drop_db,/*!< in: true=dropping whole database */
|
||||||
|
ibool create_failed,/*!<in: TRUE=create table failed
|
||||||
|
because e.g. foreign key column
|
||||||
|
type mismatch. */
|
||||||
bool nonatomic = true)
|
bool nonatomic = true)
|
||||||
/*!< in: whether it is permitted
|
/*!< in: whether it is permitted
|
||||||
to release and reacquire dict_operation_lock */
|
to release and reacquire dict_operation_lock */
|
||||||
|
@@ -3636,7 +3636,7 @@ row_merge_drop_table(
|
|||||||
/* There must be no open transactions on the table. */
|
/* There must be no open transactions on the table. */
|
||||||
ut_a(table->n_ref_count == 0);
|
ut_a(table->n_ref_count == 0);
|
||||||
|
|
||||||
return(row_drop_table_for_mysql(table->name, trx, false, false));
|
return(row_drop_table_for_mysql(table->name, trx, false, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************//**
|
/*********************************************************************//**
|
||||||
|
@@ -2391,7 +2391,7 @@ err_exit:
|
|||||||
|
|
||||||
dict_table_close(table, TRUE, FALSE);
|
dict_table_close(table, TRUE, FALSE);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table->name, trx, FALSE);
|
row_drop_table_for_mysql(table->name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
if (commit) {
|
if (commit) {
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
@@ -2551,7 +2551,7 @@ error_handling:
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
@@ -2628,7 +2628,7 @@ row_table_add_foreign_constraints(
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(name, trx, FALSE);
|
row_drop_table_for_mysql(name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
@@ -2669,7 +2669,7 @@ row_drop_table_for_mysql_in_background(
|
|||||||
|
|
||||||
/* Try to drop the table in InnoDB */
|
/* Try to drop the table in InnoDB */
|
||||||
|
|
||||||
error = row_drop_table_for_mysql(name, trx, FALSE);
|
error = row_drop_table_for_mysql(name, trx, FALSE, FALSE);
|
||||||
|
|
||||||
/* Flush the log to reduce probability that the .frm files and
|
/* Flush the log to reduce probability that the .frm files and
|
||||||
the InnoDB data dictionary get out-of-sync if the user runs
|
the InnoDB data dictionary get out-of-sync if the user runs
|
||||||
@@ -3767,6 +3767,9 @@ row_drop_table_for_mysql(
|
|||||||
const char* name, /*!< in: table name */
|
const char* name, /*!< in: table name */
|
||||||
trx_t* trx, /*!< in: transaction handle */
|
trx_t* trx, /*!< in: transaction handle */
|
||||||
bool drop_db,/*!< in: true=dropping whole database */
|
bool drop_db,/*!< in: true=dropping whole database */
|
||||||
|
ibool create_failed,/*!<in: TRUE=create table failed
|
||||||
|
because e.g. foreign key column
|
||||||
|
type mismatch. */
|
||||||
bool nonatomic)
|
bool nonatomic)
|
||||||
/*!< in: whether it is permitted
|
/*!< in: whether it is permitted
|
||||||
to release and reacquire dict_operation_lock */
|
to release and reacquire dict_operation_lock */
|
||||||
@@ -3957,7 +3960,12 @@ row_drop_table_for_mysql(
|
|||||||
name,
|
name,
|
||||||
foreign->foreign_table_name_lookup);
|
foreign->foreign_table_name_lookup);
|
||||||
|
|
||||||
if (foreign->foreign_table != table && !ref_ok) {
|
/* We should allow dropping a referenced table if creating
|
||||||
|
that referenced table has failed for some reason. For example
|
||||||
|
if referenced table is created but it column types that are
|
||||||
|
referenced do not match. */
|
||||||
|
if (foreign->foreign_table != table &&
|
||||||
|
!create_failed && !ref_ok) {
|
||||||
|
|
||||||
FILE* ef = dict_foreign_err_file;
|
FILE* ef = dict_foreign_err_file;
|
||||||
|
|
||||||
@@ -4497,7 +4505,7 @@ row_mysql_drop_temp_tables(void)
|
|||||||
table = dict_load_table(table_name, TRUE, DICT_ERR_IGNORE_NONE);
|
table = dict_load_table(table_name, TRUE, DICT_ERR_IGNORE_NONE);
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4666,7 +4674,7 @@ loop:
|
|||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = row_drop_table_for_mysql(table_name, trx, TRUE);
|
err = row_drop_table_for_mysql(table_name, trx, TRUE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
if (err != DB_SUCCESS) {
|
if (err != DB_SUCCESS) {
|
||||||
|
@@ -641,7 +641,7 @@ trx_rollback_active(
|
|||||||
"in recovery",
|
"in recovery",
|
||||||
table->name, trx->table_id);
|
table->name, trx->table_id);
|
||||||
|
|
||||||
err = row_drop_table_for_mysql(table->name, trx, TRUE);
|
err = row_drop_table_for_mysql(table->name, trx, TRUE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
ut_a(err == DB_SUCCESS);
|
ut_a(err == DB_SUCCESS);
|
||||||
|
@@ -1365,7 +1365,7 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_FOREIGN table.");
|
"SYS_FOREIGN table.");
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys_foreign_cols_err == DB_CORRUPTION) {
|
if (sys_foreign_cols_err == DB_CORRUPTION) {
|
||||||
@@ -1373,7 +1373,7 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_FOREIGN_COLS table.");
|
"SYS_FOREIGN_COLS table.");
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
@@ -1427,8 +1427,8 @@ dict_create_or_check_foreign_constraint_tables(void)
|
|||||||
ut_ad(err == DB_OUT_OF_FILE_SPACE
|
ut_ad(err == DB_OUT_OF_FILE_SPACE
|
||||||
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN", trx, TRUE, TRUE);
|
||||||
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE);
|
row_drop_table_for_mysql("SYS_FOREIGN_COLS", trx, TRUE, TRUE);
|
||||||
|
|
||||||
if (err == DB_OUT_OF_FILE_SPACE) {
|
if (err == DB_OUT_OF_FILE_SPACE) {
|
||||||
err = DB_MUST_GET_MORE_FILE_SPACE;
|
err = DB_MUST_GET_MORE_FILE_SPACE;
|
||||||
@@ -1852,7 +1852,7 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
ib_logf(IB_LOG_LEVEL_WARN,
|
ib_logf(IB_LOG_LEVEL_WARN,
|
||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_TABLESPACES table.");
|
"SYS_TABLESPACES table.");
|
||||||
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sys_datafiles_err == DB_CORRUPTION) {
|
if (sys_datafiles_err == DB_CORRUPTION) {
|
||||||
@@ -1860,7 +1860,7 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
"Dropping incompletely created "
|
"Dropping incompletely created "
|
||||||
"SYS_DATAFILES table.");
|
"SYS_DATAFILES table.");
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ib_logf(IB_LOG_LEVEL_INFO,
|
ib_logf(IB_LOG_LEVEL_INFO,
|
||||||
@@ -1896,8 +1896,8 @@ dict_create_or_check_sys_tablespace(void)
|
|||||||
ut_a(err == DB_OUT_OF_FILE_SPACE
|
ut_a(err == DB_OUT_OF_FILE_SPACE
|
||||||
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
|| err == DB_TOO_MANY_CONCURRENT_TRXS);
|
||||||
|
|
||||||
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_TABLESPACES", trx, TRUE, TRUE);
|
||||||
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE);
|
row_drop_table_for_mysql("SYS_DATAFILES", trx, TRUE, TRUE);
|
||||||
|
|
||||||
if (err == DB_OUT_OF_FILE_SPACE) {
|
if (err == DB_OUT_OF_FILE_SPACE) {
|
||||||
err = DB_MUST_GET_MORE_FILE_SPACE;
|
err = DB_MUST_GET_MORE_FILE_SPACE;
|
||||||
|
@@ -1919,7 +1919,7 @@ func_exit:
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table->name, trx, FALSE);
|
row_drop_table_for_mysql(table->name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx->error_state = DB_SUCCESS;
|
trx->error_state = DB_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -2071,7 +2071,7 @@ fts_create_index_tables_low(
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx->error_state = DB_SUCCESS;
|
trx->error_state = DB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -11470,7 +11470,8 @@ ha_innobase::delete_table(
|
|||||||
|
|
||||||
/* Drop the table in InnoDB */
|
/* Drop the table in InnoDB */
|
||||||
err = row_drop_table_for_mysql(
|
err = row_drop_table_for_mysql(
|
||||||
norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB);
|
norm_name, trx, thd_sql_command(thd) == SQLCOM_DROP_DB,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
|
||||||
if (err == DB_TABLE_NOT_FOUND
|
if (err == DB_TABLE_NOT_FOUND
|
||||||
@@ -11501,7 +11502,8 @@ ha_innobase::delete_table(
|
|||||||
#endif
|
#endif
|
||||||
err = row_drop_table_for_mysql(
|
err = row_drop_table_for_mysql(
|
||||||
par_case_name, trx,
|
par_case_name, trx,
|
||||||
thd_sql_command(thd) == SQLCOM_DROP_DB);
|
thd_sql_command(thd) == SQLCOM_DROP_DB,
|
||||||
|
FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -488,6 +488,9 @@ row_drop_table_for_mysql(
|
|||||||
const char* name, /*!< in: table name */
|
const char* name, /*!< in: table name */
|
||||||
trx_t* trx, /*!< in: dictionary transaction handle */
|
trx_t* trx, /*!< in: dictionary transaction handle */
|
||||||
bool drop_db,/*!< in: true=dropping whole database */
|
bool drop_db,/*!< in: true=dropping whole database */
|
||||||
|
ibool create_failed,/*!<in: TRUE=create table failed
|
||||||
|
because e.g. foreign key column
|
||||||
|
type mismatch. */
|
||||||
bool nonatomic = true)
|
bool nonatomic = true)
|
||||||
/*!< in: whether it is permitted
|
/*!< in: whether it is permitted
|
||||||
to release and reacquire dict_operation_lock */
|
to release and reacquire dict_operation_lock */
|
||||||
|
@@ -3635,7 +3635,7 @@ row_merge_drop_table(
|
|||||||
/* There must be no open transactions on the table. */
|
/* There must be no open transactions on the table. */
|
||||||
ut_a(table->n_ref_count == 0);
|
ut_a(table->n_ref_count == 0);
|
||||||
|
|
||||||
return(row_drop_table_for_mysql(table->name, trx, false, false));
|
return(row_drop_table_for_mysql(table->name, trx, false, false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************//**
|
/*********************************************************************//**
|
||||||
|
@@ -2400,7 +2400,7 @@ err_exit:
|
|||||||
|
|
||||||
dict_table_close(table, TRUE, FALSE);
|
dict_table_close(table, TRUE, FALSE);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table->name, trx, FALSE);
|
row_drop_table_for_mysql(table->name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
if (commit) {
|
if (commit) {
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
@@ -2560,7 +2560,7 @@ error_handling:
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
@@ -2637,7 +2637,7 @@ row_table_add_foreign_constraints(
|
|||||||
|
|
||||||
trx_rollback_to_savepoint(trx, NULL);
|
trx_rollback_to_savepoint(trx, NULL);
|
||||||
|
|
||||||
row_drop_table_for_mysql(name, trx, FALSE);
|
row_drop_table_for_mysql(name, trx, FALSE, TRUE);
|
||||||
|
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
@@ -2678,7 +2678,7 @@ row_drop_table_for_mysql_in_background(
|
|||||||
|
|
||||||
/* Try to drop the table in InnoDB */
|
/* Try to drop the table in InnoDB */
|
||||||
|
|
||||||
error = row_drop_table_for_mysql(name, trx, FALSE);
|
error = row_drop_table_for_mysql(name, trx, FALSE, FALSE);
|
||||||
|
|
||||||
/* Flush the log to reduce probability that the .frm files and
|
/* Flush the log to reduce probability that the .frm files and
|
||||||
the InnoDB data dictionary get out-of-sync if the user runs
|
the InnoDB data dictionary get out-of-sync if the user runs
|
||||||
@@ -3776,6 +3776,9 @@ row_drop_table_for_mysql(
|
|||||||
const char* name, /*!< in: table name */
|
const char* name, /*!< in: table name */
|
||||||
trx_t* trx, /*!< in: transaction handle */
|
trx_t* trx, /*!< in: transaction handle */
|
||||||
bool drop_db,/*!< in: true=dropping whole database */
|
bool drop_db,/*!< in: true=dropping whole database */
|
||||||
|
ibool create_failed,/*!<in: TRUE=create table failed
|
||||||
|
because e.g. foreign key column
|
||||||
|
type mismatch. */
|
||||||
bool nonatomic)
|
bool nonatomic)
|
||||||
/*!< in: whether it is permitted
|
/*!< in: whether it is permitted
|
||||||
to release and reacquire dict_operation_lock */
|
to release and reacquire dict_operation_lock */
|
||||||
@@ -3966,7 +3969,12 @@ row_drop_table_for_mysql(
|
|||||||
name,
|
name,
|
||||||
foreign->foreign_table_name_lookup);
|
foreign->foreign_table_name_lookup);
|
||||||
|
|
||||||
if (foreign->foreign_table != table && !ref_ok) {
|
/* We should allow dropping a referenced table if creating
|
||||||
|
that referenced table has failed for some reason. For example
|
||||||
|
if referenced table is created but it column types that are
|
||||||
|
referenced do not match. */
|
||||||
|
if (foreign->foreign_table != table &&
|
||||||
|
!create_failed && !ref_ok) {
|
||||||
|
|
||||||
FILE* ef = dict_foreign_err_file;
|
FILE* ef = dict_foreign_err_file;
|
||||||
|
|
||||||
@@ -4507,7 +4515,7 @@ row_mysql_drop_temp_tables(void)
|
|||||||
table = dict_table_get_low(table_name);
|
table = dict_table_get_low(table_name);
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
row_drop_table_for_mysql(table_name, trx, FALSE);
|
row_drop_table_for_mysql(table_name, trx, FALSE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4676,7 +4684,7 @@ loop:
|
|||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = row_drop_table_for_mysql(table_name, trx, TRUE);
|
err = row_drop_table_for_mysql(table_name, trx, TRUE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
if (err != DB_SUCCESS) {
|
if (err != DB_SUCCESS) {
|
||||||
|
@@ -641,7 +641,7 @@ trx_rollback_active(
|
|||||||
"in recovery",
|
"in recovery",
|
||||||
table->name, trx->table_id);
|
table->name, trx->table_id);
|
||||||
|
|
||||||
err = row_drop_table_for_mysql(table->name, trx, TRUE);
|
err = row_drop_table_for_mysql(table->name, trx, TRUE, FALSE);
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
ut_a(err == DB_SUCCESS);
|
ut_a(err == DB_SUCCESS);
|
||||||
|
Reference in New Issue
Block a user