summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/gcol/t/gcol_rollback.test
blob: 888e6be861e5f697c084636907cbca5054e29042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc

# Save the initial number of concurrent sessions.
--source include/count_sessions.inc

# Make sure there are no unexpected open tables from previous tests
--disable_query_log
FLUSH TABLES;
--enable_query_log

CREATE TABLE t (
  a INTEGER,
  b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
  INDEX (b(57))
)ENGINE=INNODB;

INSERT INTO t (a) VALUES (9);
BEGIN;
SAVEPOINT a;
UPDATE t set a = 12;
DELETE FROM t where a = 12;
ROLLBACK TO SAVEPOINT a;
COMMIT;

CHECK TABLE t;

SELECT * FROM t;

BEGIN;
INSERT INTO t (a) VALUES (10);
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
SELECT * FROM t;
DROP TABLE t;

CREATE TABLE t (
  a INTEGER,
  b BLOB GENERATED ALWAYS AS (a) VIRTUAL,
  c INTEGER
)ENGINE=INNODB;

INSERT INTO t (a,c) VALUES (9, 10);
SELECT * FROM t;

connect (con1,localhost,root,,);
connection con1;

# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
# detected before we get a chance to apply the online log.

SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
--send
ALTER TABLE t ADD KEY(b(57)), ALGORITHM=INPLACE;

connection default;
SET DEBUG_SYNC = 'now WAIT_FOR created';
BEGIN;
INSERT INTO t (a,c) VALUES (10, 12);
SELECT * FROM t;
ROLLBACK;
SET DEBUG_SYNC = 'now SIGNAL dml_done';

connection con1;
reap;
disconnect con1;
connection default;

SELECT * FROM t;
DROP TABLE t;

# drop virtual column and alter index
CREATE TABLE t (
  a INT,
  b INT,
  c INT GENERATED ALWAYS AS(a+b),
  d INT GENERATED ALWAYS AS(a+b+b),
  KEY(c, d)
)ENGINE=INNODB;

INSERT INTO t (a,b) VALUES (9, 10);
SELECT * FROM t;

connect (con1,localhost,root,,);
connection con1;

# This DEBUG_SYNC should not kick in yet, because the duplicate key will be
# detected before we get a chance to apply the online log.

SET DEBUG_SYNC = 'row_log_apply_after SIGNAL created WAIT_FOR dml_done';
--send
ALTER TABLE t DROP COLUMN c, ALGORITHM=INPLACE;

connection default;
SET DEBUG_SYNC = 'now WAIT_FOR created';
BEGIN;
INSERT INTO t (a,b) VALUES (10, 12);
SELECT * FROM t;
ROLLBACK;
SET DEBUG_SYNC = 'now SIGNAL dml_done';

connection con1;
reap;
connection default;

SELECT * FROM t;

DROP TABLE t;
SET DEBUG_SYNC = 'RESET';

--echo #
--echo #  MDEV-30597 Assertion `flag == 1' failed in
--echo #	row_build_index_entry_low
--echo #
CREATE TABLE t1 (
col1 INT PRIMARY KEY, col_text TEXT,
col_text_g TEXT GENERATED ALWAYS AS (SUBSTR(col_text,1,499))
) ENGINE = InnoDB ROW_FORMAT = Compact;
connection con1;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
INSERT INTO t1 (col1) VALUES (1) ;
DELETE FROM t1 WHERE col1 = 1;
ALTER TABLE t1 ADD UNIQUE INDEX (col_text_g(9));
BEGIN;
INSERT INTO t1 (col1) VALUES (1);
ROLLBACK;
disconnect con1;
DROP TABLE t1;

# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc

--echo # End of 10.4 tests