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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
#
# Start of 5.5 tests
#
#
# MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
@a := 1
1
SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
COALESCE(1)
1
SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
COALESCE(@a:=1)
1
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
COALESCE(@a)
1
DROP TABLE t1;
#
# MDEV-21065 UNIQUE constraint causes a query with string comparison to omit a row in the result set
#
CREATE TABLE t1 (c0 INT UNIQUE);
INSERT INTO t1 VALUES (NULL), (NULL), (NULL), (NULL), (1), (0);
SELECT * FROM t1 WHERE c0 < '\n2';
c0
0
1
DROP TABLE t1;
SELECT CAST('\n2' AS INT);
CAST('\n2' AS INT)
2
#
# End of 5.5 tests
#
#
# Start of 10.1 tests
#
#
# MDEV-8741 Equal field propagation leaves some remainders after simplifying WHERE zerofill_column=2010 AND zerofill_column>=2010
#
CREATE TABLE t1 (a INT ZEROFILL);
INSERT INTO t1 VALUES (2010),(2020);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2010 AND a>=2010;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2010
DROP TABLE t1;
#
# MDEV-8369 Unexpected impossible WHERE for a condition on a ZEROFILL field
#
CREATE TABLE t1 (a INT ZEROFILL);
INSERT INTO t1 VALUES (128),(129);
SELECT * FROM t1 WHERE a=128;
a
0000000128
SELECT * FROM t1 WHERE hex(a)='80';
a
0000000128
SELECT * FROM t1 WHERE a=128 AND hex(a)='80';
a
0000000128
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE a=128 AND hex(a)='80';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 128 and hex(`test`.`t1`.`a`) = '80'
DROP TABLE t1;
#
# End of 10.1 tests
#
#
# Start of 10.2 tests
#
#
# MDEV-9393 Split Copy_field::get_copy_func() into virtual methods in Field
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10.1),(10.9);
SELECT * FROM t1;
a
10
11
DROP TABLE t1;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a DECIMAL(10,2));
INSERT INTO t2 VALUES (10.1),(10.9);
INSERT INTO t1 SELECT a FROM t2;
SELECT * FROM t1;
a
10
11
DROP TABLE t1,t2;
CREATE TABLE t1 (a DECIMAL(10,2));
INSERT INTO t1 VALUES (10.1),(10.9);
ALTER TABLE t1 MODIFY a INT;
SELECT * FROM t1;
a
10
11
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (TIME'00:00:10.1'),(TIME'00:00:10.9');
SELECT * FROM t1;
a
10
10
DROP TABLE t1;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a TIME(1));
INSERT INTO t2 VALUES (10.1),(10.9);
INSERT INTO t1 SELECT a FROM t2;
SELECT * FROM t1;
a
10
10
DROP TABLE t1,t2;
CREATE TABLE t1 (a TIME(1));
INSERT INTO t1 VALUES (10.1),(10.9);
ALTER TABLE t1 MODIFY a INT;
SELECT * FROM t1;
a
10
10
DROP TABLE t1;
#
# MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result
#
CREATE TABLE t1 (a DECIMAL(30,0));
INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED));
SELECT * FROM t1;
a
18446744073709551615
ALTER TABLE t1 MODIFY a BIGINT UNSIGNED;
SELECT * FROM t1;
a
18446744073709551615
DROP TABLE t1;
#
# End of 10.2 tests
#
#
# Start of 10.3 tests
#
#
# MDEV-15926 MEDIUMINT returns wrong I_S attributes
#
CREATE TABLE t1 (a MEDIUMINT, b MEDIUMINT UNSIGNED);
SELECT COLUMN_NAME, NUMERIC_PRECISION FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1' ORDER BY COLUMN_NAME;
COLUMN_NAME NUMERIC_PRECISION
a 7
b 8
DROP TABLE t1;
#
# MDEV-15946 MEDIUMINT(N<8) creates a wrong data type on conversion to string
#
CREATE TABLE t1 (
uint8 TINYINT(2) UNSIGNED, sint8 TINYINT(2),
uint16 SMALLINT(2) UNSIGNED, sint16 SMALLINT(2),
uint24 MEDIUMINT(2) UNSIGNED, sint24 MEDIUMINT(2),
uint32 INT(2) UNSIGNED, sint32 INT(2),
uint64 BIGINT(2) UNSIGNED, sint64 BIGINT(2)
);
CREATE TABLE t2 AS SELECT
CONCAT(uint8),CONCAT(sint8),
CONCAT(uint16),CONCAT(sint16),
CONCAT(uint24),CONCAT(sint24),
CONCAT(uint32),CONCAT(sint32),
CONCAT(uint64),CONCAT(sint64)
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`CONCAT(uint8)` varchar(3) DEFAULT NULL,
`CONCAT(sint8)` varchar(4) DEFAULT NULL,
`CONCAT(uint16)` varchar(5) DEFAULT NULL,
`CONCAT(sint16)` varchar(6) DEFAULT NULL,
`CONCAT(uint24)` varchar(8) DEFAULT NULL,
`CONCAT(sint24)` varchar(8) DEFAULT NULL,
`CONCAT(uint32)` varchar(10) DEFAULT NULL,
`CONCAT(sint32)` varchar(11) DEFAULT NULL,
`CONCAT(uint64)` varchar(20) DEFAULT NULL,
`CONCAT(sint64)` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 AS SELECT
CONCAT(COALESCE(uint8)),CONCAT(COALESCE(sint8)),
CONCAT(COALESCE(uint16)),CONCAT(COALESCE(sint16)),
CONCAT(COALESCE(uint24)),CONCAT(COALESCE(sint24)),
CONCAT(COALESCE(uint32)),CONCAT(COALESCE(sint32)),
CONCAT(COALESCE(uint64)),CONCAT(COALESCE(sint64))
FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`CONCAT(COALESCE(uint8))` varchar(3) DEFAULT NULL,
`CONCAT(COALESCE(sint8))` varchar(4) DEFAULT NULL,
`CONCAT(COALESCE(uint16))` varchar(5) DEFAULT NULL,
`CONCAT(COALESCE(sint16))` varchar(6) DEFAULT NULL,
`CONCAT(COALESCE(uint24))` varchar(8) DEFAULT NULL,
`CONCAT(COALESCE(sint24))` varchar(8) DEFAULT NULL,
`CONCAT(COALESCE(uint32))` varchar(10) DEFAULT NULL,
`CONCAT(COALESCE(sint32))` varchar(11) DEFAULT NULL,
`CONCAT(COALESCE(uint64))` varchar(20) DEFAULT NULL,
`CONCAT(COALESCE(sint64))` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
DROP TABLE t1;
CREATE FUNCTION uint8() RETURNS TINYINT(2) UNSIGNED RETURN 1;
CREATE FUNCTION sint8() RETURNS TINYINT(2) RETURN 1;
CREATE FUNCTION uint16() RETURNS SMALLINT(2) UNSIGNED RETURN 1;
CREATE FUNCTION sint16() RETURNS SMALLINT(2) RETURN 1;
CREATE FUNCTION uint24() RETURNS MEDIUMINT(2) UNSIGNED RETURN 1;
CREATE FUNCTION sint24() RETURNS MEDIUMINT(2) RETURN 1;
CREATE FUNCTION uint32() RETURNS INT(2) UNSIGNED RETURN 1;
CREATE FUNCTION sint32() RETURNS INT(2) RETURN 1;
CREATE FUNCTION uint64() RETURNS BIGINT(2) UNSIGNED RETURN 1;
CREATE FUNCTION sint64() RETURNS BIGINT(2) RETURN 1;
CREATE TABLE t1 AS SELECT
CONCAT(uint8()), CONCAT(sint8()),
CONCAT(uint16()),CONCAT(sint16()),
CONCAT(uint24()),CONCAT(sint24()),
CONCAT(uint32()),CONCAT(sint32()),
CONCAT(uint64()),CONCAT(sint64());
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CONCAT(uint8())` varchar(3) DEFAULT NULL,
`CONCAT(sint8())` varchar(4) DEFAULT NULL,
`CONCAT(uint16())` varchar(5) DEFAULT NULL,
`CONCAT(sint16())` varchar(6) DEFAULT NULL,
`CONCAT(uint24())` varchar(8) DEFAULT NULL,
`CONCAT(sint24())` varchar(8) DEFAULT NULL,
`CONCAT(uint32())` varchar(10) DEFAULT NULL,
`CONCAT(sint32())` varchar(11) DEFAULT NULL,
`CONCAT(uint64())` varchar(20) DEFAULT NULL,
`CONCAT(sint64())` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
CONCAT(COALESCE(uint8())),CONCAT(COALESCE(sint8())),
CONCAT(COALESCE(uint16())),CONCAT(COALESCE(sint16())),
CONCAT(COALESCE(uint24())),CONCAT(COALESCE(sint24())),
CONCAT(COALESCE(uint32())),CONCAT(COALESCE(sint32())),
CONCAT(COALESCE(uint64())),CONCAT(COALESCE(sint64()));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CONCAT(COALESCE(uint8()))` varchar(3) DEFAULT NULL,
`CONCAT(COALESCE(sint8()))` varchar(4) DEFAULT NULL,
`CONCAT(COALESCE(uint16()))` varchar(5) DEFAULT NULL,
`CONCAT(COALESCE(sint16()))` varchar(6) DEFAULT NULL,
`CONCAT(COALESCE(uint24()))` varchar(8) DEFAULT NULL,
`CONCAT(COALESCE(sint24()))` varchar(8) DEFAULT NULL,
`CONCAT(COALESCE(uint32()))` varchar(10) DEFAULT NULL,
`CONCAT(COALESCE(sint32()))` varchar(11) DEFAULT NULL,
`CONCAT(COALESCE(uint64()))` varchar(20) DEFAULT NULL,
`CONCAT(COALESCE(sint64()))` varchar(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP FUNCTION uint8;
DROP FUNCTION sint8;
DROP FUNCTION uint16;
DROP FUNCTION sint16;
DROP FUNCTION uint24;
DROP FUNCTION sint24;
DROP FUNCTION uint32;
DROP FUNCTION sint32;
DROP FUNCTION uint64;
DROP FUNCTION sint64;
#
# MDEV-20285 Wrong result on INSERT..SELECT when converting from SIGNED to UNSIGNED
#
CREATE TABLE t1 (a TINYINT UNSIGNED);
CREATE TABLE t2 (a TINYINT);
INSERT INTO t1 VALUES (255);
INSERT IGNORE INTO t2 SELECT a FROM t1;
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
SELECT * FROM t2;
a
127
DROP TABLE t1, t2;
#
# End of 10.3 tests
#
#
# Start of 10.4 tests
#
#
# MDEV-11362 True condition elimination does not work for DECIMAL and temporal dynamic SQL parameters
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1+a<=>1+a;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>?+a' USING 1,1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>1+a' USING 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1+a<=>?+a' USING 1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
DROP TABLE t1;
#
# MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant
#
CREATE TABLE t1 (a TINYINT, KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
EXPLAIN SELECT * FROM t1 WHERE a=200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE a<=>200;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
#
# MDEV-8554 Expect "Impossible WHERE" for never true values like a!=a, a<a, a>a
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
EXPLAIN SELECT * FROM t1 WHERE a!=a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a!=a;
COUNT(*)
0
EXPLAIN SELECT * FROM t1 WHERE a>a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a>a;
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a<a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a<a;
COUNT(*)
0
ALTER TABLE t1 MODIFY a TINYINT NOT NULL;
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a!=a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a!=a;
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a>a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a>a;
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a<a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
SELECT COUNT(*) FROM t1 WHERE a<a;
COUNT(*)
0
#
# MDEV-8554 Modifing expression doesn't hit "Impossible WHERE" clause
#
EXPLAIN SELECT COUNT(*) FROM t1 WHERE not (a!=a);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
SELECT COUNT(*) FROM t1 WHERE not (a!=a);
COUNT(*)
3
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a>a-1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT COUNT(*) FROM t1 WHERE a>a-1;
COUNT(*)
3
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a<a+1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT COUNT(*) FROM t1 WHERE a<a+1;
COUNT(*)
3
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a-1<a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT COUNT(*) FROM t1 WHERE a-1<a;
COUNT(*)
3
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a NOT LIKE a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT COUNT(*) FROM t1 WHERE a NOT LIKE a;
COUNT(*)
0
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a XOR a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
SELECT COUNT(*) FROM t1 WHERE a XOR a;
COUNT(*)
0
DROP TABLE t1;
#
# End of 10.4 tests
#
|