mirror of
https://github.com/MariaDB/server.git
synced 2025-01-25 00:04:33 +01:00
1cae1af6f9
* remove old 5.2+ InnoDB support for virtual columns * enable corresponding parts of the innodb-5.7 sources * copy corresponding test cases from 5.7 * copy detailed Alter_inplace_info::HA_ALTER_FLAGS flags from 5.7 - and more detailed detection of changes in fill_alter_inplace_info() * more "innodb compatibility hooks" in sql_class.cc to - create/destroy/reset a THD (used by background purge threads) - find a prelocked table by name - open a table (from a background purge thread) * different from 5.7: - new service thread "thd_destructor_proxy" to make sure all THDs are destroyed at the correct point in time during the server shutdown - proper opening/closing of tables for vcol evaluations in + FK checks (use already opened prelocked tables) + purge threads (open the table, MDLock it, add it to tdc, close when not needed) - cache open tables in vc_templ - avoid unnecessary allocations, reuse table->record[0] and table->s->default_values - not needed in 5.7, because it overcalculates: + tell the server to calculate vcols for an on-going inline ADD INDEX + calculate vcols for correct error messages * update other engines (mroonga/tokudb) accordingly
44 lines
1.3 KiB
Text
44 lines
1.3 KiB
Text
#
|
|
# Bug#22469130: FOREIGN KEY ON DELETE CASCADE NOT ALLOWED
|
|
# WHEN A VIRTUAL INDEX EXISTS.
|
|
# Add the VIRTUAL INDEX contains fk constraINT column
|
|
# using INPLACE alter operatiON
|
|
CREATE TABLE t1(fld1 INT NOT NULL PRIMARY KEY) engine=innodb;
|
|
CREATE TABLE t2(fld1 INT NOT NULL, fld2 INT NOT NULL,
|
|
fld3 INT AS (fld2) VIRTUAL, KEY(fld1),
|
|
FOREIGN KEY(fld1) REFERENCES t1(fld1) ON UPDATE CASCADE) engine=innodb;
|
|
INSERT INTO t1(fld1) VALUES(1);
|
|
INSERT INTO t2(fld1, fld2) VALUES(1, 2);
|
|
UPDATE t1 SET fld1= 2;
|
|
SELECT fld3, fld1 FROM t2;
|
|
fld3 fld1
|
|
2 2
|
|
alter TABLE t2 ADD INDEX vk(fld3, fld1), ALGORITHM=INPLACE;
|
|
UPDATE t1 SET fld1=3;
|
|
SELECT fld3, fld1 FROM t2;
|
|
fld3 fld1
|
|
2 3
|
|
DROP TABLE t2, t1;
|
|
# TEMPORARY TABLE NAME and CHILD TABLE NAME are same
|
|
CREATE TABLE t1(fld1 INT NOT NULL PRIMARY KEY) engine=innodb;
|
|
CREATE TABLE t2(fld1 INT NOT NULL,
|
|
fld2 INT AS (fld1) VIRTUAL,
|
|
KEY(fld2),
|
|
FOREIGN KEY(fld1) REFERENCES t1(fld1)
|
|
ON UPDATE CASCADE) engine=innodb;
|
|
INSERT INTO t1 VALUES(1), (2);
|
|
INSERT INTO t2 VALUES(1, DEFAULT), (2, default);
|
|
CREATE TEMPORARY TABLE t2 (fld1 INT NOT NULL)ENGINE=INNODB;
|
|
UPDATE t1 SET fld1= 3 WHERE fld1= 2;
|
|
connect con1,localhost,root,,test;
|
|
SELECT fld2 FROM t2;
|
|
fld2
|
|
1
|
|
3
|
|
CHECK TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 check status OK
|
|
connection default;
|
|
disconnect con1;
|
|
DROP TABLE t2;
|
|
DROP TABLE t2, t1;
|