--source include/have_rocksdb.inc

# Tests the Apply_changes_iter class for walking forward and backwards
# with data in both the transaction class and in the rocksdb storage layer

--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
--enable_warnings

CREATE TABLE t1 (
  pk INT NOT NULL PRIMARY KEY,
  key1 INT NOT NULL,
  KEY (key1)
) ENGINE=ROCKSDB;

INSERT INTO t1 VALUES (12,12);
INSERT INTO t1 VALUES (6,6);
BEGIN;
INSERT INTO t1 VALUES (8,8), (10,10);
SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
SELECT * FROM t1 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
SELECT * FROM t1 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
ROLLBACK;

CREATE TABLE t2 (
  pk INT NOT NULL PRIMARY KEY,
  key1 INT NOT NULL,
  KEY (key1) COMMENT 'rev:cf'
) ENGINE=ROCKSDB;

INSERT INTO t2 VALUES (12,12);
INSERT INTO t2 VALUES (6,6);
BEGIN;
INSERT INTO t2 VALUES (8,8), (10,10);
SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 DESC;
SELECT * FROM t2 WHERE key1 BETWEEN 4 and 11 ORDER BY KEY1 ASC;
SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 DESC;
SELECT * FROM t2 IGNORE INDEX(key1) WHERE key1 BETWEEN 4 and 11 ORDER BY key1 ASC;
ROLLBACK;

DROP TABLE t1;
DROP TABLE t2;
