Skip to content

Commit 23d03a1

Browse files
committed
parse negative numbers into one item
use Item->neg to convert generate negative Item_num's instead of Item_func_neg(Item_num). Based on the following commit: Author: Monty <monty@mariadb.org> Date: Mon May 30 22:44:00 2016 +0300 Make negative number their own token The negation (-) operator will call Item->neg() one underlying numeric constants and remove itself (like the NOT() function does today for other NOT functions. This simplifies things - -1 is not anymore an expression but a basic_const_item - improves optimizer - DEFAULT -1 doesn't need special handling anymore - When we add DEFAULT expressions, -1 will be treated exactly like 1 - printing of items doesn't anymore put braces around all negative numbers Other things fixed: - Fixed that longlong converted to decimal's has a more appropriate size - Fixed that "-0.0" read into a decimal is interpreted as 0.0
1 parent 60916a8 commit 23d03a1

22 files changed

+157
-93
lines changed

mysql-test/r/bigint.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ drop table t1;
402402
create table t1 select -9223372036854775809 bi;
403403
describe t1;
404404
Field Type Null Key Default Extra
405-
bi decimal(19,0) NO NULL
405+
bi decimal(20,0) NO NULL
406406
drop table t1;
407407
#
408408
# Bug #45360: wrong results

mysql-test/r/errors.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),''));
142142
ERROR 22003: DOUBLE value is out of range in 'cot('v')'
143143
SET NAMES utf8 COLLATE utf8_latvian_ci ;
144144
SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
145-
ERROR 22003: BIGINT value is out of range in '(-(73) * -(2465717823867977728))'
145+
ERROR 22003: BIGINT value is out of range in '(-73 * -2465717823867977728)'
146146
#
147147
# End Bug#57882
148148
#

mysql-test/r/func_math.result

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ explain extended select floor(5.5),floor(-5.5);
66
id select_type table type possible_keys key key_len ref rows filtered Extra
77
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
88
Warnings:
9-
Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
9+
Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-5.5) AS `floor(-5.5)`
1010
select ceiling(5.5),ceiling(-5.5);
1111
ceiling(5.5) ceiling(-5.5)
1212
6 -5
1313
explain extended select ceiling(5.5),ceiling(-5.5);
1414
id select_type table type possible_keys key key_len ref rows filtered Extra
1515
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
1616
Warnings:
17-
Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
17+
Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-5.5) AS `ceiling(-5.5)`
1818
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
1919
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
2020
52.6 52.64 50 0 -52.6 -50
2121
explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
2222
id select_type table type possible_keys key key_len ref rows filtered Extra
2323
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
2424
Warnings:
25-
Note 1003 select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)`
25+
Note 1003 select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-1) AS `truncate(52.64,-1)`,truncate(52.64,-2) AS `truncate(52.64,-2)`,truncate(-52.64,1) AS `truncate(-52.64,1)`,truncate(-52.64,-1) AS `truncate(-52.64,-1)`
2626
select round(5.5),round(-5.5);
2727
round(5.5) round(-5.5)
2828
6 -6
2929
explain extended select round(5.5),round(-5.5);
3030
id select_type table type possible_keys key key_len ref rows filtered Extra
3131
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3232
Warnings:
33-
Note 1003 select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
33+
Note 1003 select round(5.5,0) AS `round(5.5)`,round(-5.5,0) AS `round(-5.5)`
3434
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
3535
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
3636
5.6 5.64 10 0
@@ -41,39 +41,39 @@ explain extended select abs(-10), sign(-5), sign(5), sign(0);
4141
id select_type table type possible_keys key key_len ref rows filtered Extra
4242
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
4343
Warnings:
44-
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
44+
Note 1003 select abs(-10) AS `abs(-10)`,sign(-5) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
4545
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
4646
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
4747
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
4848
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
4949
id select_type table type possible_keys key key_len ref rows filtered Extra
5050
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
5151
Warnings:
52-
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
52+
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-1) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-1,2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
5353
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
5454
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
5555
10 10.000000000000002 NULL NULL NULL
5656
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
5757
id select_type table type possible_keys key key_len ref rows filtered Extra
5858
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
5959
Warnings:
60-
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
60+
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-1) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
6161
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
6262
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
6363
3 3.9068905956085187 NULL NULL NULL
6464
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
6565
id select_type table type possible_keys key key_len ref rows filtered Extra
6666
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
6767
Warnings:
68-
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
68+
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-2) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
6969
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
7070
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
7171
2 1.255272505103306 NULL NULL NULL
7272
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
7373
id select_type table type possible_keys key key_len ref rows filtered Extra
7474
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
7575
Warnings:
76-
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
76+
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-4) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
7777
select pow(10,log10(10)),power(2,4);
7878
pow(10,log10(10)) power(2,4)
7979
10 16
@@ -488,7 +488,7 @@ End of 5.0 tests
488488
SELECT 1e308 + 1e308;
489489
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
490490
SELECT -1e308 - 1e308;
491-
ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
491+
ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
492492
SELECT 1e300 * 1e300;
493493
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
494494
SELECT 1e300 / 1e-300;
@@ -519,9 +519,9 @@ DROP TABLE t1;
519519
# Bug#57477 SIGFPE when dividing a huge number a negative number
520520
#
521521
SELECT -9999999999999999991 DIV -1;
522-
ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))'
522+
ERROR 22003: BIGINT value is out of range in '(-9999999999999999991 DIV -1)'
523523
SELECT -9223372036854775808 DIV -1;
524-
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
524+
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
525525
SELECT -9223372036854775808 MOD -1;
526526
-9223372036854775808 MOD -1
527527
0
@@ -591,7 +591,7 @@ End of 5.1 tests
591591
SELECT 1e308 + 1e308;
592592
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
593593
SELECT -1e308 - 1e308;
594-
ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
594+
ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
595595
SELECT 1e300 * 1e300;
596596
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
597597
SELECT 1e300 / 1e-300;
@@ -611,11 +611,11 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1
611611
SELECT 1 + 18446744073709551615;
612612
ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)'
613613
SELECT -2 + CAST(1 AS UNSIGNED);
614-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(2) + cast(1 as unsigned))'
614+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-2 + cast(1 as unsigned))'
615615
SELECT CAST(1 AS UNSIGNED) + -2;
616-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -(2))'
616+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -2)'
617617
SELECT -9223372036854775808 + -9223372036854775808;
618-
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) + -(9223372036854775808))'
618+
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 + -9223372036854775808)'
619619
SELECT 9223372036854775807 + 9223372036854775807;
620620
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)'
621621
SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
@@ -625,24 +625,24 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 92
625625
SELECT CAST(1 AS UNSIGNED) - 2;
626626
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)'
627627
SELECT 18446744073709551615 - (-1);
628-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -(1))'
628+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -1)'
629629
SELECT -1 - 9223372036854775808;
630-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - 9223372036854775808)'
630+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - 9223372036854775808)'
631631
SELECT -1 - CAST(1 AS UNSIGNED);
632-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - cast(1 as unsigned))'
632+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - cast(1 as unsigned))'
633633
SELECT -9223372036854775808 - 1;
634-
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) - 1)'
634+
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 - 1)'
635635
SELECT 9223372036854775807 - -9223372036854775808;
636-
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(9223372036854775808))'
636+
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -9223372036854775808)'
637637
set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
638638
SELECT 18446744073709551615 - 1;
639639
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)'
640640
SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
641641
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))'
642642
SELECT 18446744073709551614 - (-1);
643-
ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -(1))'
643+
ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -1)'
644644
SELECT 9223372036854775807 - -1;
645-
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(1))'
645+
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -1)'
646646
set SQL_MODE=default;
647647
SELECT 4294967296 * 4294967296;
648648
ERROR 22003: BIGINT value is out of range in '(4294967296 * 4294967296)'
@@ -653,17 +653,17 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)
653653
SELECT 7158278827 * 3221225472;
654654
ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)'
655655
SELECT 9223372036854775807 * (-2);
656-
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -(2))'
656+
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -2)'
657657
SELECT CAST(1 as UNSIGNED) * (-1);
658-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -(1))'
658+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -1)'
659659
SELECT 9223372036854775807 * 2;
660660
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)'
661661
SELECT ABS(-9223372036854775808);
662-
ERROR 22003: BIGINT value is out of range in 'abs(-(9223372036854775808))'
662+
ERROR 22003: BIGINT value is out of range in 'abs(-9223372036854775808)'
663663
SELECT -9223372036854775808 DIV -1;
664-
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
664+
ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
665665
SELECT 18446744073709551615 DIV -1;
666-
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -(1))'
666+
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -1)'
667667
CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
668668
INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
669669
SELECT -a FROM t1;
@@ -794,5 +794,9 @@ SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table;
794794
STDDEV_POP(ROUND(0,@A:=2009))
795795
0.0000
796796
#
797-
# End of 10.0 tests
797+
# Start of 10.2 tests
798798
#
799+
# Test zero
800+
select 0=0, 0=-0, 0.0= -0.0, 0.0 = -(0.0), 0.0E1=-0.0E1, 0.0E1=-(0.0E1);
801+
0=0 0=-0 0.0= -0.0 0.0 = -(0.0) 0.0E1=-0.0E1 0.0E1=-(0.0E1)
802+
1 1 1 1 1 1

mysql-test/r/func_op.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
55
id select_type table type possible_keys key key_len ref rows filtered Extra
66
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
77
Warnings:
8-
Note 1003 select (1 + 1) AS `1+1`,(1 - 1) AS `1-1`,(1 + (1 * 2)) AS `1+1*2`,(8 / 5) AS `8/5`,(8 % 5) AS `8%5`,(8 % 5) AS `mod(8,5)`,((8 % 5) | 0) AS `mod(8,5)|0`,(-((1 + 1)) * -(2)) AS `-(1+1)*-2`
8+
Note 1003 select (1 + 1) AS `1+1`,(1 - 1) AS `1-1`,(1 + (1 * 2)) AS `1+1*2`,(8 / 5) AS `8/5`,(8 % 5) AS `8%5`,(8 % 5) AS `mod(8,5)`,((8 % 5) | 0) AS `mod(8,5)|0`,(-((1 + 1)) * -2) AS `-(1+1)*-2`
99
select 1 | (1+1),5 & 3,bit_count(7) ;
1010
1 | (1+1) 5 & 3 bit_count(7)
1111
3 1 3

mysql-test/r/func_time.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_d
874874
id select_type table type possible_keys key key_len ref rows filtered Extra
875875
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
876876
Warnings:
877-
Note 1003 select period_add('9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,'9404') AS `period_diff(199505,"9404")`,from_days(to_days('960101')) AS `from_days(to_days("960101"))`,dayofmonth('1997-01-02') AS `dayofmonth("1997-01-02")`,month('1997-01-02') AS `month("1997-01-02")`,monthname('1972-03-04') AS `monthname("1972-03-04")`,dayofyear('0000-00-00') AS `dayofyear("0000-00-00")`,hour('1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute('23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week('1998-03-03',@@default_week_format) AS `WEEK("1998-03-03")`,yearweek('2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year('98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec('0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format('1997-01-02 03:04:05','%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp('1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,('1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,('1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,('1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from '1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,('1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
877+
Note 1003 select period_add('9602',-12) AS `period_add("9602",-12)`,period_diff(199505,'9404') AS `period_diff(199505,"9404")`,from_days(to_days('960101')) AS `from_days(to_days("960101"))`,dayofmonth('1997-01-02') AS `dayofmonth("1997-01-02")`,month('1997-01-02') AS `month("1997-01-02")`,monthname('1972-03-04') AS `monthname("1972-03-04")`,dayofyear('0000-00-00') AS `dayofyear("0000-00-00")`,hour('1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute('23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week('1998-03-03',@@default_week_format) AS `WEEK("1998-03-03")`,yearweek('2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year('98-02-03') AS `year("98-02-03")`,(weekday(curdate()) - weekday(now())) AS `weekday(curdate())-weekday(now())`,dayname('1962-03-03') AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec('0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format('1997-01-02 03:04:05','%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp('1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,('1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,('1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,('1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from '1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,('1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
878878
SET @TMP='2007-08-01 12:22:49';
879879
CREATE TABLE t1 (d DATETIME);
880880
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');

mysql-test/r/selectivity_no_engine.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ explain extended select * from t1 where a=-1;
8383
id select_type table type possible_keys key key_len ref rows filtered Extra
8484
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 9.52 Using where
8585
Warnings:
86-
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = <cache>(-(1)))
86+
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = -1)
8787
drop table t0, t1;
8888
#
8989
# MDEV-4362: Selectivity estimates for IN (...) do not depend on whether the values are in range
@@ -110,12 +110,12 @@ explain extended select * from t1 where col1 in (-1,-2,-3);
110110
id select_type table type possible_keys key key_len ref rows filtered Extra
111111
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 5.94 Using where
112112
Warnings:
113-
Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (<cache>(-(1)),<cache>(-(2)),<cache>(-(3))))
113+
Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (-1,-2,-3))
114114
explain extended select * from t1 where col1<=-1;
115115
id select_type table type possible_keys key key_len ref rows filtered Extra
116116
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 1.00 Using where
117117
Warnings:
118-
Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= <cache>(-(1)))
118+
Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= -1)
119119
drop table t1, t2;
120120
#
121121
# MDEV-5984: EITS: Incorrect filtered% value for single-table select with range access

0 commit comments

Comments
 (0)