summaryrefslogtreecommitdiff
path: root/storage/tokudb/mysql-test/tokudb_alter_table/t/hcad_with_lock_sps.test
blob: 9d34faefbbc0fa4966ad8d8f00d6e58744f9c8a5 (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
#--source include/have_tokudb.inc
SET DEFAULT_STORAGE_ENGINE='tokudb';

--disable_warnings
DROP TABLE IF EXISTS foo;
drop procedure if exists p0;
drop procedure if exists p1;
drop function if exists f0;
--enable_warnings

set session tokudb_disable_slow_alter=ON;

create table foo (a int, b int, c int, key (b) clustering=yes)engine=TokuDB;
insert into foo values (1,10,100),(2,20,200),(3,30,300);

#test that alter table works with autocommit off;
set autocommit=off;
insert into foo values (4,40,400);
alter table foo add column z int default 999 first;
explain select * from foo;
select * from foo;
explain select * from foo where b > 20;
select* from foo where b > 10;
set autocommit=on;

#test that alter table works with autocommit off;
begin;
alter table foo drop column z;
explain select * from foo;
select * from foo;
explain select * from foo where b > 20;
select* from foo where b > 10;


#simple test with lock tables

lock tables foo write;
alter table foo add column z int;
explain select * from foo;
select * from foo;
explain select * from foo where b > 20;
select* from foo where b > 10;
unlock tables;
select * from foo;
select * from foo where b > 10;

delimiter |;
create procedure p0()
begin
  alter table foo drop column z;
  explain select * from foo;
  select * from foo;
  explain select * from foo where b > 20;
  select* from foo where b > 10;
end |
delimiter ;|

call p0();
explain select * from foo;
select * from foo;
explain select * from foo where b > 20;
select* from foo where b > 10;

delimiter |;
--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
create function f0() returns int
begin
  alter table foo add column ggg int;
end|

delimiter ;|


set autocommit=0;

delimiter |;
create procedure p1()
begin
  insert into foo values(5,50,500);
  select * from foo;
  savepoint x;
  alter table foo add column g int;
  explain select * from foo;
  select * from foo;
  select * from foo where b > 10;
  explain select * from foo where b > 20;
end|
delimiter ;|

call p1();
set autocommit=on;
explain select * from foo;
select * from foo;
explain select * from foo where b > 10;
select * from foo where b > 10;

drop table foo;
drop procedure p0;
drop procedure p1;