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

--source include/have_partition.inc

--disable_warnings
drop table if exists t1,t2;
--enable_warnings

--echo # Tests for MyRocks + partitioning

--echo #
--echo # MyRocks Issue #70: Server crashes in Rdb_key_def::get_primary_key_tuple
--echo #
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, KEY(f2)) ENGINE=RocksDB 
PARTITION BY HASH(pk) PARTITIONS 2;
INSERT INTO t1 VALUES (1, 6, NULL), (2, NULL, 1);

CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB;
INSERT INTO t2 VALUES (1, 1), (2, 1);

SELECT f1 FROM t1 WHERE f2 = ( SELECT f1 FROM t2 WHERE pk = 2 );

drop table t1,t2;

--echo #
--echo # Issue#105: key_info[secondary_key].actual_key_parts does not include primary key on partitioned tables
--echo #
CREATE TABLE t1 (
 id INT PRIMARY KEY,
 a set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')  CHARACTER SET utf8,
 b set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')  CHARACTER SET utf8 default null,
 c set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')  CHARACTER SET utf8 not null,
 INDEX (a),
 INDEX (b),
 INDEX (c)
) ENGINE=RocksDB PARTITION BY key (id) partitions 2;

INSERT INTO t1 (id, b) VALUES (28, 3);
UPDATE t1 SET id=8 WHERE c < 8 LIMIT 1;
check table t1;
drop table t1;

--echo # 
--echo #  Issue #105, another testcase
--echo # 
create table t1 (
  pk int primary key,
  col1 int,
  col2 int,
  key (col1) comment 'rev:cf_issue105'
) engine=rocksdb partition by hash(pk) partitions 2;

insert into t1 values (1,10,10);
insert into t1 values (2,10,10);

insert into t1 values (11,20,20);
insert into t1 values (12,20,20);
explain select * from t1 force index(col1) where col1=10;
select * from t1 force index(col1) where col1=10;
select * from t1 use index () where col1=10;
drop table t1;

--echo #
--echo # Issue #108: Index-only scans do not work for partitioned tables and extended keys
--echo #
create table t1 (
  pk int primary key,
  col1 int,
  col2 int,
  key (col1)
) engine=rocksdb partition by hash(pk) partitions 2;

insert into t1 values (1,10,10);
insert into t1 values (2,10,10);

insert into t1 values (11,20,20);
insert into t1 values (12,20,20);
--echo # The following must use "Using index"
explain select pk from t1 force index(col1) where col1=10;

drop table t1;

--echo #
--echo # Issue #214: subqueries cause crash
--echo #
create TABLE t1(a int,b int,c int,primary key(a,b))
    partition by list (b*a) (partition x1 values in (1) tablespace ts1,
                             partition x2 values in (3,11,5,7) tablespace ts2,
                             partition x3 values in (16,8,5+19,70-43) tablespace ts3);
create table t2(b binary(2));
set session optimizer_switch='materialization=off';
insert into t1(a,b) values(1,7);
select a from t1 where a in (select a from t1 where a in (select b from t2));

drop table t1, t2;

--echo #
--echo # Issue #260: altering name to invalid value leaves table unaccessible
--echo #
CREATE TABLE t1 (c1 INT NOT NULL, c2 CHAR(5)) PARTITION BY HASH(c1) PARTITIONS 4;
INSERT INTO t1 VALUES(1,'a');
--replace_result \\ /
--error ER_ERROR_ON_RENAME
RENAME TABLE t1 TO db3.t3;
SELECT * FROM t1;
SHOW TABLES;
# try it again to the same database
RENAME TABLE t1 TO test.t3;
SELECT * FROM t3;
SHOW TABLES;
# now try it again but with another existing database
CREATE DATABASE db3;
USE test;
RENAME TABLE t3 to db3.t2;
USE db3;
SELECT * FROM t2;
SHOW TABLES;
# cleanup
DROP TABLE t2;
use test;
DROP DATABASE db3;