@@ -532,3 +532,98 @@ DROP TABLE t1,t2;
532
532
#
533
533
# End of 10.0 tests
534
534
#
535
+ #
536
+ # MDEV-8704 Wrong result for SELECT..WHERE LENGTH(double_column)!=6 AND double_column=100e0
537
+ #
538
+ CREATE TABLE t1 (a DOUBLE(9,2));
539
+ INSERT INTO t1 VALUES (100),(110);
540
+ SELECT * FROM t1 WHERE LENGTH(a)!=6;
541
+ a
542
+ SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
543
+ a
544
+ DROP TABLE t1;
545
+ CREATE TABLE t1 (a DOUBLE);
546
+ INSERT INTO t1 VALUES (100),(110);
547
+ SELECT * FROM t1 WHERE LENGTH(a)!=6;
548
+ a
549
+ 100
550
+ 110
551
+ SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
552
+ a
553
+ 100
554
+ EXPLAIN EXTENDED
555
+ SELECT * FROM t1 WHERE LENGTH(a)!=6 AND a=100e0;
556
+ id select_type table type possible_keys key key_len ref rows filtered Extra
557
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
558
+ Warnings:
559
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = 100e0)
560
+ EXPLAIN EXTENDED
561
+ SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=100e0;
562
+ id select_type table type possible_keys key key_len ref rows filtered Extra
563
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
564
+ Warnings:
565
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 100e0) and (<cache>(length(100)) <> rand()))
566
+ DROP TABLE t1;
567
+ CREATE TABLE t1 (a DOUBLE(10,1));
568
+ INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
569
+ SELECT * FROM t1 WHERE LENGTH(a)!=3;
570
+ a
571
+ SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
572
+ a
573
+ EXPLAIN EXTENDED
574
+ SELECT * FROM t1 WHERE LENGTH(a)!=3 AND a=1.10e0;
575
+ id select_type table type possible_keys key key_len ref rows filtered Extra
576
+ 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
577
+ Warnings:
578
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
579
+ # Notice 1.1 instead of 1.10 in the final WHERE condition
580
+ EXPLAIN EXTENDED
581
+ SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
582
+ id select_type table type possible_keys key key_len ref rows filtered Extra
583
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
584
+ Warnings:
585
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.1)) <> rand()))
586
+ DROP TABLE t1;
587
+ CREATE TABLE t1 (a DOUBLE(10,2));
588
+ INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
589
+ SELECT * FROM t1 WHERE LENGTH(a)!=4;
590
+ a
591
+ SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
592
+ a
593
+ EXPLAIN EXTENDED
594
+ SELECT * FROM t1 WHERE LENGTH(a)!=4 AND a=1.10e0;
595
+ id select_type table type possible_keys key key_len ref rows filtered Extra
596
+ 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
597
+ Warnings:
598
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
599
+ # Notice 1.10 in the final WHERE condition
600
+ EXPLAIN EXTENDED
601
+ SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
602
+ id select_type table type possible_keys key key_len ref rows filtered Extra
603
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
604
+ Warnings:
605
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.10)) <> rand()))
606
+ DROP TABLE t1;
607
+ CREATE TABLE t1 (a DOUBLE(10,3));
608
+ INSERT INTO t1 VALUES (1.1),(1.2),(1.3);
609
+ SELECT * FROM t1 WHERE LENGTH(a)!=5;
610
+ a
611
+ SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
612
+ a
613
+ EXPLAIN EXTENDED
614
+ SELECT * FROM t1 WHERE LENGTH(a)!=5 AND a=1.10e0;
615
+ id select_type table type possible_keys key key_len ref rows filtered Extra
616
+ 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
617
+ Warnings:
618
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 0
619
+ # Notice 1.100 rather than 1.10 in the final WHERE condition
620
+ EXPLAIN EXTENDED
621
+ SELECT * FROM t1 WHERE LENGTH(a)!=RAND() AND a=1.10e0;
622
+ id select_type table type possible_keys key key_len ref rows filtered Extra
623
+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
624
+ Warnings:
625
+ Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 1.10e0) and (<cache>(length(1.100)) <> rand()))
626
+ DROP TABLE t1;
627
+ #
628
+ # End of 10.1 tests
629
+ #
0 commit comments