summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2020-11-19 14:23:23 +0300
committerAleksey Midenkov <midenok@gmail.com>2020-12-02 02:06:55 +0300
commit50691e09616a1ae290ef2c4f55e8faf54af41f48 (patch)
tree0d9c3a93bf680aceac99dfe30e8d37ed1b4f8404
parent4310cbfcda669a4785a34f4ff287b8fb51117943 (diff)
downloadmariadb-git-50691e09616a1ae290ef2c4f55e8faf54af41f48.tar.gz
MDEV-21652 fixes
- fix lowercase - lcase2 fix - --ps-protocol fix
-rw-r--r--mysql-test/suite/innodb/r/foreign_key_legacy.result26
-rw-r--r--mysql-test/suite/innodb/t/foreign_key_legacy.test20
-rw-r--r--sql/handler.cc5
-rw-r--r--storage/innobase/handler/ha_innodb.cc6
4 files changed, 36 insertions, 21 deletions
diff --git a/mysql-test/suite/innodb/r/foreign_key_legacy.result b/mysql-test/suite/innodb/r/foreign_key_legacy.result
index f75952374ec..c88277cf275 100644
--- a/mysql-test/suite/innodb/r/foreign_key_legacy.result
+++ b/mysql-test/suite/innodb/r/foreign_key_legacy.result
@@ -29,8 +29,6 @@ t2 CREATE TABLE `t2` (
KEY `fk_t2` (`y`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t1` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -105,7 +103,7 @@ show create table t2;
ERROR HY000: Index for table 't2' is corrupt; try to repair it
show warnings;
Level Code Message
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
Warning 150 Upgrade table t2 with foreign key t2_ibfk_1 constraint failed. Foreign key index not found!
Error 1215 Cannot add foreign key constraint for `t2`
Error 1034 Index for table 't2' is corrupt; try to repair it
@@ -127,7 +125,7 @@ show create table t2;
ERROR HY000: Index for table 't2' is corrupt; try to repair it
show warnings;
Level Code Message
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
Warning 150 Upgrade table t2 with foreign key t2_ibfk_1 constraint failed. Referenced key index not found!
Error 1215 Cannot add foreign key constraint for `t2`
Error 1034 Index for table 't2' is corrupt; try to repair it
@@ -143,7 +141,7 @@ show create table t2;
ERROR HY000: Index for table 't2' is corrupt; try to repair it
show warnings;
Level Code Message
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
Warning 150 Upgrade table t2 with foreign key t2_ibfk_1 constraint failed. Foreign key index not found!
Error 1215 Cannot add foreign key constraint for `t2`
Error 1034 Index for table 't2' is corrupt; try to repair it
@@ -159,7 +157,7 @@ show create table t2;
ERROR HY000: Index for table 't2' is corrupt; try to repair it
show warnings;
Level Code Message
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
Warning 150 Upgrade table t2 with foreign key t2_ibfk_1 constraint failed. Referenced key index not found!
Error 1215 Cannot add foreign key constraint for `t2`
Error 1034 Index for table 't2' is corrupt; try to repair it
@@ -192,8 +190,6 @@ t2 CREATE TABLE `t2` (
KEY `fk_t2` (`y`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t0` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -222,8 +218,6 @@ t3 CREATE TABLE `t3` (
KEY `fk_t2` (`y`),
CONSTRAINT `t3_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t1` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t3`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -253,8 +247,6 @@ t2 CREATE TABLE `t2` (
KEY `fk_t2` (`y`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t0` (`x`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -269,7 +261,7 @@ INSERT INTO SYS_FOREIGN VALUES ('test/t2_ibfk_1', 'test/t2', 'test/t1', 1);
INSERT INTO SYS_FOREIGN_COLS VALUES ('test/t2_ibfk_1', 0, 'y', 'x');";
alter table t2 rename t3;
Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -306,8 +298,6 @@ t2 CREATE TABLE `t2` (
KEY `fk_t2` (`y`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t1` (`z`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -322,7 +312,7 @@ INSERT INTO SYS_FOREIGN VALUES ('test/t2_ibfk_1', 'test/t2', 'test/t1', 1);
INSERT INTO SYS_FOREIGN_COLS VALUES ('test/t2_ibfk_1', 0, 'y', 'x');";
alter table t2 change y z int;
Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -359,8 +349,6 @@ t2 CREATE TABLE `t2` (
KEY `fk_t2` (`y`),
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`y`) REFERENCES `t1` (`z`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
@@ -377,7 +365,7 @@ INSERT INTO SYS_FOREIGN VALUES ('test/t2_ibfk_1', 'test/t2', 'test/t1', 1);
INSERT INTO SYS_FOREIGN_COLS VALUES ('test/t2_ibfk_1', 0, 'y', 'x');";
alter table t2 rename column y to z;
Warnings:
-Error 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
+Note 1459 Upgrade required. Please do "REPAIR TABLE `t2`" or dump/reload to fix it!
select * from information_schema.innodb_sys_foreign;
ID FOR_NAME REF_NAME N_COLS TYPE
select * from information_schema.innodb_sys_foreign_cols;
diff --git a/mysql-test/suite/innodb/t/foreign_key_legacy.test b/mysql-test/suite/innodb/t/foreign_key_legacy.test
index 7b50533775a..ab79f7fa775 100644
--- a/mysql-test/suite/innodb/t/foreign_key_legacy.test
+++ b/mysql-test/suite/innodb/t/foreign_key_legacy.test
@@ -22,7 +22,10 @@ select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
flush tables;
--echo # Data is imported from SYS_FOREIGN[_COLS] on table open
+# Warnings doesn't appear in SHOW CREATE TABLE under ps-protocol
+--disable_warnings
show create table t2;
+--enable_warnings
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
@@ -154,7 +157,9 @@ rename table t1 to t0;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
@@ -176,7 +181,9 @@ rename table t2 to t3;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t3;
+--enable_warnings
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
@@ -200,7 +207,9 @@ alter table t1 rename t0;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
@@ -240,7 +249,9 @@ alter table t1 change x z int;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
drop tables t2, t1;
@@ -259,7 +270,9 @@ alter table t2 change y z int;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
--error ER_ROW_IS_REFERENCED_2
drop table t1;
drop tables t2, t1;
@@ -279,7 +292,10 @@ alter table t1 rename column x to z;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
+
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
--error ER_ROW_IS_REFERENCED_2
@@ -300,7 +316,10 @@ alter table t2 rename column y to z;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
+--disable_warnings
show create table t2;
+--enable_warnings
+
--error ER_ROW_IS_REFERENCED_2
drop table t1;
drop tables t2, t1;
@@ -331,6 +350,7 @@ select * from information_schema.innodb_sys_foreign_cols;
drop table t1;
drop tables t2, t1;
+--enable_warnings
set session debug_dbug= @saved_debug_dbug;
set global innodb_eval_sql= default;
set default_storage_engine= default;
diff --git a/sql/handler.cc b/sql/handler.cc
index f6706e78ae9..51c2b493990 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4153,6 +4153,11 @@ void handler::print_error(int error, myf errflag)
DBUG_VOID_RETURN;
}
case HA_ERR_FK_UPGRADE:
+ if (!ha_thd()->transaction_rollback_request)
+ {
+ /* Ensure this becomes a true error */
+ errflag|= (ME_NOTE);
+ }
/* fall through */
case HA_ERR_TABLE_NEEDS_UPGRADE:
textno= ER_TABLE_NEEDS_UPGRADE;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index b259cb98a88..895cb45a454 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -21248,7 +21248,7 @@ fk_upgrade_create_fk(
ut_a(fld->len <= MAX_FULL_NAME_LEN);
memcpy(src_ref, fld->data, fld->len);
src_ref[fld->len] = 0;
- if (lower_case_table_names == 1) {
+ if (lower_case_table_names) {
innobase_casedn_str(src_ref);
}
memcpy(d.ref_name, src_ref, fld->len + 1);
@@ -21386,6 +21386,7 @@ fk_upgrade_push_fk(
ut_ad(fk.foreign_fields.elements < MAX_NUM_FK_COLUMNS);
ut_ad(fk.foreign_fields.elements == fk.referenced_fields.elements);
uint i= 0;
+ char norm_name[FN_REFLEN];
const char* column_names[MAX_NUM_FK_COLUMNS];
const char* ref_column_names[MAX_NUM_FK_COLUMNS];
dict_index_t* index;
@@ -21408,7 +21409,8 @@ fk_upgrade_push_fk(
d.err = DB_CANNOT_ADD_CONSTRAINT;
return 0;
}
- dict_table_t* ref_table = dict_table_open_on_name(d.ref_name, true, false, DICT_ERR_IGNORE_FK_NOKEY);
+ normalize_table_name(norm_name, d.ref_name);
+ dict_table_t* ref_table = dict_table_open_on_name(norm_name, true, false, DICT_ERR_IGNORE_FK_NOKEY);
if (!ref_table) {
mutex_exit(&dict_sys.mutex);
ib_foreign_warn(d.trx, DB_CANNOT_ADD_CONSTRAINT, d.s->table_name.str,