summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/gcol/t/innodb_virtual_purge.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/gcol/t/innodb_virtual_purge.test')
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_purge.test176
1 files changed, 176 insertions, 0 deletions
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_purge.test
new file mode 100644
index 00000000..c79a817d
--- /dev/null
+++ b/mysql-test/suite/gcol/t/innodb_virtual_purge.test
@@ -0,0 +1,176 @@
+--source include/have_innodb.inc
+--source include/count_sessions.inc
+
+# Ensure that the history list length will actually be decremented by purge.
+SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
+SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
+
+--echo #
+--echo # Bug#21869656 UNDO LOG DOES NOT CONTAIN ENOUGH INFORMATION
+--echo # ON INDEXED VIRTUAL COLUMNS
+--echo #
+
+CREATE TABLE t1 (a INT, b INT,
+ a1 INT GENERATED ALWAYS AS (a) VIRTUAL, INDEX(a1)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 (a,b) VALUES(1,1);
+
+connect (con1,localhost,root,,);
+# disable purge
+CREATE TABLE t0 (a INT) ENGINE=InnoDB;
+BEGIN; SELECT * FROM t0;
+
+connection default;
+# write the problematic update_undo log record
+UPDATE t1 SET a=0;
+
+ALTER TABLE t1 DROP COLUMN a1, ALGORITHM=INPLACE;
+ALTER TABLE t1 ADD COLUMN b1 INT GENERATED ALWAYS AS (b) VIRTUAL, ADD
+INDEX(b1),
+ALGORITHM=INPLACE;
+
+connection con1;
+# enable purge
+COMMIT;
+UPDATE t1 SET a=1;
+
+connection default;
+--source ../../innodb/include/wait_all_purged.inc
+
+CHECK TABLE t1;
+SELECT b1 FROM t1;
+
+
+# Create multi-virtual column, more ADD/DROP to test it
+ALTER TABLE t1
+ADD COLUMN a1 INT GENERATED ALWAYS AS (a) VIRTUAL,
+ADD COLUMN a2 INT GENERATED ALWAYS AS (a + b) VIRTUAL,
+ADD COLUMN a3 INT GENERATED ALWAYS AS (a - b) VIRTUAL,
+ADD COLUMN a4 INT GENERATED ALWAYS AS (a - b) VIRTUAL,
+ADD INDEX(a1), ADD INDEX(a2), ADD INDEX(a3), ALGORITHM=INPLACE;
+
+CREATE TABLE t2 (
+ a BLOB,
+ b BLOB,
+ c BLOB GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
+ h VARCHAR(10) DEFAULT NULL
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES (REPEAT('g', 16000), REPEAT('x', 16000), DEFAULT, 'kk');
+
+INSERT INTO t2 VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, 'mm');
+
+CREATE INDEX idx ON t2(c(100));
+
+INSERT INTO t1 (a, b) VALUES(1,1);
+
+connection con1;
+# disable purge
+BEGIN; SELECT * FROM t0;
+
+connection default;
+--enable_info
+
+# write the problematic update_undo log record
+UPDATE t1 SET a=0;
+UPDATE t1 SET b=0;
+
+ALTER TABLE t1 DROP COLUMN a3, ALGORITHM=INPLACE;
+
+UPDATE t1 SET a=2;
+ALTER TABLE t1 DROP COLUMN a2, ALGORITHM=INPLACE;
+UPDATE t1 SET b=3;
+
+ALTER TABLE t1 ADD COLUMN b2 INT GENERATED ALWAYS AS (b) VIRTUAL,
+ADD INDEX(b2), ALGORITHM=INPLACE;
+UPDATE t1 SET b=9;
+
+ALTER TABLE t1 ADD COLUMN b3 INT GENERATED ALWAYS AS (a) VIRTUAL,
+ADD INDEX(b3), ALGORITHM=INPLACE;
+
+UPDATE t1 SET b=10;
+
+ALTER TABLE t2 DROP COLUMN c;
+
+UPDATE t2 SET a = REPEAT('s', 6000) WHERE a like 'aaa%';
+
+ALTER TABLE t2 ADD COLUMN x1 BLOB GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
+ADD COLUMN x2 BLOB GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
+ADD INDEX(x1(100), x2(120)), ADD INDEX (x1(20));
+
+UPDATE t1 SET a=5;
+
+UPDATE t2 SET a = REPEAT('m', 16000) WHERE a like 'sss%';
+
+ALTER TABLE t1 DROP COLUMN b2, ALGORITHM=INPLACE;
+
+UPDATE t1 SET a=6;
+
+ALTER TABLE t2 DROP COLUMN x1, DROP COLUMN x2, ALGORITHM=INPLACE;
+
+UPDATE t2 SET a = REPEAT('x', 1000) WHERE a like 'mmm%';
+
+ALTER TABLE t1 DROP INDEX b3;
+UPDATE t1 SET a=100;
+--disable_info
+
+connection con1;
+# enable purge
+COMMIT;
+disconnect con1;
+
+connection default;
+--source ../../innodb/include/wait_all_purged.inc
+
+CHECK TABLE t1;
+SELECT b1 FROM t1;
+
+SELECT * FROM t1;
+CHECK TABLE t2;
+DROP TABLE t2, t1, t0;
+
+CREATE TABLE t1 (a VARCHAR(30), b INT, a2 VARCHAR(30) GENERATED ALWAYS AS (a) VIRTUAL);
+
+--error ER_DUP_FIELDNAME
+CREATE INDEX idx ON t1(a2(10), b, a2(20));
+
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17540 Server crashes in row_purge after TRUNCATE TABLE
+--echo #
+
+# Note: this test case is nondeterministic and should depend on
+# MDEV-12288 to trigger the needed purge activity.
+# The test does not seem to repeat the bug on MariaDB 10.2.
+
+CREATE TABLE t1 (a BIT(14)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+ (b'01110110101011'),(b'01100111111000'),(b'00001011110100'),
+ (b'01110110111010'),(b'10001010101011'),(b'01100111001111');
+
+CREATE TABLE t2 (
+ pk INT DEFAULT 1,
+ b YEAR,
+ c BIT(14),
+ d YEAR AS (b),
+ e BIT(14) AS (c),
+ UNIQUE(pk),
+ KEY(e)
+) ENGINE=InnoDB;
+
+# Run a few times in order to improve the chances of triggering the bug.
+--disable_query_log
+let $n=10;
+while ($n) {
+REPLACE INTO t2 (c) SELECT a FROM t1;
+TRUNCATE TABLE t2;
+dec $n;
+}
+--enable_query_log
+
+DROP TABLE t1, t2;
+
+--source include/wait_until_count_sessions.inc
+SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;