Skip to content

Commit 57f5c31

Browse files
committed
MDEV-21445 Strange/inconsistent behavior of IN condition when mixing numbers and strings
1 parent bdc1134 commit 57f5c31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+733
-498
lines changed

mysql-test/main/check_constraint.result

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,32 +161,32 @@ EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
161161
FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2))
162162
);
163163
INSERT INTO t1 VALUES (NULL, 'Ken');
164-
ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
164+
ERROR 22007: Truncated incorrect DECIMAL value: 'Ken'
165165
SHOW WARNINGS;
166166
Level Code Message
167-
Error 1292 Truncated incorrect DOUBLE value: 'Ken'
167+
Error 1292 Truncated incorrect DECIMAL value: 'Ken'
168168
Error 4025 CONSTRAINT `t1.FirstName` failed for `test`.`t1`
169169
INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
170-
ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
170+
ERROR 22007: Truncated incorrect DECIMAL value: 'Ken'
171171
SHOW WARNINGS;
172172
Level Code Message
173-
Error 1292 Truncated incorrect DOUBLE value: 'Ken'
173+
Error 1292 Truncated incorrect DECIMAL value: 'Ken'
174174
Error 4025 CONSTRAINT `t1.FirstName` failed for `test`.`t1`
175175
INSERT IGNORE INTO t1 VALUES (NULL, 'Ken');
176176
Warnings:
177-
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
177+
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
178178
INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
179179
Warnings:
180-
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
181-
Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
180+
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
181+
Warning 1292 Truncated incorrect DECIMAL value: 'Brian'
182182
set sql_mode="";
183183
INSERT INTO t1 VALUES (NULL, 'Ken');
184184
Warnings:
185-
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
185+
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
186186
INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
187187
Warnings:
188-
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
189-
Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
188+
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
189+
Warning 1292 Truncated incorrect DECIMAL value: 'Brian'
190190
set sql_mode=default;
191191
select * from t1;
192192
EmployeeID FirstName

mysql-test/main/compare.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ insert into t1 values (0x01,0x01);
4747
select * from t1 where a=b;
4848
a b
4949
Warnings:
50-
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
50+
Warning 1292 Truncated incorrect DECIMAL value: '\x01'
5151
select * from t1 where a=b and b=0x01;
5252
a b
5353
Warnings:
54-
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
54+
Warning 1292 Truncated incorrect DECIMAL value: '\x01'
5555
drop table if exists t1;
5656
CREATE TABLE t1 (b int(2) zerofill, c int(2) zerofill);
5757
INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2);

mysql-test/main/ctype_cp1251.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,17 +3371,17 @@ SELECT * FROM t1 WHERE a IN (1,2,3);
33713371
a
33723372
1
33733373
Warnings:
3374-
Warning 1292 Truncated incorrect DOUBLE value: '`1'
3374+
Warning 1292 Truncated incorrect DECIMAL value: '`1'
33753375
SELECT * FROM t1 WHERE a IN (1,2,3) AND a=' 1';
33763376
a
33773377
1
33783378
Warnings:
3379-
Warning 1292 Truncated incorrect DOUBLE value: '`1'
3379+
Warning 1292 Truncated incorrect DECIMAL value: '`1'
33803380
SELECT * FROM t1 WHERE a IN (1,2,3,'4') AND a=' 1';
33813381
a
33823382
1
33833383
Warnings:
3384-
Warning 1292 Truncated incorrect DOUBLE value: '`1'
3384+
Warning 1292 Truncated incorrect DECIMAL value: '`1'
33853385
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (1,2,3) AND a=' 1';
33863386
id select_type table type possible_keys key key_len ref rows filtered Extra
33873387
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where

mysql-test/main/ctype_utf8.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10286,7 +10286,7 @@ SELECT * FROM t1 WHERE a=10;
1028610286
a
1028710287
1e1
1028810288
Warnings:
10289-
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
10289+
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
1029010290
SELECT * FROM t1 WHERE a='1e1';
1029110291
a
1029210292
1e1
@@ -10295,12 +10295,12 @@ SELECT * FROM t1 WHERE a=10 AND a='1e1';
1029510295
a
1029610296
1e1
1029710297
Warnings:
10298-
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
10298+
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
1029910299
SELECT * FROM t1 WHERE (a,a)=(10,'1e1');
1030010300
a
1030110301
1e1
1030210302
Warnings:
10303-
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
10303+
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
1030410304
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a,a)=(10,'1e1');
1030510305
id select_type table type possible_keys key key_len ref rows filtered Extra
1030610306
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
@@ -10317,17 +10317,17 @@ SELECT * FROM t1 WHERE a IN (1,2);
1031710317
a
1031810318
1ë1
1031910319
Warnings:
10320-
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
10320+
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
1032110321
SELECT * FROM t1 WHERE a IN (1,2) AND a='1ë1';
1032210322
a
1032310323
1ë1
1032410324
Warnings:
10325-
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
10325+
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
1032610326
SELECT * FROM t1 WHERE a IN (1,2,'x') AND a='1ë1';
1032710327
a
1032810328
1ë1
1032910329
Warnings:
10330-
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
10330+
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
1033110331
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (1,2) AND a='1ë1';
1033210332
id select_type table type possible_keys key key_len ref rows filtered Extra
1033310333
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where

mysql-test/main/distinct.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,13 @@ a
677677
A
678678
0
679679
Warnings:
680-
Warning 1292 Truncated incorrect DOUBLE value: 'A'
680+
Warning 1292 Truncated incorrect DECIMAL value: 'A'
681681
SELECT DISTINCT a FROM t1 WHERE a=0;
682682
a
683683
A
684684
0
685685
Warnings:
686-
Warning 1292 Truncated incorrect DOUBLE value: 'A'
686+
Warning 1292 Truncated incorrect DECIMAL value: 'A'
687687
DROP TABLE t1;
688688
CREATE TABLE t1 (a DATE);
689689
INSERT INTO t1 VALUES ('1972-07-29'), ('1972-02-06');

mysql-test/main/func_debug.result

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -774,28 +774,28 @@ SELECT 'a' IN ('a',2);
774774
1
775775
Warnings:
776776
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
777-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
777+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
778778
Note 1105 DBUG: types_compatible=no bisect=no
779779
SELECT 'a' IN ('a',2,NULL);
780780
'a' IN ('a',2,NULL)
781781
1
782782
Warnings:
783783
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
784-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
784+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
785785
Note 1105 DBUG: types_compatible=no bisect=no
786786
SELECT 'a' NOT IN ('a',2);
787787
'a' NOT IN ('a',2)
788788
0
789789
Warnings:
790790
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
791-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
791+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
792792
Note 1105 DBUG: types_compatible=no bisect=no
793793
SELECT 'a' NOT IN ('a',2,NULL);
794794
'a' NOT IN ('a',2,NULL)
795795
0
796796
Warnings:
797797
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
798-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
798+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
799799
Note 1105 DBUG: types_compatible=no bisect=no
800800
SELECT TIME'10:20:30' IN (1,TIME'10:20:30');
801801
TIME'10:20:30' IN (1,TIME'10:20:30')
@@ -999,25 +999,25 @@ SELECT a IN (1,'1') FROM t1;
999999
a IN (1,'1')
10001000
Warnings:
10011001
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
1002-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1002+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
10031003
Note 1105 DBUG: types_compatible=no bisect=no
10041004
SELECT a IN (1,'1',NULL) FROM t1;
10051005
a IN (1,'1',NULL)
10061006
Warnings:
10071007
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
1008-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1008+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
10091009
Note 1105 DBUG: types_compatible=no bisect=no
10101010
SELECT a NOT IN (1,'1') FROM t1;
10111011
a NOT IN (1,'1')
10121012
Warnings:
10131013
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
1014-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1014+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
10151015
Note 1105 DBUG: types_compatible=no bisect=no
10161016
SELECT a NOT IN (1,'1',NULL) FROM t1;
10171017
a NOT IN (1,'1',NULL)
10181018
Warnings:
10191019
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
1020-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1020+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
10211021
Note 1105 DBUG: types_compatible=no bisect=no
10221022
SELECT a IN (1,TIME'10:20:30') FROM t1;
10231023
a IN (1,TIME'10:20:30')
@@ -1197,7 +1197,7 @@ SELECT a IN ('a',1) FROM t1;
11971197
a IN ('a',1)
11981198
Warnings:
11991199
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
1200-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1200+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
12011201
Note 1105 DBUG: types_compatible=no bisect=no
12021202
SELECT a IN ('a',TIME'10:20:30') FROM t1;
12031203
a IN ('a',TIME'10:20:30')
@@ -1209,7 +1209,7 @@ SELECT a NOT IN ('a',1) FROM t1;
12091209
a NOT IN ('a',1)
12101210
Warnings:
12111211
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
1212-
Note 1105 DBUG: [1] arg=2 handler=1 (double)
1212+
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
12131213
Note 1105 DBUG: types_compatible=no bisect=no
12141214
SELECT a NOT IN ('a',TIME'10:20:30') FROM t1;
12151215
a NOT IN ('a',TIME'10:20:30')
@@ -1577,32 +1577,32 @@ A NULL
15771577
B NULL
15781578
Warnings:
15791579
Note 1105 DBUG: [0] arg=2 handler=0 (longblob)
1580-
Note 1105 DBUG: [1] arg=3 handler=1 (double)
1580+
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
15811581
Note 1105 DBUG: types_compatible=no bisect=no
15821582
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN ('A',b,10);
15831583
a b
15841584
A NULL
15851585
B NULL
15861586
Warnings:
15871587
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
1588-
Note 1105 DBUG: [1] arg=3 handler=1 (double)
1588+
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
15891589
Note 1105 DBUG: types_compatible=no bisect=no
15901590
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN (b,a,10);
15911591
a b
15921592
A NULL
15931593
Warnings:
15941594
Note 1105 DBUG: [0] arg=2 handler=0 (longblob)
1595-
Note 1105 DBUG: [1] arg=3 handler=1 (double)
1595+
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
15961596
Note 1105 DBUG: types_compatible=no bisect=no
1597-
Warning 1292 Truncated incorrect DOUBLE value: 'A'
1597+
Warning 1292 Truncated incorrect DECIMAL value: 'A'
15981598
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN (a,b,10);
15991599
a b
16001600
A NULL
16011601
Warnings:
16021602
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
1603-
Note 1105 DBUG: [1] arg=3 handler=1 (double)
1603+
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
16041604
Note 1105 DBUG: types_compatible=no bisect=no
1605-
Warning 1292 Truncated incorrect DOUBLE value: 'A'
1605+
Warning 1292 Truncated incorrect DECIMAL value: 'A'
16061606
DROP TABLE t1;
16071607
#
16081608
# MDEV-11497 Wrong result for (int_expr IN (mixture of signed and unsigned expressions))

mysql-test/main/func_if.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ select nullif(1,'test');
6363
nullif(1,'test')
6464
1
6565
Warnings:
66-
Warning 1292 Truncated incorrect DOUBLE value: 'test'
66+
Warning 1292 Truncated incorrect DECIMAL value: 'test'
6767
select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test");
6868
NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test")
6969
NULL NULL NULL NULL

mysql-test/main/func_in.result

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -498,21 +498,21 @@ f1
498498
a
499499
1
500500
Warnings:
501-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
501+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
502502
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
503503
f1 case f1 when 'a' then '+' when 1 then '-' end
504504
a +
505505
b NULL
506506
1 -
507507
Warnings:
508-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
508+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
509509
create index t1f1_idx on t1(f1);
510510
select f1 from t1 where f1 in ('a',1);
511511
f1
512512
1
513513
a
514514
Warnings:
515-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
515+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
516516
explain select f1 from t1 where f1 in ('a',1);
517517
id select_type table type possible_keys key key_len ref rows Extra
518518
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
@@ -527,8 +527,8 @@ select f1 from t1 where f1 in (2,1);
527527
f1
528528
1
529529
Warnings:
530-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
531-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
530+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
531+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
532532
explain select f1 from t1 where f1 in (2,1);
533533
id select_type table type possible_keys key key_len ref rows Extra
534534
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
@@ -539,31 +539,31 @@ f2
539539
0
540540
2
541541
Warnings:
542-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
543-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
544-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
542+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
543+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
544+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
545545
explain select f2 from t2 where f2 in ('a',2);
546546
id select_type table type possible_keys key key_len ref rows Extra
547547
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
548548
select f2 from t2 where f2 in ('a','b');
549549
f2
550550
0
551551
Warnings:
552-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
553-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
552+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
553+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
554554
explain select f2 from t2 where f2 in ('a','b');
555555
id select_type table type possible_keys key key_len ref rows Extra
556556
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
557557
Warnings:
558-
Warning 1292 Truncated incorrect DOUBLE value: 'a'
559-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
558+
Warning 1292 Truncated incorrect DECIMAL value: 'a'
559+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
560560
select f2 from t2 where f2 in (1,'b');
561561
f2
562562
0
563563
1
564564
Warnings:
565-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
566-
Warning 1292 Truncated incorrect DOUBLE value: 'b'
565+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
566+
Warning 1292 Truncated incorrect DECIMAL value: 'b'
567567
explain select f2 from t2 where f2 in (1,'b');
568568
id select_type table type possible_keys key key_len ref rows Extra
569569
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index

mysql-test/main/func_misc.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ SELECT COALESCE(a) = COALESCE(b) FROM t1;
303303
COALESCE(a) = COALESCE(b)
304304
1
305305
Warnings:
306-
Warning 1292 Truncated incorrect DOUBLE value: ''
306+
Warning 1292 Truncated incorrect DECIMAL value: ''
307307
DROP TABLE t1;
308308
#
309309
# Bug #54461: crash with longblob and union or update with subquery

mysql-test/main/func_str.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("
372372
position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql"))
373373
1 0 3
374374
Warnings:
375-
Warning 1292 Truncated incorrect DOUBLE value: 'baaa'
375+
Warning 1292 Truncated incorrect DECIMAL value: 'baaa'
376376
select position(("1" in (1,2,3)) in "01");
377377
position(("1" in (1,2,3)) in "01")
378378
2
@@ -1184,12 +1184,12 @@ SELECT * FROM t1, t2 WHERE num=str;
11841184
str num
11851185
notnumber 0
11861186
Warnings:
1187-
Warning 1292 Truncated incorrect DOUBLE value: 'notnumber'
1187+
Warning 1292 Truncated incorrect DECIMAL value: 'notnumber'
11881188
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
11891189
str num
11901190
notnumber 0
11911191
Warnings:
1192-
Warning 1292 Truncated incorrect DOUBLE value: 'notnum'
1192+
Warning 1292 Truncated incorrect DECIMAL value: 'notnum'
11931193
DROP TABLE t1,t2;
11941194
CREATE TABLE t1(
11951195
id int(11) NOT NULL auto_increment,

0 commit comments

Comments
 (0)