summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/transaction.test
blob: 3350db99dab04270cfe5fac36d4c0dac23a1c12e (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
--source include/have_rocksdb.inc

create table t1 (id int primary key, value int, value2 varchar(100), index(value)) engine=rocksdb;

insert into t1 values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(8,8,8),(9,9,9),(10,10,10);

# insert
begin;
insert into t1 values (11,11,11);
--source transaction_select.inc
rollback;

# insert in the middle
begin;
insert into t1 values (7,7,7);
--source transaction_select.inc
rollback;

# update non-index column by primary key
begin;
update t1 set value2=100 where id=1;
--source transaction_select.inc
rollback;

# update secondary key by primary key
begin;
update t1 set value=100 where id=1;
--source transaction_select.inc
rollback;

# update primary key by primary key
begin;
update t1 set id=100 where id=1;
--source transaction_select.inc
rollback;

# update non-index column key by secondary key
begin;
update t1 set value2=100 where value=1;
--source transaction_select.inc
rollback;

# update secondary key by secondary key
begin;
update t1 set value=100 where value=1;
--source transaction_select.inc
rollback;

# update primary key by secondary key
begin;
update t1 set id=100 where value=1;
--source transaction_select.inc
rollback;

# update non-index column by non-index column
begin;
update t1 set value2=100 where value2=1;
--source transaction_select.inc
rollback;

# update secondary key by non-index column
begin;
update t1 set value=100 where value2=1;
--source transaction_select.inc
rollback;

# update primary key column by non-index column
begin;
update t1 set id=100 where value2=1;
--source transaction_select.inc
rollback;


# delete by primary key
begin;
delete from t1 where id=1;
--source transaction_select.inc
rollback;

# delete by secondary key
begin;
delete from t1 where value=1;
--source transaction_select.inc
rollback;

# delete by non-index column
begin;
delete from t1 where value2=1;
--source transaction_select.inc
rollback;

# mixed
begin;
insert into t1 values (11,11,11);
insert into t1 values (12,12,12);
insert into t1 values (13,13,13);
delete from t1 where id=9;
delete from t1 where value=8;
update t1 set id=100 where value2=5;
update t1 set value=103 where value=4;
update t1 set id=115 where id=3;
--source transaction_select.inc
rollback;

drop table t1;

--echo #
--echo #  #802: MyRocks: Statement rollback doesnt work correctly for nested statements
--echo #
create table t1 (a varchar(100)) engine=rocksdb;
create table t2(a int) engine=rocksdb;
insert into t2 values (1), (2);

create table t3(a varchar(100)) engine=rocksdb;

delimiter //;
create function func() returns varchar(100) deterministic 
begin
  insert into t3 values ('func-called');
  set @a= (select a from t2);
  return 'func-returned';
end;//
delimiter ;//

begin;
--error ER_SUBQUERY_NO_1_ROW 
insert into t1 values (func());
select * from t1;
--echo # The following must not produce 'func-called':
select * from t3;

rollback;
drop function func;
drop table t1,t2,t3;