#
# MDEV-14433: RocksDB may show empty or incorrect output with rocksdb_strict_collation_check=off
#
set global rocksdb_strict_collation_check=off;
set @tmp_rscc=@@rocksdb_strict_collation_check;
CREATE TABLE t1(
a varchar(10) NOT NULL,
b char(1) DEFAULT 'X',
c char(2) NOT NULL DEFAULT '??',
d varchar(10) NOT NULL,
e int(11) DEFAULT 0,
PRIMARY KEY (a,d),
KEY (e)
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
insert into t1 select 1,1,1,1,0;
insert into t1 select 2,1,1,1,0;
insert into t1 select 3,1,1,1,0;
explain
select a from t1 force index(e) where e<10000;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	range	e	e	5	NULL	#	Using index condition
select a from t1;
a
1
2
3
select * from t1;
a	b	c	d	e
1	1	1	1	0
2	1	1	1	0
3	1	1	1	0
DROP TABLE t1;
#
# MDEV-14563: Wrong query plan for query with no PK
#
CREATE TABLE t1(
pk int primary key,
a varchar(10) NOT NULL,   
e int(11) DEFAULT 0,   
KEY (a) 
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
insert into t1 values (1,"a",1),(2,"b",2),(3,"c",2);
explain select a from t1 where a <'b';
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	range	a	a	32	NULL	#	Using where
CREATE TABLE t2(
pk int,
a varchar(10) NOT NULL,
e int(11) DEFAULT 0,   
KEY (a)
) ENGINE=ROCKSDB DEFAULT CHARSET=utf8;
insert into t2 values (1,1,1),(2,2,2);
explain select a from t2 where a <'zzz';
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t2	range	a	a	32	NULL	#	Using where
drop table t1,t2;
set global rocksdb_strict_collation_check=@tmp_rscc;
#
# MDEV-14389: MyRocks and NOPAD collations
#
create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
set global rocksdb_strict_collation_check=off;
create table t1 (pk varchar(10) collate latin1_nopad_bin, primary key(pk)) engine=rocksdb;
ERROR HY000: MyRocks doesn't currently support collations with "No pad" attribute.
set global rocksdb_strict_collation_check=@tmp_rscc;
#
# MDEV-14679: RocksdB plugin fails to load with "Loading of unknown plugin ROCKSDB_CFSTATS
#
select plugin_name, plugin_maturity from information_schema.plugins where plugin_name like '%rocksdb%';
plugin_name	plugin_maturity
ROCKSDB	Stable
ROCKSDB_CFSTATS	Stable
ROCKSDB_DBSTATS	Stable
ROCKSDB_PERF_CONTEXT	Stable
ROCKSDB_PERF_CONTEXT_GLOBAL	Stable
ROCKSDB_CF_OPTIONS	Stable
ROCKSDB_COMPACTION_STATS	Stable
ROCKSDB_GLOBAL_INFO	Stable
ROCKSDB_DDL	Stable
ROCKSDB_SST_PROPS	Stable
ROCKSDB_INDEX_FILE_MAP	Stable
ROCKSDB_LOCKS	Stable
ROCKSDB_TRX	Stable
ROCKSDB_DEADLOCK	Stable
#
#  MDEV-12466 : Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt ||  ...
#
CREATE TABLE t1 (i INT) ENGINE=RocksDB;
FLUSH TABLE t1 FOR EXPORT;
ERROR HY000: Storage engine ROCKSDB of the table `test`.`t1` doesn't have this option
DROP TABLE t1;
# 
# MDEV-16154 Server crashes in in myrocks::ha_rocksdb::load_auto_incr_value_from_inde
# 
CREATE TABLE t1 (a INT) ENGINE=RocksDB;
INSERT INTO t1 VALUES (1);
ALTER TABLE t1 AUTO_INCREMENT 10;
DROP TABLE t1;
# 
# MDEV-16155: UPDATE on RocksDB table with unique constraint does not work
# 
CREATE TABLE t1 (a INT, b CHAR(8), UNIQUE INDEX(a)) ENGINE=RocksDB;
INSERT INTO t1 (a,b) VALUES (1,'foo'),(2,'bar');
UPDATE t1 SET a=a+100;
SELECT * FROM t1;
a	b
101	foo
102	bar
DROP TABLE t1;
#
# MDEV-15319: [SQL Layer] Server crashes in Field::set_null / myrocks::ha_rocksdb::convert_record_from_storage_format
#  (just a testcase)
#
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 ENGINE=RocksDB AS SELECT VALUE(i) AS a FROM t1;
DELETE FROM t2;
DROP TABLE t1,t2;
