summaryrefslogtreecommitdiff
path: root/mysql-test/main/alter_table_lock.test
blob: 6fe717f977ee1181667d31e3768f98fb79d5d68a (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
--source include/not_msan.inc
--source include/have_innodb.inc

--echo #
--echo # MDEV-23836: Assertion `! is_set() || m_can_overwrite_status' in
--echo # Diagnostics_area::set_error_status (interrupted ALTER TABLE under LOCK)
--echo #

SET @max_session_mem_used_save= @@max_session_mem_used;

CREATE TABLE t1 (a INT);
SELECT * FROM t1;

--error ER_NO_SUCH_TABLE
ALTER TABLE x MODIFY xx INT;

SET SESSION max_session_mem_used= 8192;
--error 0,ER_OPTION_PREVENTS_STATEMENT
LOCK TABLE t1 WRITE;

--disable_warnings
--error 0,ER_OPTION_PREVENTS_STATEMENT
ALTER TABLE t1 CHANGE COLUMN IF EXISTS b c INT;
--enable_warnings

SET SESSION max_session_mem_used = @max_session_mem_used_save;
UNLOCK TABLES;
DROP TABLE t1;

--echo #
--echo # End of 10.5 tests
--echo #

--echo #
--echo # MDEV-28943 Online alter fails under LOCK TABLE with ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
--echo #

# test that any lock=xxx works under LOCK TABLES
# and that it is ignored, does not actually downgrade the lock
create table t1 (f int) engine=innodb;
insert t1 values (1);
alter table t1 force, algorithm=copy, lock=none;
alter table t1 force, algorithm=inplace, lock=none;
alter table t1 force, algorithm=copy, lock=shared;
alter table t1 force, algorithm=inplace, lock=shared;
alter table t1 force, algorithm=copy, lock=exclusive;
alter table t1 force, algorithm=inplace, lock=exclusive;
lock table t1 write;
connect con1, localhost, root;
--send select count(*) as 'must be 0' from t1
--connection default
alter table t1 force, algorithm=copy, lock=none;
alter table t1 force, algorithm=inplace, lock=none;
alter table t1 force, algorithm=copy, lock=shared;
alter table t1 force, algorithm=inplace, lock=shared;
alter table t1 force, algorithm=copy, lock=exclusive;
alter table t1 force, algorithm=inplace, lock=exclusive;
delete from t1;
unlock tables;
--connection con1
--reap
--connection default
drop table t1;

--echo #
--echo # MDEV-29056 Replica SQL thread stops with 1846 error on ALTER ONLINE after LOCK WRITE
--echo #
create table t1 (c varchar(1), key (c)) engine=innodb;
insert into t1 (c) values ('g') ;
alter table t1 add fulltext key(c), algorithm=inplace;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter online table t1 add column s blob not null, algorithm=inplace;
lock table t1 write;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
alter online table t1 add column s blob not null, algorithm=inplace;
drop table t1;

--echo #
--echo # End of 10.11 tests
--echo #