summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/bigint.result2
-rw-r--r--mysql-test/r/errors.result2
-rw-r--r--mysql-test/r/func_math.result62
-rw-r--r--mysql-test/r/func_op.result2
-rw-r--r--mysql-test/r/func_time.result2
-rw-r--r--mysql-test/r/selectivity_no_engine.result6
-rw-r--r--mysql-test/r/type_blob.result22
-rw-r--r--mysql-test/r/type_newdecimal.result2
-rw-r--r--mysql-test/r/view.result6
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_innodb.result4
-rw-r--r--mysql-test/suite/vcol/r/vcol_select_myisam.result2
-rw-r--r--mysql-test/t/func_math.test6
-rw-r--r--mysql-test/t/type_blob.test12
-rw-r--r--sql/field.cc12
-rw-r--r--sql/item.cc59
-rw-r--r--sql/item.h16
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/replace-ignore.result8
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/type_blob.result10
-rw-r--r--storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result2
-rw-r--r--storage/tokudb/mysql-test/tokudb/t/type_blob.test8
-rw-r--r--strings/decimal.c3
22 files changed, 157 insertions, 93 deletions
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index cc2ab456833..9810c2ea72b 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -402,7 +402,7 @@ drop table t1;
create table t1 select -9223372036854775809 bi;
describe t1;
Field Type Null Key Default Extra
-bi decimal(19,0) NO NULL
+bi decimal(20,0) NO NULL
drop table t1;
#
# Bug #45360: wrong results
diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result
index 23c77d3978c..3f5ad20fe6e 100644
--- a/mysql-test/r/errors.result
+++ b/mysql-test/r/errors.result
@@ -142,7 +142,7 @@ SELECT (CONVERT('0' USING latin1) IN (CHAR(COT('v') USING utf8),''));
ERROR 22003: DOUBLE value is out of range in 'cot('v')'
SET NAMES utf8 COLLATE utf8_latvian_ci ;
SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
-ERROR 22003: BIGINT value is out of range in '(-(73) * -(2465717823867977728))'
+ERROR 22003: BIGINT value is out of range in '(-73 * -2465717823867977728)'
#
# End Bug#57882
#
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index 6842613e8c7..2a646cbcb8d 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -6,7 +6,7 @@ explain extended select floor(5.5),floor(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
+Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-5.5) AS `floor(-5.5)`
select ceiling(5.5),ceiling(-5.5);
ceiling(5.5) ceiling(-5.5)
6 -5
@@ -14,7 +14,7 @@ explain extended select ceiling(5.5),ceiling(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
+Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-5.5) AS `ceiling(-5.5)`
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);
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
52.6 52.64 50 0 -52.6 -50
@@ -22,7 +22,7 @@ explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),t
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
select round(5.5),round(-5.5);
round(5.5) round(-5.5)
6 -6
@@ -30,7 +30,7 @@ explain extended select round(5.5),round(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
+Note 1003 select round(5.5,0) AS `round(5.5)`,round(-5.5,0) AS `round(-5.5)`
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
5.6 5.64 10 0
@@ -41,7 +41,7 @@ explain extended select abs(-10), sign(-5), sign(5), sign(0);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
+Note 1003 select abs(-10) AS `abs(-10)`,sign(-5) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
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);
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
@@ -49,7 +49,7 @@ explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
10 10.000000000000002 NULL NULL NULL
@@ -57,7 +57,7 @@ explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3 3.9068905956085187 NULL NULL NULL
@@ -65,7 +65,7 @@ explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2 1.255272505103306 NULL NULL NULL
@@ -73,7 +73,7 @@ explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
select pow(10,log10(10)),power(2,4);
pow(10,log10(10)) power(2,4)
10 16
@@ -488,7 +488,7 @@ End of 5.0 tests
SELECT 1e308 + 1e308;
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
SELECT -1e308 - 1e308;
-ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
+ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
SELECT 1e300 * 1e300;
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
SELECT 1e300 / 1e-300;
@@ -519,9 +519,9 @@ DROP TABLE t1;
# Bug#57477 SIGFPE when dividing a huge number a negative number
#
SELECT -9999999999999999991 DIV -1;
-ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))'
+ERROR 22003: BIGINT value is out of range in '(-9999999999999999991 DIV -1)'
SELECT -9223372036854775808 DIV -1;
-ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
+ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
SELECT -9223372036854775808 MOD -1;
-9223372036854775808 MOD -1
0
@@ -591,7 +591,7 @@ End of 5.1 tests
SELECT 1e308 + 1e308;
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
SELECT -1e308 - 1e308;
-ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
+ERROR 22003: DOUBLE value is out of range in '(-1e308 - 1e308)'
SELECT 1e300 * 1e300;
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
SELECT 1e300 / 1e-300;
@@ -611,11 +611,11 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1
SELECT 1 + 18446744073709551615;
ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)'
SELECT -2 + CAST(1 AS UNSIGNED);
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(2) + cast(1 as unsigned))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(-2 + cast(1 as unsigned))'
SELECT CAST(1 AS UNSIGNED) + -2;
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -(2))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -2)'
SELECT -9223372036854775808 + -9223372036854775808;
-ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) + -(9223372036854775808))'
+ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 + -9223372036854775808)'
SELECT 9223372036854775807 + 9223372036854775807;
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)'
SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
@@ -625,24 +625,24 @@ ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 92
SELECT CAST(1 AS UNSIGNED) - 2;
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)'
SELECT 18446744073709551615 - (-1);
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -(1))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -1)'
SELECT -1 - 9223372036854775808;
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - 9223372036854775808)'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - 9223372036854775808)'
SELECT -1 - CAST(1 AS UNSIGNED);
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - cast(1 as unsigned))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(-1 - cast(1 as unsigned))'
SELECT -9223372036854775808 - 1;
-ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) - 1)'
+ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 - 1)'
SELECT 9223372036854775807 - -9223372036854775808;
-ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(9223372036854775808))'
+ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -9223372036854775808)'
set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
SELECT 18446744073709551615 - 1;
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)'
SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))'
SELECT 18446744073709551614 - (-1);
-ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -(1))'
+ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -1)'
SELECT 9223372036854775807 - -1;
-ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(1))'
+ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -1)'
set SQL_MODE=default;
SELECT 4294967296 * 4294967296;
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)
SELECT 7158278827 * 3221225472;
ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)'
SELECT 9223372036854775807 * (-2);
-ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -(2))'
+ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -2)'
SELECT CAST(1 as UNSIGNED) * (-1);
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -(1))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -1)'
SELECT 9223372036854775807 * 2;
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)'
SELECT ABS(-9223372036854775808);
-ERROR 22003: BIGINT value is out of range in 'abs(-(9223372036854775808))'
+ERROR 22003: BIGINT value is out of range in 'abs(-9223372036854775808)'
SELECT -9223372036854775808 DIV -1;
-ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
+ERROR 22003: BIGINT value is out of range in '(-9223372036854775808 DIV -1)'
SELECT 18446744073709551615 DIV -1;
-ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -(1))'
+ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -1)'
CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
SELECT -a FROM t1;
@@ -794,5 +794,9 @@ SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table;
STDDEV_POP(ROUND(0,@A:=2009))
0.0000
#
-# End of 10.0 tests
+# Start of 10.2 tests
#
+# Test zero
+select 0=0, 0=-0, 0.0= -0.0, 0.0 = -(0.0), 0.0E1=-0.0E1, 0.0E1=-(0.0E1);
+0=0 0=-0 0.0= -0.0 0.0 = -(0.0) 0.0E1=-0.0E1 0.0E1=-(0.0E1)
+1 1 1 1 1 1
diff --git a/mysql-test/r/func_op.result b/mysql-test/r/func_op.result
index ce755e86b4c..0d738570035 100644
--- a/mysql-test/r/func_op.result
+++ b/mysql-test/r/func_op.result
@@ -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;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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`
+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`
select 1 | (1+1),5 & 3,bit_count(7) ;
1 | (1+1) 5 & 3 bit_count(7)
3 1 3
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index ad51010de30..9a9ab76883e 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -874,7 +874,7 @@ explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_d
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-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)`
+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)`
SET @TMP='2007-08-01 12:22:49';
CREATE TABLE t1 (d DATETIME);
INSERT INTO t1 VALUES ('2007-08-01 12:22:59');
diff --git a/mysql-test/r/selectivity_no_engine.result b/mysql-test/r/selectivity_no_engine.result
index 31037e90a84..da210b09c23 100644
--- a/mysql-test/r/selectivity_no_engine.result
+++ b/mysql-test/r/selectivity_no_engine.result
@@ -83,7 +83,7 @@ explain extended select * from t1 where a=-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 9.52 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = <cache>(-(1)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` = -1)
drop table t0, t1;
#
# 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);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 5.94 Using where
Warnings:
-Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (<cache>(-(1)),<cache>(-(2)),<cache>(-(3))))
+Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` in (-1,-2,-3))
explain extended select * from t1 where col1<=-1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 1.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= <cache>(-(1)))
+Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where (`test`.`t1`.`col1` <= -1)
drop table t1, t2;
#
# MDEV-5984: EITS: Incorrect filtered% value for single-table select with range access
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index 883f12194c7..ec33f8ba203 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -878,7 +878,7 @@ ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT
CREATE TABLE b15776 (a char(4294967295));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(4294967296));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a year(4294967295));
Warnings:
Note 1287 'YEAR(4294967295)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
@@ -888,7 +888,12 @@ a
2042
DROP TABLE b15776;
CREATE TABLE b15776 (a year(4294967296));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+SHOW CREATE TABLE b15776;
+Table Create Table
+b15776 CREATE TABLE `b15776` (
+ `a` year(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE b15776;
CREATE TABLE b15776 (a year(0));
Warnings:
Note 1287 'YEAR(0)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
@@ -900,17 +905,22 @@ ERROR 42000: Too big precision 4294967294 specified for 'a'. Maximum is 6.
CREATE TABLE b15776 (a timestamp(4294967295));
ERROR 42000: Too big precision 4294967295 specified for 'a'. Maximum is 6.
CREATE TABLE b15776 (a timestamp(4294967296));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Too big precision 4294967296 specified for 'a'. Maximum is 6.
CREATE TABLE b15776 (a timestamp(-1));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-1))' at line 1
CREATE TABLE b15776 (a timestamp(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 255)
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+SHOW CREATE TABLE b15776;
+Table Create Table
+b15776 CREATE TABLE `b15776` (
+ `a` year(4) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE b15776;
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 5221973702d..4b09b269d2f 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -176,7 +176,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(3,0) NOT NULL,
`truncate(-5678.123451,-3)` decimal(4,0) NOT NULL,
- `abs(-1.1)` decimal(3,1) NOT NULL,
+ `abs(-1.1)` decimal(2,1) NOT NULL,
`-(-1.1)` decimal(2,1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 1bcad9471fb..5b21ba57619 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -4404,7 +4404,7 @@ SELECT * FROM v1 WHERE a > -1 OR a > 6 AND a = 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(-(1)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > -1)
SELECT * FROM v1 WHERE a > -1 OR a AND a = 0;
a
2
@@ -4419,7 +4419,7 @@ SELECT * FROM v1 WHERE a > -1 OR a AND a = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(-(1)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > -1)
CREATE VIEW v2 AS SELECT * FROM v1;
SELECT * FROM v2 WHERE a > -1 OR a AND a = 0;
a
@@ -4435,7 +4435,7 @@ SELECT * FROM v2 WHERE a > -1 OR a AND a = 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > <cache>(-(1)))
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` > -1)
DROP VIEW v1,v2;
DROP TABLE t1;
CREATE TABLE t1 (a varchar(10), KEY (a)) ;
diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result
index 97bfbbe4eaf..63c35bade07 100644
--- a/mysql-test/suite/vcol/r/vcol_select_innodb.result
+++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result
@@ -22,7 +22,7 @@ a b c
1 -1 -1
explain select * from t2 where c=-1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref c c 5 const 1 Using index condition
+1 SIMPLE t2 ref c c 5 const 1
# select_type=SIMPLE, type=ALL
select * from t1 where b=-1;
a b c
@@ -53,7 +53,7 @@ a b c a b c
explain select * from t1,t3 where t1.c=t3.c and t3.c=-1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 const c c 5 const 1
-1 SIMPLE t1 ref c c 5 const 2 Using index condition
+1 SIMPLE t1 ref c c 5 const 2
# select_type=PRIMARY, type=index,ALL
select * from t1 where b in (select c from t3);
a b c
diff --git a/mysql-test/suite/vcol/r/vcol_select_myisam.result b/mysql-test/suite/vcol/r/vcol_select_myisam.result
index 934d047f6bf..d6d01150e0b 100644
--- a/mysql-test/suite/vcol/r/vcol_select_myisam.result
+++ b/mysql-test/suite/vcol/r/vcol_select_myisam.result
@@ -53,7 +53,7 @@ a b c a b c
explain select * from t1,t3 where t1.c=t3.c and t3.c=-1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 const c c 5 const 1
-1 SIMPLE t1 ref c c 5 const 2 Using index condition
+1 SIMPLE t1 ref c c 5 const 2
# select_type=PRIMARY, type=index,ALL
select * from t1 where b in (select c from t3);
a b c
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index b48f4599074..058c6f3b7ca 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -586,5 +586,9 @@ SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table;
--echo #
---echo # End of 10.0 tests
+--echo # Start of 10.2 tests
--echo #
+
+--echo # Test zero
+select 0=0, 0=-0, 0.0= -0.0, 0.0 = -(0.0), 0.0E1=-0.0E1, 0.0E1=-(0.0E1);
+
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index a20173e231a..8a6e63bb49b 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -515,7 +515,7 @@ CREATE TABLE b15776 (a char(2147483648));
--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(4294967295));
# Even BLOB won't hold
---error ER_TOO_BIG_DISPLAYWIDTH
+--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(4294967296));
@@ -527,8 +527,9 @@ CREATE TABLE b15776 (a year(4294967295));
INSERT INTO b15776 VALUES (42);
SELECT * FROM b15776;
DROP TABLE b15776;
---error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(4294967296));
+SHOW CREATE TABLE b15776;
+DROP TABLE b15776;
CREATE TABLE b15776 (a year(0)); # 0 is special case, means default size
DROP TABLE b15776;
--error ER_PARSE_ERROR
@@ -539,7 +540,7 @@ CREATE TABLE b15776 (a year(-2));
CREATE TABLE b15776 (a timestamp(4294967294));
--error ER_TOO_BIG_PRECISION
CREATE TABLE b15776 (a timestamp(4294967295));
---error ER_TOO_BIG_DISPLAYWIDTH
+--error ER_TOO_BIG_PRECISION
CREATE TABLE b15776 (a timestamp(4294967296));
--error ER_PARSE_ERROR
CREATE TABLE b15776 (a timestamp(-1));
@@ -550,10 +551,11 @@ CREATE TABLE b15776 (a timestamp(-2));
# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
+--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
+SHOW CREATE TABLE b15776;
+DROP TABLE b15776;
## Do not select, too much memory needed.
CREATE TABLE b15776 select cast(null as char(4294967295));
diff --git a/sql/field.cc b/sql/field.cc
index 0e2bc724db0..f15e9979ff2 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -9769,12 +9769,6 @@ bool Column_definition::check(THD *thd)
}
}
- if (length > MAX_FIELD_BLOBLENGTH)
- {
- my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, MAX_FIELD_BLOBLENGTH);
- DBUG_RETURN(TRUE);
- }
-
if (def)
{
/*
@@ -10080,6 +10074,12 @@ bool Column_definition::check(THD *thd)
field_name, max_field_charlength); /* purecov: inspected */
DBUG_RETURN(TRUE);
}
+ else if (length > MAX_FIELD_BLOBLENGTH)
+ {
+ my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, MAX_FIELD_BLOBLENGTH);
+ DBUG_RETURN(1);
+ }
+
if ((~allowed_type_modifier) & flags & conditional_type_modifiers)
{
my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name);
diff --git a/sql/item.cc b/sql/item.cc
index 6566f3ca533..05d4cc86f7a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -5998,9 +5998,64 @@ Item *Item_int_with_ref::clone_item(THD *thd)
}
-Item_num *Item_uint::neg(THD *thd)
+Item *Item::neg(THD *thd)
{
- Item_decimal *item= new (thd->mem_root) Item_decimal(thd, value, 1);
+ return new (thd->mem_root) Item_func_neg(thd, this);
+}
+
+Item *Item_int::neg(THD *thd)
+{
+ /*
+ The following if should never be true with code generated by
+ our parser as LONGLONG_MIN values will be stored as decimal.
+ The code is here in case someone generates an int from inside
+ MariaDB
+ */
+ if (unlikely(value == LONGLONG_MIN))
+ {
+ /* Precision for int not big enough; Convert constant to decimal */
+ Item_decimal *item= new (thd->mem_root) Item_decimal(thd, value, 0);
+ return item ? item->neg(thd) : item;
+ }
+ if (value > 0)
+ max_length++;
+ else if (value < 0 && max_length)
+ max_length--;
+ value= -value;
+ name= 0;
+ return this;
+}
+
+Item *Item_decimal::neg(THD *thd)
+{
+ my_decimal_neg(&decimal_value);
+ unsigned_flag= 0;
+ name= 0;
+ max_length= my_decimal_precision_to_length_no_truncation(
+ decimal_value.intg + decimals, decimals, unsigned_flag);
+ return this;
+}
+
+Item *Item_float::neg(THD *thd)
+{
+ if (value > 0)
+ max_length++;
+ else if (value < 0 && max_length)
+ max_length--;
+ value= -value;
+ name= presentation= 0 ;
+ return this;
+}
+
+Item *Item_uint::neg(THD *thd)
+{
+ Item_decimal *item;
+ if (((ulonglong)value) <= LONGLONG_MAX)
+ return new (thd->mem_root) Item_int(thd, -value, max_length+1);
+ if (value == LONGLONG_MIN)
+ return new (thd->mem_root) Item_int(thd, value, max_length+1);
+ if (!(item= new (thd->mem_root) Item_decimal(thd, value, 1)))
+ return 0;
return item->neg(thd);
}
diff --git a/sql/item.h b/sql/item.h
index 67d683b15ff..22e44719706 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1846,6 +1846,8 @@ public:
/* how much position should be reserved for Exists2In transformation */
virtual uint exists2in_reserved_items() { return 0; };
+ virtual Item *neg(THD *thd);
+
/**
Inform the item that it is located under a NOT, which is a top-level item.
*/
@@ -2261,7 +2263,6 @@ class Item_num: public Item_basic_constant
{
public:
Item_num(THD *thd): Item_basic_constant(thd) { collation.set_numeric(); }
- virtual Item_num *neg(THD *thd)= 0;
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs);
bool check_partition_func_processor(uchar *int_arg) { return FALSE;}
bool check_vcol_func_processor(uchar *arg) { return FALSE;}
@@ -2834,7 +2835,7 @@ public:
bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
- Item_num *neg(THD *thd) { value= -value; return this; }
+ Item *neg(THD *thd);
uint decimal_precision() const
{ return (uint) (max_length - MY_TEST(value < 0)); }
bool eq(const Item *item, bool binary_cmp) const
@@ -2855,7 +2856,7 @@ public:
String *val_str(String*);
Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
- Item_num *neg(THD *thd);
+ Item *neg(THD *thd);
uint decimal_precision() const { return max_length; }
};
@@ -2899,12 +2900,7 @@ public:
bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd);
virtual void print(String *str, enum_query_type query_type);
- Item_num *neg(THD *thd)
- {
- my_decimal_neg(&decimal_value);
- unsigned_flag= !decimal_value.sign();
- return this;
- }
+ Item *neg(THD *thd);
uint decimal_precision() const { return decimal_value.precision(); }
bool eq(const Item *, bool binary_cmp) const;
void set_decimal_value(my_decimal *value_par);
@@ -2954,7 +2950,7 @@ public:
my_decimal *val_decimal(my_decimal *);
bool basic_const_item() const { return 1; }
Item *clone_item(THD *thd);
- Item_num *neg(THD *thd) { value= -value; return this; }
+ Item *neg(THD *thd);
virtual void print(String *str, enum_query_type query_type);
bool eq(const Item *item, bool binary_cmp) const
{ return real_eq(value, item); }
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 7ab11716f93..c971373d31b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9461,7 +9461,7 @@ simple_expr:
}
| '-' simple_expr %prec NEG
{
- $$= new (thd->mem_root) Item_func_neg(thd, $2);
+ $$= $2->neg(thd);
if ($$ == NULL)
MYSQL_YYABORT;
}
diff --git a/storage/tokudb/mysql-test/tokudb/r/replace-ignore.result b/storage/tokudb/mysql-test/tokudb/r/replace-ignore.result
index 247c23f9788..e6f19fc2ead 100644
--- a/storage/tokudb/mysql-test/tokudb/r/replace-ignore.result
+++ b/storage/tokudb/mysql-test/tokudb/r/replace-ignore.result
@@ -185,7 +185,7 @@ a b c
8 8 80
explain select * from t where c = -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t ref c c 5 const 1 Using where; Using index
+1 SIMPLE t ref c c 5 const 1 Using index
select * from t where c = -1;
a b c
insert ignore t values (15, 15, -1);
@@ -211,7 +211,7 @@ a b c
15 15 150
explain select * from t where c = -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t ref c c 5 const 1 Using where; Using index
+1 SIMPLE t ref c c 5 const 1 Using index
select * from t where c = -1;
a b c
drop table t;
@@ -399,7 +399,7 @@ select * from t where c = 80;
a b c
explain select * from t where c = -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t ref c c 5 const 1 Using where; Using index
+1 SIMPLE t ref c c 5 const 1 Using index
select * from t where c = -1;
a b c
8 8 -1
@@ -423,7 +423,7 @@ select * from t where c = 150;
a b c
explain select * from t where c = -1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t ref c c 5 const 2 Using where; Using index
+1 SIMPLE t ref c c 5 const 2 Using index
select * from t where c = -1;
a b c
8 8 -1
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_blob.result b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
index fcd086cc50d..4a3b7206a62 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_blob.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
@@ -861,7 +861,7 @@ ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT
CREATE TABLE b15776 (a char(4294967295));
ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a char(4294967296));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 (a year(4294967295));
Warnings:
Note 1287 'YEAR(4294967295)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
@@ -870,8 +870,6 @@ SELECT * FROM b15776;
a
2042
DROP TABLE b15776;
-CREATE TABLE b15776 (a year(4294967296));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
CREATE TABLE b15776 (a year(0));
Warnings:
Note 1287 'YEAR(0)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
@@ -879,11 +877,9 @@ DROP TABLE b15776;
CREATE TABLE b15776 (a year(-2));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-2))' at line 1
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Display width out of range for 'a' (max = 255)
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
-CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
-ERROR 42000: Display width out of range for 'a' (max = 4294967295)
+ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead
CREATE TABLE b15776 select cast(null as char(4294967295));
show columns from b15776;
Field Type Null Key Default Extra
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result b/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result
index 5727b339eb8..1d42fc5bb0b 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_newdecimal.result
@@ -177,7 +177,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`round(15.4,-1)` decimal(3,0) NOT NULL,
`truncate(-5678.123451,-3)` decimal(4,0) NOT NULL,
- `abs(-1.1)` decimal(3,1) NOT NULL,
+ `abs(-1.1)` decimal(2,1) NOT NULL,
`-(-1.1)` decimal(2,1) NOT NULL
) ENGINE=ENGINE DEFAULT CHARSET=latin1
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/t/type_blob.test b/storage/tokudb/mysql-test/tokudb/t/type_blob.test
index 4ea452ab732..c1055adbe7a 100644
--- a/storage/tokudb/mysql-test/tokudb/t/type_blob.test
+++ b/storage/tokudb/mysql-test/tokudb/t/type_blob.test
@@ -522,7 +522,7 @@ CREATE TABLE b15776 (a char(2147483648));
--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(4294967295));
# Even BLOB won't hold
---error ER_TOO_BIG_DISPLAYWIDTH
+--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(4294967296));
@@ -534,8 +534,6 @@ CREATE TABLE b15776 (a year(4294967295));
INSERT INTO b15776 VALUES (42);
SELECT * FROM b15776;
DROP TABLE b15776;
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a year(4294967296));
CREATE TABLE b15776 (a year(0)); # 0 is special case, means default size
DROP TABLE b15776;
--error ER_PARSE_ERROR
@@ -546,10 +544,8 @@ CREATE TABLE b15776 (a year(-2));
# widths that are too large to be interpreted cause DISPLAYWIDTH errors.
--error ER_TOO_BIG_DISPLAYWIDTH
CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
+--error ER_TOO_BIG_FIELDLENGTH
CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
---error ER_TOO_BIG_DISPLAYWIDTH
-CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999));
## Do not select, too much memory needed.
CREATE TABLE b15776 select cast(null as char(4294967295));
diff --git a/strings/decimal.c b/strings/decimal.c
index e64f7634a45..5f451d668e3 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1005,7 +1005,8 @@ static int ull2dec(ulonglong from, decimal_t *to)
error=E_DEC_OVERFLOW;
}
to->frac=0;
- to->intg=intg1*DIG_PER_DEC1;
+ /* intg can't be bigger than number of digits in a ulonglong (20) */
+ to->intg= MY_MIN(intg1*DIG_PER_DEC1, 20);
for (buf=to->buf+intg1; intg1; intg1--)
{