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

SET @prior_rocksdb_perf_context_level = @@rocksdb_perf_context_level;
SET GLOBAL rocksdb_perf_context_level=3;
SET GLOBAL enable_blind_replace=ON;

#
# case 1: table only with primary key, support replace blind write
#
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;

#
# case 2: table only with primary key but with trigger, not support replace blind write
#
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
create trigger trg before insert on t1 for each row set @a:=1;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;


#
# case 3: table without primary key, not support replace blind write
#

create table t1(c1 int,c2 int) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;


create table t1(c1 int,c2 int unique) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;



#
# case 4: table with primary key and secondary key, not support replace blind write
#
create table t1(c1 int primary key,c2 int unique) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;


create table t1(c1 int primary key,c2 int, key idx1(c2)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;



#
# case 5: Disabling blind replace through enable_blind_replace should work
SET GLOBAL enable_blind_replace=OFF;
create table t1(c1 int,c2 int, primary key (c1)) engine=rocksdb;
insert into t1 values(1,1),(2,2),(3,3);
select * from t1;

select variable_value into @c from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
replace into t1 values(1,11);
select case when variable_value-@c > 1 then 'false' else 'true' end as read_free from information_schema.global_status where variable_name='rocksdb_num_get_for_update_calls';
drop table t1;

SET GLOBAL enable_blind_replace=DEFAULT;
SET GLOBAL rocksdb_perf_context_level = @prior_rocksdb_perf_context_level;