#
# table(hidden key)
#
CREATE TABLE t1 (
a INT,
b INT
) ENGINE=ROCKSDB
PARTITION BY RANGE (b) (
PARTITION p0 VALUES LESS THAN (3),
PARTITION p1 VALUES LESS THAN (6),
PARTITION p2 VALUES LESS THAN MAXVALUE
);
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
3	8
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
SELECT a FROM t1 WHERE b > 2;
a
2
SELECT b from t1 where a != 3;
b
1
4
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1 ORDER BY b;
a	b
1	1
SELECT a FROM t1 WHERE b > 2;
a
SELECT b from t1 where a != 3;
b
1
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1 ORDER BY a;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
SELECT a FROM t1 WHERE b < 5;
a
4
5
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1;
a	b
4	1
5	4
INSERT INTO t1(a,b) VALUES(7, 1);
SELECT b from t1 WHERE a > 2;
b
1
1
4
SELECT a,b FROM t1;
a	b
4	1
5	4
7	1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1;
a	b
4	1
7	1
INSERT INTO t1(a,b) VALUES(8, 4);
SELECT a,b FROM t1;
a	b
4	1
7	1
8	4
SELECT b from t1 WHERE a < 9;
b
1
1
4
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1;
a	b
8	4
INSERT INTO t1(a,b) VALUES(9, 8);
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf = 'default';
SELECT b FROM t1 WHERE a < 5;
b
1
2
3
4
TRUNCATE TABLE t1;
SELECT b FROM t1 WHERE a < 5;
b
DROP TABLE t1;
#
# table(secondary key)
#
CREATE TABLE t1(
a INT,
b INT,
KEY (b)
) ENGINE=ROCKSDB
PARTITION BY HASH(a) PARTITIONS 3;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
3	8
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
3	8
SELECT a FROM t1 WHERE b > 2;
a
3
SELECT b from t1 where a != 3;
b
1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1 ORDER BY b;
a	b
3	8
SELECT a FROM t1 WHERE b > 2;
a
3
SELECT b from t1 where a != 3;
b
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1 ORDER BY a;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
SELECT a FROM t1 WHERE b < 5;
a
4
5
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1;
a	b
4	1
6	8
INSERT INTO t1(a,b) VALUES(7, 1);
SELECT b from t1 WHERE a > 2;
b
1
1
8
SELECT a,b FROM t1;
a	b
4	1
6	8
7	1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1;
a	b
6	8
INSERT INTO t1(a,b) VALUES(8, 4);
SELECT a,b FROM t1;
a	b
6	8
8	4
SELECT b from t1 WHERE a < 9;
b
4
8
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1;
a	b
8	4
INSERT INTO t1(a,b) VALUES(9, 8);
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf = 'default';
SELECT b FROM t1 WHERE a < 5;
b
1
2
3
4
TRUNCATE TABLE t1;
SELECT b FROM t1 WHERE a < 5;
b
DROP TABLE t1;
#
# table(primary key, auto increment)
#
CREATE TABLE t1(
a INT NOT NULL AUTO_INCREMENT,
b INT,
PRIMARY KEY(a)
) ENGINE=ROCKSDB
PARTITION BY KEY() PARTITIONS 3;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
3	8
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
SELECT a FROM t1 WHERE b > 2;
a
SELECT b from t1 where a != 3;
b
1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1 ORDER BY b;
a	b
SELECT a FROM t1 WHERE b > 2;
a
SELECT b from t1 where a != 3;
b
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1 ORDER BY a;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
SELECT a FROM t1 WHERE b < 5;
a
4
5
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
INSERT INTO t1(a,b) VALUES(7, 1);
SELECT b from t1 WHERE a > 2;
b
1
1
4
8
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
7	1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1;
a	b
4	1
5	4
INSERT INTO t1(a,b) VALUES(8, 4);
SELECT a,b FROM t1;
a	b
4	1
5	4
8	4
SELECT b from t1 WHERE a < 9;
b
1
4
4
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1;
a	b
8	4
INSERT INTO t1(a,b) VALUES(9, 8);
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf = 'default';
SELECT b FROM t1 WHERE a < 5;
b
1
2
3
4
TRUNCATE TABLE t1;
SELECT b FROM t1 WHERE a < 5;
b
DROP TABLE t1;
#
# table(cf)
#
CREATE TABLE t1 (
a INT,
b INT,
PRIMARY KEY (`a`, `b`) COMMENT 'testcomment'
) ENGINE=ROCKSDB
PARTITION BY LIST(a) (
PARTITION p0 VALUES IN (1, 4, 7),
PARTITION p1 VALUES IN (2, 5, 8),
PARTITION p2 VALUES IN (3, 6, 9)
);
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
3	8
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
SELECT a FROM t1 WHERE b > 2;
a
2
SELECT b from t1 where a != 3;
b
1
4
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1 ORDER BY b;
a	b
1	1
SELECT a FROM t1 WHERE b > 2;
a
SELECT b from t1 where a != 3;
b
1
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1 ORDER BY a;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
SELECT a FROM t1 WHERE b < 5;
a
4
5
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1;
a	b
4	1
5	4
INSERT INTO t1(a,b) VALUES(7, 1);
SELECT b from t1 WHERE a > 2;
b
1
1
4
SELECT a,b FROM t1;
a	b
4	1
5	4
7	1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1;
a	b
4	1
7	1
INSERT INTO t1(a,b) VALUES(8, 4);
SELECT a,b FROM t1;
a	b
4	1
7	1
8	4
SELECT b from t1 WHERE a < 9;
b
1
1
4
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1;
a	b
8	4
INSERT INTO t1(a,b) VALUES(9, 8);
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf = 'default';
SELECT b FROM t1 WHERE a < 5;
b
1
2
3
4
TRUNCATE TABLE t1;
SELECT b FROM t1 WHERE a < 5;
b
DROP TABLE t1;
#
# table(reverse cf)
#
CREATE TABLE t1 (
a INT,
b INT,
PRIMARY KEY (`a`, `b`) COMMENT 'p0_cfname=rev:foo;p1_cfname=bar;p2_cfname=baz'
) ENGINE=ROCKSDB
PARTITION BY LIST(a) (
PARTITION p0 VALUES IN (1, 4, 7),
PARTITION p1 VALUES IN (2, 5, 8),
PARTITION p2 VALUES IN (3, 6, 9)
);
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p0;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p2;
ALTER TABLE t1 TRUNCATE PARTITION p1;
ALTER TABLE t1 TRUNCATE PARTITION p0;
TRUNCATE TABLE t1;
ALTER TABLE t1 TRUNCATE PARTITION p2;
INSERT INTO t1 (a,b) VALUES (1, 1), (2, 4), (3, 8);
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
3	8
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1 ORDER BY a;
a	b
1	1
2	4
SELECT a FROM t1 WHERE b > 2;
a
2
SELECT b from t1 where a != 3;
b
1
4
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1 ORDER BY b;
a	b
1	1
SELECT a FROM t1 WHERE b > 2;
a
SELECT b from t1 where a != 3;
b
1
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1 ORDER BY a;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
INSERT INTO t1 (a,b) VALUES (4, 1), (5, 4), (6, 8);
SELECT a,b FROM t1;
a	b
4	1
5	4
6	8
SELECT a FROM t1 WHERE b < 5;
a
4
5
ALTER TABLE t1 TRUNCATE PARTITION p2;
SELECT a,b FROM t1;
a	b
4	1
5	4
INSERT INTO t1(a,b) VALUES(7, 1);
SELECT b from t1 WHERE a > 2;
b
1
1
4
SELECT a,b FROM t1;
a	b
4	1
5	4
7	1
ALTER TABLE t1 TRUNCATE PARTITION p1;
SELECT a,b FROM t1;
a	b
4	1
7	1
INSERT INTO t1(a,b) VALUES(8, 4);
SELECT a,b FROM t1;
a	b
4	1
7	1
8	4
SELECT b from t1 WHERE a < 9;
b
1
1
4
ALTER TABLE t1 TRUNCATE PARTITION p0;
SELECT a,b FROM t1;
a	b
8	4
INSERT INTO t1(a,b) VALUES(9, 8);
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
TRUNCATE TABLE t1;
SELECT a,b FROM t1;
a	b
set global rocksdb_force_flush_memtable_now = true;
set global rocksdb_compact_cf = 'default';
SELECT b FROM t1 WHERE a < 5;
b
1
2
3
4
TRUNCATE TABLE t1;
SELECT b FROM t1 WHERE a < 5;
b
DROP TABLE t1;
