Skip to content
Permalink
Browse files
MDEV-21445 Strange/inconsistent behavior of IN condition when mixing …
…numbers and strings
  • Loading branch information
abarkov committed Jul 6, 2022
1 parent bdc1134 commit 57f5c31
Show file tree
Hide file tree
Showing 63 changed files with 733 additions and 498 deletions.
@@ -161,32 +161,32 @@ EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2))
);
INSERT INTO t1 VALUES (NULL, 'Ken');
ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
ERROR 22007: Truncated incorrect DECIMAL value: 'Ken'
SHOW WARNINGS;
Level Code Message
Error 1292 Truncated incorrect DOUBLE value: 'Ken'
Error 1292 Truncated incorrect DECIMAL value: 'Ken'
Error 4025 CONSTRAINT `t1.FirstName` failed for `test`.`t1`
INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
ERROR 22007: Truncated incorrect DECIMAL value: 'Ken'
SHOW WARNINGS;
Level Code Message
Error 1292 Truncated incorrect DOUBLE value: 'Ken'
Error 1292 Truncated incorrect DECIMAL value: 'Ken'
Error 4025 CONSTRAINT `t1.FirstName` failed for `test`.`t1`
INSERT IGNORE INTO t1 VALUES (NULL, 'Ken');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
Warning 1292 Truncated incorrect DECIMAL value: 'Brian'
set sql_mode="";
INSERT INTO t1 VALUES (NULL, 'Ken');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
Warning 1292 Truncated incorrect DECIMAL value: 'Ken'
Warning 1292 Truncated incorrect DECIMAL value: 'Brian'
set sql_mode=default;
select * from t1;
EmployeeID FirstName
@@ -47,11 +47,11 @@ insert into t1 values (0x01,0x01);
select * from t1 where a=b;
a b
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
Warning 1292 Truncated incorrect DECIMAL value: '\x01'
select * from t1 where a=b and b=0x01;
a b
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '\x01'
Warning 1292 Truncated incorrect DECIMAL value: '\x01'
drop table if exists t1;
CREATE TABLE t1 (b int(2) zerofill, c int(2) zerofill);
INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2);
@@ -3371,17 +3371,17 @@ SELECT * FROM t1 WHERE a IN (1,2,3);
a
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '`1'
Warning 1292 Truncated incorrect DECIMAL value: '`1'
SELECT * FROM t1 WHERE a IN (1,2,3) AND a=' 1';
a
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '`1'
Warning 1292 Truncated incorrect DECIMAL value: '`1'
SELECT * FROM t1 WHERE a IN (1,2,3,'4') AND a=' 1';
a
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '`1'
Warning 1292 Truncated incorrect DECIMAL value: '`1'
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (1,2,3) AND a=' 1';
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
@@ -10286,7 +10286,7 @@ SELECT * FROM t1 WHERE a=10;
a
1e1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
SELECT * FROM t1 WHERE a='1e1';
a
1e1
@@ -10295,12 +10295,12 @@ SELECT * FROM t1 WHERE a=10 AND a='1e1';
a
1e1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
SELECT * FROM t1 WHERE (a,a)=(10,'1e1');
a
1e1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1é1'
Warning 1292 Truncated incorrect DECIMAL value: '1é1'
EXPLAIN EXTENDED SELECT * FROM t1 WHERE (a,a)=(10,'1e1');
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
@@ -10317,17 +10317,17 @@ SELECT * FROM t1 WHERE a IN (1,2);
a
1ë1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
SELECT * FROM t1 WHERE a IN (1,2) AND a='1ë1';
a
1ë1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
SELECT * FROM t1 WHERE a IN (1,2,'x') AND a='1ë1';
a
1ë1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1ë1'
Warning 1292 Truncated incorrect DECIMAL value: '1ë1'
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN (1,2) AND a='1ë1';
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
@@ -677,13 +677,13 @@ a
A
0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'A'
Warning 1292 Truncated incorrect DECIMAL value: 'A'
SELECT DISTINCT a FROM t1 WHERE a=0;
a
A
0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'A'
Warning 1292 Truncated incorrect DECIMAL value: 'A'
DROP TABLE t1;
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('1972-07-29'), ('1972-02-06');
@@ -774,28 +774,28 @@ SELECT 'a' IN ('a',2);
1
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT 'a' IN ('a',2,NULL);
'a' IN ('a',2,NULL)
1
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT 'a' NOT IN ('a',2);
'a' NOT IN ('a',2)
0
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT 'a' NOT IN ('a',2,NULL);
'a' NOT IN ('a',2,NULL)
0
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT TIME'10:20:30' IN (1,TIME'10:20:30');
TIME'10:20:30' IN (1,TIME'10:20:30')
@@ -999,25 +999,25 @@ SELECT a IN (1,'1') FROM t1;
a IN (1,'1')
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a IN (1,'1',NULL) FROM t1;
a IN (1,'1',NULL)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a NOT IN (1,'1') FROM t1;
a NOT IN (1,'1')
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a NOT IN (1,'1',NULL) FROM t1;
a NOT IN (1,'1',NULL)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a IN (1,TIME'10:20:30') FROM t1;
a IN (1,TIME'10:20:30')
@@ -1197,7 +1197,7 @@ SELECT a IN ('a',1) FROM t1;
a IN ('a',1)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a IN ('a',TIME'10:20:30') FROM t1;
a IN ('a',TIME'10:20:30')
@@ -1209,7 +1209,7 @@ SELECT a NOT IN ('a',1) FROM t1;
a NOT IN ('a',1)
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=2 handler=1 (double)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a NOT IN ('a',TIME'10:20:30') FROM t1;
a NOT IN ('a',TIME'10:20:30')
@@ -1577,32 +1577,32 @@ A NULL
B NULL
Warnings:
Note 1105 DBUG: [0] arg=2 handler=0 (longblob)
Note 1105 DBUG: [1] arg=3 handler=1 (double)
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN ('A',b,10);
a b
A NULL
B NULL
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=3 handler=1 (double)
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN (b,a,10);
a b
A NULL
Warnings:
Note 1105 DBUG: [0] arg=2 handler=0 (longblob)
Note 1105 DBUG: [1] arg=3 handler=1 (double)
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
Warning 1292 Truncated incorrect DOUBLE value: 'A'
Warning 1292 Truncated incorrect DECIMAL value: 'A'
SELECT a,NULL AS b FROM t1 GROUP BY a HAVING 'A' IN (a,b,10);
a b
A NULL
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (longblob)
Note 1105 DBUG: [1] arg=3 handler=1 (double)
Note 1105 DBUG: [1] arg=3 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
Warning 1292 Truncated incorrect DOUBLE value: 'A'
Warning 1292 Truncated incorrect DECIMAL value: 'A'
DROP TABLE t1;
#
# MDEV-11497 Wrong result for (int_expr IN (mixture of signed and unsigned expressions))
@@ -63,7 +63,7 @@ select nullif(1,'test');
nullif(1,'test')
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'test'
Warning 1292 Truncated incorrect DECIMAL value: 'test'
select NULLIF(NULL,NULL), NULLIF(NULL,1), NULLIF(NULL,1.0), NULLIF(NULL,"test");
NULLIF(NULL,NULL) NULLIF(NULL,1) NULLIF(NULL,1.0) NULLIF(NULL,"test")
NULL NULL NULL NULL
@@ -498,21 +498,21 @@ f1
a
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
f1 case f1 when 'a' then '+' when 1 then '-' end
a +
b NULL
1 -
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
create index t1f1_idx on t1(f1);
select f1 from t1 where f1 in ('a',1);
f1
1
a
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
explain select f1 from t1 where f1 in ('a',1);
id select_type table type possible_keys key key_len ref rows Extra
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);
f1
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
explain select f1 from t1 where f1 in (2,1);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index t1f1_idx t1f1_idx 2 NULL 3 Using where; Using index
@@ -539,31 +539,31 @@ f2
0
2
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
explain select f2 from t2 where f2 in ('a',2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
select f2 from t2 where f2 in ('a','b');
f2
0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
explain select f2 from t2 where f2 in ('a','b');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
select f2 from t2 where f2 in (1,'b');
f2
0
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DOUBLE value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
Warning 1292 Truncated incorrect DECIMAL value: 'b'
explain select f2 from t2 where f2 in (1,'b');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index
@@ -303,7 +303,7 @@ SELECT COALESCE(a) = COALESCE(b) FROM t1;
COALESCE(a) = COALESCE(b)
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: ''
Warning 1292 Truncated incorrect DECIMAL value: ''
DROP TABLE t1;
#
# Bug #54461: crash with longblob and union or update with subquery
@@ -372,7 +372,7 @@ select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("
position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql"))
1 0 3
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'baaa'
Warning 1292 Truncated incorrect DECIMAL value: 'baaa'
select position(("1" in (1,2,3)) in "01");
position(("1" in (1,2,3)) in "01")
2
@@ -1184,12 +1184,12 @@ SELECT * FROM t1, t2 WHERE num=str;
str num
notnumber 0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'notnumber'
Warning 1292 Truncated incorrect DECIMAL value: 'notnumber'
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
str num
notnumber 0
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'notnum'
Warning 1292 Truncated incorrect DECIMAL value: 'notnum'
DROP TABLE t1,t2;
CREATE TABLE t1(
id int(11) NOT NULL auto_increment,
@@ -1724,7 +1724,7 @@ min(timestampadd(month, 1>'', from_days('%Z')))
NULL
Warnings:
Warning 1292 Truncated incorrect INTEGER value: '%Z'
Warning 1292 Truncated incorrect DOUBLE value: ''
Warning 1292 Truncated incorrect DECIMAL value: ''
Warning 1292 Incorrect datetime value: '0000-00-00'
SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00');
create table t1(a time);
@@ -1654,8 +1654,8 @@ SELECT 1 FROM g1 WHERE a >= ANY
(SELECT 1 FROM g1 WHERE a = geomfromtext('') OR a) ;
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
Warning 1292 Truncated incorrect DECIMAL value: 'a'
DROP TABLE g1;
#
# Bug#16451878 GEOMETRY QUERY CRASHES SERVER

0 comments on commit 57f5c31

Please sign in to comment.