summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/auto_increment_ranges_myisam.result
blob: a300518adebdfbfc0bf31128c250de60dd87551d (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
set default_storage_engine=MYISAM;
drop table if exists t1;
#
# Testing ranges with smallint
#
create table t1 (a smallint primary key auto_increment);
insert into t1 values(32767);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
truncate table t1;
insert into t1 values(32767-1);
insert into t1 values(NULL);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
32766
32767
truncate table t1;
insert into t1 values(32767),(NULL);
ERROR 22003: Out of range value for column 'a' at row 2
select * from t1;
a
32767
truncate table t1;
insert into t1 values(32767-1),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
truncate table t1;
insert ignore into t1 values(32767+1);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
select * from t1;
a
32767
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# Testing ranges with unsigned smallint
#
create table t1 (a smallint unsigned primary key auto_increment);
insert into t1 values(65535);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
truncate table t1;
insert into t1 values(65535-1);
insert into t1 values(NULL);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
65534
65535
truncate table t1;
insert into t1 values(65535),(NULL);
ERROR 22003: Out of range value for column 'a' at row 2
select * from t1;
a
65535
truncate table t1;
insert into t1 values(65535-1),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
truncate table t1;
insert ignore into t1 values(65535+1);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
select * from t1;
a
65535
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# Testing ranges with integer
#
create table t1 (a int primary key auto_increment);
insert into t1 values(2147483647);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
truncate table t1;
insert into t1 values(2147483647-1);
insert into t1 values(NULL);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
2147483646
2147483647
truncate table t1;
insert into t1 values(2147483647),(NULL);
ERROR 22003: Out of range value for column 'a' at row 2
select * from t1;
a
2147483647
truncate table t1;
insert into t1 values(2147483647-1),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
truncate table t1;
insert ignore into t1 values(2147483647+1);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
select * from t1;
a
2147483647
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# Testing ranges with unsigned integer
#
create table t1 (a int unsigned primary key auto_increment);
insert into t1 values(4294967295);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
truncate table t1;
insert into t1 values(4294967295-1);
insert into t1 values(NULL);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
4294967294
4294967295
truncate table t1;
insert into t1 values(4294967295),(NULL);
ERROR 22003: Out of range value for column 'a' at row 2
select * from t1;
a
4294967295
truncate table t1;
insert into t1 values(4294967295-1),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
truncate table t1;
insert ignore into t1 values(4294967295+1);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
select * from t1;
a
4294967295
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# Testing ranges with bigint
#
create table t1 (a bigint primary key auto_increment);
insert into t1 values(cast(9223372036854775807 as unsigned));
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
truncate table t1;
insert into t1 values(cast(9223372036854775807 as unsigned)-1);
insert into t1 values(NULL);
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
select * from t1;
a
9223372036854775806
9223372036854775807
truncate table t1;
insert into t1 values(cast(9223372036854775807 as unsigned)),(NULL);
ERROR 22003: Out of range value for column 'a' at row 2
select * from t1;
a
9223372036854775807
truncate table t1;
insert into t1 values(cast(9223372036854775807 as unsigned)-1),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
truncate table t1;
insert ignore into t1 values(cast(9223372036854775807 as unsigned)+1);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
select * from t1;
a
9223372036854775807
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# Testing ranges with unsigned bigint
#
create table t1 (a bigint unsigned primary key auto_increment);
insert into t1 values(18446744073709551615-1);
insert into t1 values(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
insert into t1 values(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
truncate table t1;
insert into t1 values(18446744073709551615-1);
insert into t1 values(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
insert into t1 values(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
select * from t1;
a
18446744073709551614
truncate table t1;
insert into t1 values(18446744073709551615),(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
select * from t1;
a
18446744073709551615
truncate table t1;
insert into t1 values(18446744073709551615-1),(NULL),(NULL);
ERROR HY000: Failed to read auto-increment value from storage engine
drop table t1;
#
# Test IGNORE and strict mode
#
create table t1 (a smallint primary key auto_increment);
insert ignore into t1 values(32766),(NULL),(NULL),(1);
Warnings:
Warning	167	Out of range value for column 'a' at row 3
select * from t1;
a
1
32766
32767
truncate table t1;
set @org_mode=@@sql_mode;
set @@sql_mode='ansi,traditional';
insert ignore into t1 values(32766),(NULL),(NULL);
Warnings:
Warning	167	Out of range value for column 'a' at row 3
truncate table t1;
insert into t1 values(32766),(NULL),(NULL);
ERROR 22003: Out of range value for column 'a' at row 3
set @@sql_mode=@org_mode;
drop table t1;
#
# Test auto increment with negative numbers
#
CREATE TABLE t1 (a INTEGER AUTO_INCREMENT, PRIMARY KEY (a));
INSERT INTO t1 VALUES (NULL), (2), (-5), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
a
-5
1
2
3
4
TRUNCATE TABLE t1;
INSERT INTO t1 VALUES (-5), (NULL);
SELECT * FROM t1;
a
-5
1
DROP TABLE t1;
#
# Test inserting a value out-of-range into an auto increment column
#
CREATE TABLE t1 (a smallint AUTO_INCREMENT, PRIMARY KEY (a));
INSERT INTO t1 VALUES (2);
INSERT IGNORE INTO t1 VALUES (32768);
Warnings:
Warning	1264	Out of range value for column 'a' at row 1
INSERT INTO t1 VALUES (NULL);
ERROR 22003: Out of range value for column 'a' at row 1
SELECT * FROM t1;
a
2
32767
DROP TABLE t1;
#
# Test old behaviour
#
create table t1 (a smallint primary key auto_increment);
insert into t1 values(32766),(NULL);
delete from t1 where a=32767;
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
#
# MDEV-17333 Assertion in update_auto_increment() upon exotic LOAD
#
create or replace table t1 (pk int auto_increment, x int, primary key(pk), unique key(x))
with system versioning partition by system_time interval 2 day
(partition p1 history, partition pn current);
load data infile 'load.data' ignore into table t1;
Warnings:
Warning	1062	Duplicate entry '1' for key 'x'
Warning	1062	Duplicate entry '1' for key 'x'
drop table t1;