1--source include/have_rocksdb.inc
2
3#
4# auto-increment-offset and auto-increment-increment
5#
6
7############################################
8# TODO:
9# This test currently produces wrong result
10# on the line 36 of the result file and further
11# due to bug MySQL:47118.
12# When/if the bug is fixed,
13# the result will need to be updated
14############################################
15
16--disable_warnings
17DROP TABLE IF EXISTS t1;
18--enable_warnings
19
20--echo #---------------------------
21--echo # auto_increment_offset
22--echo #---------------------------
23SET auto_increment_offset = 200;
24
25CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
26
27# If auto_increment_offset is greater than auto_increment_increment,
28# the offset is ignored
29
30INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
31SELECT LAST_INSERT_ID();
32SELECT a,b FROM t1 ORDER BY a;
33
34--echo #---------------------------
35--echo # auto_increment_increment
36--echo #---------------------------
37
38SET auto_increment_increment = 300;
39# offset should not be ignored anymore
40
41INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
42SELECT LAST_INSERT_ID();
43SELECT a,b FROM t1 ORDER BY a;
44
45SET auto_increment_increment = 50;
46INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
47SELECT LAST_INSERT_ID();
48SELECT a,b FROM t1 ORDER BY a;
49DROP TABLE t1;
50
51
52--echo #---------------------------
53--echo # offset is greater than the max value
54--echo #---------------------------
55
56SET auto_increment_increment = 500;
57SET auto_increment_offset = 300;
58
59CREATE TABLE t1 (a TINYINT AUTO_INCREMENT PRIMARY KEY) ENGINE=rocksdb;
60--echo # In MariaDB, this is an error:
61--error HA_ERR_AUTOINC_ERANGE
62INSERT INTO t1 (a) VALUES (NULL);
63SELECT LAST_INSERT_ID();
64SELECT a FROM t1 ORDER BY a;
65DROP TABLE t1;
66
67--echo #---------------------------
68--echo # test large autoincrement values
69--echo #---------------------------
70
71SET auto_increment_increment = 1;
72SET auto_increment_offset = 1;
73CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
74INSERT INTO t1 VALUES (18446744073709551613, 'a');
75SHOW CREATE TABLE t1;
76INSERT INTO t1 VALUES (NULL, 'b');
77SHOW CREATE TABLE t1;
78--error ER_AUTOINC_READ_FAILED
79INSERT INTO t1 VALUES (NULL, 'c');
80SELECT * FROM t1;
81DROP TABLE t1;
82
83SET auto_increment_increment = 300;
84CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
85INSERT INTO t1 VALUES (18446744073709551613, 'a');
86SHOW CREATE TABLE t1;
87--error ER_AUTOINC_READ_FAILED
88INSERT INTO t1 VALUES (NULL, 'b');
89SHOW CREATE TABLE t1;
90--error ER_AUTOINC_READ_FAILED
91INSERT INTO t1 VALUES (NULL, 'c');
92SELECT * FROM t1;
93DROP TABLE t1;
94
95SET auto_increment_offset = 200;
96CREATE TABLE t1 (a BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, b CHAR(8)) ENGINE=rocksdb;
97INSERT INTO t1 VALUES (18446744073709551613, 'a');
98SHOW CREATE TABLE t1;
99--error ER_AUTOINC_READ_FAILED
100INSERT INTO t1 VALUES (NULL, 'b');
101SHOW CREATE TABLE t1;
102--error ER_AUTOINC_READ_FAILED
103INSERT INTO t1 VALUES (NULL, 'c');
104SELECT * FROM t1;
105DROP TABLE t1;
106
107--echo #----------------------------------
108--echo # Issue #792 Crash in autoincrement
109--echo #----------------------------------
110
111CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
112INSERT INTO t1 VALUES(2177,0);
113DROP TABLE t1;
114
115CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
116INSERT INTO t0 VALUES(0);
117ALTER TABLE t0 AUTO_INCREMENT=0;
118DROP TABLE t0;
119
120--echo #---------------------------------------------------------------
121--echo # MDEV-16703 Assertion failed in load_auto_incr_value_from_index
122--echo #---------------------------------------------------------------
123
124CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
125INSERT INTO t1 (a) VALUES (1);
126UPDATE t1 SET pk = 3;
127ALTER TABLE t1 AUTO_INCREMENT 2;
128DROP TABLE t1;
129
130--echo #----------------------------------
131--echo # Issue #792 Crash in autoincrement
132--echo #----------------------------------
133
134CREATE TABLE t1(C1 DOUBLE AUTO_INCREMENT KEY,C2 CHAR) ENGINE=ROCKSDB;
135INSERT INTO t1 VALUES(2177,0);
136DROP TABLE t1;
137
138CREATE TABLE t0(c0 BLOB) ENGINE=ROCKSDB;
139INSERT INTO t0 VALUES(0);
140ALTER TABLE t0 AUTO_INCREMENT=0;
141DROP TABLE t0;
142
143--echo #----------------------------------
144--echo # Issue #869 Crash in autoincrement
145--echo #----------------------------------
146
147CREATE TABLE t1 (pk INT AUTO_INCREMENT, a INT, PRIMARY KEY(pk)) ENGINE=RocksDB;
148INSERT INTO t1 (a) VALUES (1);
149UPDATE t1 SET pk = 3;
150ALTER TABLE t1 AUTO_INCREMENT 2;
151DROP TABLE t1;
152
153--echo #----------------------------------
154--echo # Issue #902 Debug assert in autoincrement with small field type
155--echo #----------------------------------
156
157SET auto_increment_increment=100, auto_increment_offset=10;
158CREATE TABLE t1(i INT AUTO_INCREMENT PRIMARY KEY) ENGINE=ROCKSDB AUTO_INCREMENT=18446744073709551615;
159# ha_rocksdb::get_auto_increment would assert here
160--error ER_AUTOINC_READ_FAILED
161INSERT INTO t1 VALUES (NULL);
162SELECT * FROM t1;
163ALTER TABLE t1 AUTO_INCREMENT=1;
164INSERT INTO t1 VALUES (NULL);
165SELECT * FROM t1;
166ALTER TABLE t1 AUTO_INCREMENT=18446744073709551615;
167# ha_rocksdb::get_auto_increment would assert here
168--error ER_AUTOINC_READ_FAILED
169INSERT INTO t1 VALUES (NULL);
170SELECT * FROM t1;
171DROP TABLE t1;
172