1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge 11.2 into 11.4

This commit is contained in:
Marko Mäkelä
2024-10-03 14:32:14 +03:00
560 changed files with 5796 additions and 1398 deletions

View File

@ -0,0 +1,18 @@
--- foreign_null.result
+++ foreign_null,COPY.result
@@ -139,6 +139,7 @@
ALTER TABLE `t#2` DROP INDEX f1;
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE `t#1` MODIFY COLUMN f2 INT;
+ERROR HY000: Error on rename of './test/#sql-alter' to './test/t@00231' (errno: 150 "Foreign key constraint is incorrectly formed")
DROP TABLE `t#2`, `t#1`;
# Drop referenced index and modify column
CREATE TABLE `t#1`(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
@@ -147,6 +148,7 @@
ALTER TABLE `t#1` DROP INDEX f2;
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE `t#2` MODIFY COLUMN f1 INT NOT NULL;
+ERROR HY000: Error on rename of './test/#sql-alter' to './test/t@00232' (errno: 150 "Foreign key constraint is incorrectly formed")
DROP TABLE `t#2`, `t#1`;
# Self referential modifying column
CREATE TABLE t1(f1 INT, f2 INT, index(f2), foreign key(f1) references t1(f2) ON UPDATE CASCADE)engine=innodb;

View File

@ -0,0 +1,156 @@
call mtr.add_suppression("InnoDB: In ALTER TABLE .* has or is referenced in foreign key constraints which are not compatible with the new table definition.");
# modify child column NOT NULL on UPDATE CASCADE..parent column NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL;
ERROR HY000: Column 'f1' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
DROP TABLE t2, t1;
# modify child column NOT NULL ON DELETE CASCADE..parent column NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL;
DROP TABLE t2, t1;
# modify child column NOT NULL ON UPDATE SET NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY(f1) REFERENCES t1(f1) ON UPDATE SET NULL)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL;
ERROR HY000: Column 'f1' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
DROP TABLE t2, t1;
# modify child column NOT NULL ON DELETE SET NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
ERROR HY000: Column 'f2' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
DROP TABLE t2, t1;
# modify child column NOT NULL ON UPDATE RESTRICT..parent column NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
DROP TABLE t2, t1;
# modify child column NOT NULL ON DELETE RESTRICT..parent column NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE RESTRICT)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
DROP TABLE t2, t1;
# modify child column NOT NULL ON UPDATE NO ACTION..PARENT COLUMN NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
DROP TABLE t2, t1;
# modify child column NOT NULL ON DELETE NO ACTION..PARENT COLUMN NULL
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
DROP TABLE t2, t1;
# modify parent column NULL ON UPDATE CASCADE child column NOT NULL
CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE `t#2`(f1 INT NOT NULL,
FOREIGN KEY(f1) REFERENCES `t#1`(f2)
ON UPDATE CASCADE)ENGINE=InnoDB;
ALTER TABLE `t#1` MODIFY COLUMN f2 INT;
ERROR HY000: Cannot change column 'f2': used in a foreign key constraint 't#2_ibfk_1' of table 'test.t#2'
DROP TABLE `t#2`, `t#1`;
# modify parent column NULL ON DELETE CASCADE child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f2 INT;
DROP TABLE t2, t1;
# modify parent column NULL ON UPDATE SET NULL child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE SET NULL)ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
DROP TABLE t1;
# modify parent column NULL ON DELETE SET NULL child NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
DROP TABLE t1;
# modify parent column NULL ON UPDATE RESTRICT child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f2 INT;
DROP TABLE t2, t1;
# modify parent column NULL ON DELETE RESTRICT child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f2 INT;
DROP TABLE t2, t1;
# modify parent column NULL ON UPDATE NO ACTION child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f2 INT;
DROP TABLE t2, t1;
# modify parent column NULL ON DELETE NO ACTION child column NOT NULL
CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f2 INT;
DROP TABLE t2, t1;
# foreign key constraint for multiple columns
# modify parent column NULL ON UPDATE CASCADE child column NOT NULL
CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL,
INDEX(f1, f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL,
INDEX(f1, f2),
FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON
UPDATE CASCADE)ENGINE=InnoDB;
ALTER TABLE t1 MODIFY COLUMN f1 INT;
ERROR HY000: Cannot change column 'f1': used in a foreign key constraint 't2_ibfk_1' of table 'test.t2'
DROP TABLE t2, t1;
# modify child column NOT NULL ON UPDATE CASCADE parent column NULL
CREATE TABLE t1(f1 INT, f2 INT, INDEX(f1, f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, INDEX(f1, f2),
FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON
UPDATE CASCADE)ENGINE=InnoDB;
ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL;
ERROR HY000: Column 'f2' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
DROP TABLE t2, t1;
# allow foreign key constraints when parent table created later
SET FOREIGN_KEY_CHECKS=0;
CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL;
CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
INSERT INTO t1 VALUES(1, 1);
INSERT INTO t2 VALUES(1);
UPDATE t1 SET f2= NULL;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f2`) ON UPDATE CASCADE)
SELECT * FROM t2;
f1
1
SET FOREIGN_KEY_CHECKS=0;
UPDATE t1 SET f2= NULL;
SELECT * FROM t2;
f1
1
DROP TABLE t2, t1;
# Modify column + Drop column & Drop foreign key constraint
CREATE TABLE t1(f1 INT, f2 INT, KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE t2(f1 INT, f2 INT, f3 INT,
FOREIGN KEY fdx(f2) REFERENCES t1(f1),
FOREIGN KEY fdx2(f3) REFERENCES t1(f2))ENGINE=InnoDB;
ALTER TABLE t2 MODIFY f2 INT NOT NULL, DROP FOREIGN KEY fdx;
ALTER TABLE t2 ADD FOREIGN KEY fdx (f2) REFERENCES t1(f1);
ALTER TABLE t2 DROP COLUMN f2, DROP FOREIGN KEY fdx;
DROP TABLE t2, t1;
# Drop foreign index & modify column
CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE `t#2`(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE `t#2` DROP INDEX f1;
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE `t#1` MODIFY COLUMN f2 INT;
DROP TABLE `t#2`, `t#1`;
# Drop referenced index and modify column
CREATE TABLE `t#1`(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB;
CREATE TABLE `t#2`(f1 INT, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB;
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE `t#1` DROP INDEX f2;
SET FOREIGN_KEY_CHECKS=1;
ALTER TABLE `t#2` MODIFY COLUMN f1 INT NOT NULL;
DROP TABLE `t#2`, `t#1`;
# Self referential modifying column
CREATE TABLE t1(f1 INT, f2 INT, index(f2), foreign key(f1) references t1(f2) ON UPDATE CASCADE)engine=innodb;
ALTER TABLE t1 MODIFY COLUMN f2 INT NOT NULL;
ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL;
ALTER TABLE t1 MODIFY COLUMN f1 INT;
DROP TABLE t1;

View File

@ -1,3 +1,5 @@
SET @save_adaptive=@@GLOBAL.innodb_adaptive_hash_index;
SET GLOBAL innodb_adaptive_hash_index=ON;
call mtr.add_suppression("InnoDB: Added system generated FTS_DOC_ID and FTS_DOC_ID_INDEX while importing the tablespace");
CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY,
f2 CHAR(2) not null, fulltext f_idx(f2),
@ -9,7 +11,7 @@ INSERT INTO t1(f1, f2) SELECT seq, "si" FROM seq_2_to_256;
ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL;
ALTER TABLE t1 DROP COLUMN f6;
ALTER TABLE t1 DROP INDEX f_idx;
connect con1,localhost,root,,;
connect block_purge,localhost,root,,;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
DELETE FROM t1 WHERE f1 > 1;
@ -22,6 +24,7 @@ UNLOCK TABLES;
Warnings:
Warning 1235 This version of MariaDB doesn't yet support 'FLUSH TABLES on a table that had an FTS index, created on a hidden column, the auxiliary tables haven't been dropped as yet. FTS auxiliary tables will not be flushed.'
DROP TABLE t1;
disconnect block_purge;
CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY,
f2 CHAR(2) not null,
f3 INT as (f1) VIRTUAL, INDEX(f3),
@ -43,3 +46,4 @@ t1 CREATE TABLE `t1` (
KEY `f4` (`f4`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;
SET GLOBAL innodb_adaptive_hash_index=@save_adaptive;

View File

@ -455,11 +455,11 @@ ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
alter table t2 drop index b, drop index c, drop index d;
ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY;
ERROR HY000: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1'
ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
set @old_sql_mode = @@sql_mode;
set @@sql_mode = 'STRICT_TRANS_TABLES';
alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE;
ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL
ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
set @@sql_mode = @old_sql_mode;
SET FOREIGN_KEY_CHECKS=0;
alter table t2 DROP COLUMN b, ALGORITHM=COPY;
@ -480,10 +480,10 @@ info: Records: 0 Duplicates: 0 Warnings: 0
set @@sql_mode = 'STRICT_TRANS_TABLES';
alter table t2 add primary key (alpha), change a alpha int,
change b beta int not null, change c charlie int not null;
ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL
ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
alter table t2 add primary key (alpha), change a alpha int,
change c charlie int not null, change d delta int not null;
ERROR HY000: Column 'd' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_3' SET NULL
ERROR HY000: Column 'd' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_3' SET NULL
alter table t2 add primary key (alpha), change a alpha int,
change b beta int, modify c int not null;
affected rows: 0

View File

@ -3072,7 +3072,7 @@ ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL;
set @old_sql_mode = @@sql_mode;
set @@sql_mode = 'STRICT_TRANS_TABLES';
ALTER TABLE t2 MODIFY a INT NOT NULL;
ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL
ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL
set @@sql_mode = @old_sql_mode;
DELETE FROM t1;
DROP TABLE t2,t1;

View File

@ -19,6 +19,12 @@ SHOW VARIABLES LIKE 'innodb_log_file_size';
Variable_name Value
innodb_log_file_size 4194304
FOUND 1 /InnoDB: Resized log to 4\.000MiB/ in mysqld.1.err
SET @save=@@GLOBAL.innodb_log_file_buffering;
SET GLOBAL innodb_log_file_buffering=OFF;
SET GLOBAL innodb_log_file_buffering=ON;
SET GLOBAL innodb_log_file_buffering=@save;
SET GLOBAL innodb_log_file_mmap=OFF;
Got one of the listed errors
SET GLOBAL innodb_log_file_size=5242880;
connect con1,localhost,root;
UPDATE t SET b='' WHERE a<10;

View File

@ -116,6 +116,29 @@ t12963823 CREATE TABLE `t12963823` (
KEY `ndx_o` (`o`(500)),
KEY `ndx_p` (`p`(500))
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC
BEGIN NOT ATOMIC
DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c',
GROUP_CONCAT(seq SEPARATOR
' INT DEFAULT 0, c'),
' INT DEFAULT 0, PRIMARY KEY(c',
GROUP_CONCAT(seq SEPARATOR ', c'),
')) ENGINE=InnoDB;') FROM seq_1_to_33);
EXECUTE IMMEDIATE c;
END;
$$
ERROR 42000: Too many key parts specified; max 32 parts allowed
BEGIN NOT ATOMIC
DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c',
GROUP_CONCAT(seq SEPARATOR
' INT DEFAULT 0, c'),
' INT DEFAULT 0, PRIMARY KEY(c',
GROUP_CONCAT(seq SEPARATOR ', c'),
')) ENGINE=InnoDB;') FROM seq_1_to_32);
EXECUTE IMMEDIATE c;
END;
$$
INSERT INTO t1() VALUES();
InnoDB 0 transactions not purged
SET GLOBAL innodb_stats_persistent = @save_stats_persistent;
DROP TABLE t1;
DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge, t12637786, t12963823;

View File

@ -82,4 +82,22 @@ WHERE database_name='test' AND table_name='t1' AND stat_name='size';
TIMESTAMPDIFF(DAY,last_update,now())<=1
1
DROP TABLE t1;
#
# MDEV-34207: ALTER TABLE...STATS_PERSISTENT=0 fails to drop statistics
#
CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
ALTER TABLE t1 STATS_PERSISTENT 0;
DROP TABLE t1;
SET @save_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=1;
CREATE TABLE t2 (c1 INT) ENGINE=InnoDB;
RENAME TABLE t2 TO t1;
DROP TABLE t1;
SET GLOBAL innodb_stats_persistent=0;
CREATE TABLE t2 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
RENAME TABLE t2 TO t1;
SET GLOBAL innodb_stats_persistent=@save_persistent;
DROP TABLE t1;
CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
DROP TABLE t1;
# End of 10.6 tests