diff options
34 files changed, 367 insertions, 175 deletions
diff --git a/mysql-test/main/cast.result b/mysql-test/main/cast.result index 4e518826017..7a443f39863 100644 --- a/mysql-test/main/cast.result +++ b/mysql-test/main/cast.result @@ -390,13 +390,13 @@ ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column select cast(1 as decimal(5,6)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '') select cast(1 as double(66,6)); -ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65 +ERROR 42000: Too big precision specified for '1'. Maximum is 65 select cast(1 as decimal(66,6)); -ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65 +ERROR 42000: Too big precision specified for '1'. Maximum is 65 select cast(1 as decimal(64,63)); -ERROR 42000: Too big scale 63 specified for '1'. Maximum is 38 +ERROR 42000: Too big scale specified for '1'. Maximum is 38 select cast(1 as double(64,63)); -ERROR 42000: Too big scale 63 specified for '1'. Maximum is 38 +ERROR 42000: Too big scale specified for '1'. Maximum is 38 set names binary; select cast(_latin1'test' as char character set latin2); cast(_latin1'test' as char character set latin2) diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result index a57b5248002..4eb2a7994fc 100644 --- a/mysql-test/main/dyncol.result +++ b/mysql-test/main/dyncol.result @@ -1459,7 +1459,7 @@ Note 1105 Cast to signed converted positive out-of-range integer to it's negativ # mysqld # SELECT COLUMN_GET(`x`, 'y' AS DECIMAL(5,50)); -ERROR 42000: Too big scale 50 specified for ''y''. Maximum is 38 +ERROR 42000: Too big scale specified for ''y''. Maximum is 38 # # test of symbolic names # diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index 7bca4158d70..c1cc5dd19e6 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -1983,7 +1983,7 @@ select microsecond('12:00:00.123456'), microsecond('2009-12-31 23:59:59.000010') microsecond('12:00:00.123456') microsecond('2009-12-31 23:59:59.000010') 123456 10 select now(258); -ERROR 42000: Too big precision 258 specified for 'current_timestamp'. Maximum is 6 +ERROR 42000: Too big precision specified for 'current_timestamp'. Maximum is 6 SELECT 1 FROM DUAL WHERE YEAR(TIMEDIFF(NULL, '12:12:12')); 1 SELECT 1 FROM DUAL WHERE MONTH(TIMEDIFF(NULL, '12:12:12')); diff --git a/mysql-test/main/func_time_hires.result b/mysql-test/main/func_time_hires.result index a76571a67b5..725a3f42e55 100644 --- a/mysql-test/main/func_time_hires.result +++ b/mysql-test/main/func_time_hires.result @@ -24,9 +24,9 @@ select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222)); time_to_sec(sec_to_time(11111)) 11111 time_to_sec(sec_to_time(11111.22222)) 11111.22222 select current_timestamp(7); -ERROR 42000: Too big precision 7 specified for 'current_timestamp'. Maximum is 6 +ERROR 42000: Too big precision specified for 'current_timestamp'. Maximum is 6 select curtime(7); -ERROR 42000: Too big precision 7 specified for 'curtime'. Maximum is 6 +ERROR 42000: Too big precision specified for 'curtime'. Maximum is 6 drop table if exists t1; create table t1 select sec_to_time(12345), sec_to_time(12345.6789), sec_to_time(1234567e-2), now(), curtime(0), @@ -161,7 +161,7 @@ select cast(cast(@a as time(2)) as time(6)); cast(cast(@a as time(2)) as time(6)) 12:13:14.120000 select CAST(@a AS DATETIME(7)); -ERROR 42000: Too big precision 7 specified for '@`a`'. Maximum is 6 +ERROR 42000: Too big precision specified for '@`a`'. Maximum is 6 SELECT CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00'); CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00') 2011-01-02 15:00:00 diff --git a/mysql-test/main/type_blob.result b/mysql-test/main/type_blob.result index c2739e4b166..76088319a40 100644 --- a/mysql-test/main/type_blob.result +++ b/mysql-test/main/type_blob.result @@ -908,6 +908,8 @@ a 2042 DROP TABLE b15776; CREATE TABLE b15776 (a year(4294967296)); +Warnings: +Note 1287 'YEAR(4294967295)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE b15776; Table Create Table b15776 CREATE TABLE `b15776` ( @@ -921,11 +923,11 @@ 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 timestamp(4294967294)); -ERROR 42000: Too big precision 4294967294 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 CREATE TABLE b15776 (a timestamp(4294967295)); -ERROR 42000: Too big precision 4294967295 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 CREATE TABLE b15776 (a timestamp(4294967296)); -ERROR 42000: Too big precision 4294967296 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision 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)); @@ -935,6 +937,8 @@ ERROR 42000: Display width out of range for 'a' (max = 255) CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); ERROR 42000: Column length too big for column 'a' (max = 255); use BLOB or TEXT instead CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +Warnings: +Note 1287 'YEAR(4294967295)' is deprecated and will be removed in a future release. Please use YEAR(4) instead SHOW CREATE TABLE b15776; Table Create Table b15776 CREATE TABLE `b15776` ( diff --git a/mysql-test/main/type_blob.test b/mysql-test/main/type_blob.test index c61ed124139..f958a055b6c 100644 --- a/mysql-test/main/type_blob.test +++ b/mysql-test/main/type_blob.test @@ -532,7 +532,9 @@ CREATE TABLE b15776 (a year(4294967295)); INSERT INTO b15776 VALUES (42); SELECT * FROM b15776; DROP TABLE b15776; +--enable_prepare_warnings CREATE TABLE b15776 (a year(4294967296)); +--disable_prepare_warnings SHOW CREATE TABLE b15776; DROP TABLE b15776; --enable_prepare_warnings @@ -560,7 +562,9 @@ CREATE TABLE b15776 (a timestamp(-2)); CREATE TABLE b15776 (a int(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); --error ER_TOO_BIG_FIELDLENGTH CREATE TABLE b15776 (a char(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--enable_prepare_warnings CREATE TABLE b15776 (a year(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)); +--disable_prepare_warnings SHOW CREATE TABLE b15776; DROP TABLE b15776; diff --git a/mysql-test/main/type_datetime_hires.result b/mysql-test/main/type_datetime_hires.result index 02adadd16c5..be85669225e 100644 --- a/mysql-test/main/type_datetime_hires.result +++ b/mysql-test/main/type_datetime_hires.result @@ -1,7 +1,7 @@ SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30'); drop table if exists t1, t2, t3; create table t1 (a datetime(7)); -ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 create table t1 (a datetime(3), key(a)); insert t1 values ('2010-12-11 00:20:03.1234'); insert t1 values ('2010-12-11 15:47:11.1234'); diff --git a/mysql-test/main/type_decimal.result b/mysql-test/main/type_decimal.result index 7bf3b52970a..a053d0e5655 100644 --- a/mysql-test/main/type_decimal.result +++ b/mysql-test/main/type_decimal.result @@ -721,7 +721,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; create table t1 (d decimal(66,0)); -ERROR 42000: Too big precision 66 specified for 'd'. Maximum is 65 +ERROR 42000: Too big precision specified for 'd'. Maximum is 65 CREATE TABLE t1 (i INT, d1 DECIMAL(9,2), d2 DECIMAL(9,2)); INSERT INTO t1 VALUES (1, 101.40, 21.40), (1, -80.00, 0.00), (2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40), diff --git a/mysql-test/main/type_float.result b/mysql-test/main/type_float.result index 5137a8229b6..4791a0ad39b 100644 --- a/mysql-test/main/type_float.result +++ b/mysql-test/main/type_float.result @@ -133,7 +133,7 @@ min(a) -0.010 drop table t1; create table t1 (a float(200,100), b double(200,100)); -ERROR 42000: Too big scale 100 specified for 'a'. Maximum is 30 +ERROR 42000: Too big scale specified for 'a'. Maximum is 30 create table t1 (c20 char); insert ignore into t1 values (5000.0); Warnings: @@ -788,7 +788,7 @@ DROP TABLE t1,t2; # create or replace table t1 (a double(40,30)); create or replace table t1 (a double(40,31)); -ERROR 42000: Too big scale 31 specified for 'a'. Maximum is 30 +ERROR 42000: Too big scale specified for 'a'. Maximum is 30 create or replace table t1 as select 1.01e1; show create table t1; Table Create Table @@ -1162,3 +1162,36 @@ fdec 123.456.789,12345678900000000000000000000000000000 # # End of 10.4 tests # +# +# Start of 10.9 tests +# +# +# MDEV-27712 Reduce the size of Lex_length_and_dec_st from 16 to 8 +# +CREATE TABLE t1 (a DOUBLE(1000,1000)); +ERROR 42000: Too big scale specified for 'a'. Maximum is 30 +CREATE TABLE t1 (a DOUBLE(1000,0)); +ERROR 42000: Display width out of range for 'a' (max = 255) +CREATE TABLE t1 (a DOUBLE(0,1000)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a') +CREATE TABLE t1 (a DOUBLE(2147483647,2147483647)); +ERROR 42000: Too big scale specified for 'a'. Maximum is 30 +CREATE TABLE t1 (a DOUBLE(2147483647,0)); +ERROR 42000: Display width out of range for 'a' (max = 255) +CREATE TABLE t1 (a DOUBLE(0,2147483647)); +ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'a') +CREATE TABLE t1 (a DOUBLE(2147483648,2147483648)); +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 '2147483648,2147483648))' at line 1 +CREATE TABLE t1 (a DOUBLE(2147483648,0)); +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 '2147483648,0))' at line 1 +CREATE TABLE t1 (a DOUBLE(0,2147483648)); +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 '2147483648))' at line 1 +CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,999999999999999999999999999999)); +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 '999999999999999999999999999999,999999999999999999999999999999))' at line 1 +CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,0)); +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 '999999999999999999999999999999,0))' at line 1 +CREATE TABLE t1 (a DOUBLE(0,999999999999999999999999999999)); +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 '999999999999999999999999999999))' at line 1 +# +# End of 10.9 tests +# diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test index a12bf67a426..3870fc7cd5d 100644 --- a/mysql-test/main/type_float.test +++ b/mysql-test/main/type_float.test @@ -703,3 +703,44 @@ DELIMITER ;$$ --echo # --echo # End of 10.4 tests --echo # + + +--echo # +--echo # Start of 10.9 tests +--echo # + +--echo # +--echo # MDEV-27712 Reduce the size of Lex_length_and_dec_st from 16 to 8 +--echo # + +--error ER_TOO_BIG_SCALE +CREATE TABLE t1 (a DOUBLE(1000,1000)); +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a DOUBLE(1000,0)); +--error ER_M_BIGGER_THAN_D +CREATE TABLE t1 (a DOUBLE(0,1000)); + +--error ER_TOO_BIG_SCALE +CREATE TABLE t1 (a DOUBLE(2147483647,2147483647)); +--error ER_TOO_BIG_DISPLAYWIDTH +CREATE TABLE t1 (a DOUBLE(2147483647,0)); +--error ER_M_BIGGER_THAN_D +CREATE TABLE t1 (a DOUBLE(0,2147483647)); + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(2147483648,2147483648)); +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(2147483648,0)); +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(0,2147483648)); + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,999999999999999999999999999999)); +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(999999999999999999999999999999,0)); +--error ER_PARSE_ERROR +CREATE TABLE t1 (a DOUBLE(0,999999999999999999999999999999)); + +--echo # +--echo # End of 10.9 tests +--echo # diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result index c55938eebf1..ea2ef37cb34 100644 --- a/mysql-test/main/type_newdecimal.result +++ b/mysql-test/main/type_newdecimal.result @@ -923,13 +923,13 @@ ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column select cast(ln(14000) as decimal(2,3)) c1; ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '') create table t1 (sl decimal(70,30)); -ERROR 42000: Too big precision 70 specified for 'sl'. Maximum is 65 +ERROR 42000: Too big precision specified for 'sl'. Maximum is 65 create table t1 (sl decimal(32,39)); -ERROR 42000: Too big scale 39 specified for 'sl'. Maximum is 38 +ERROR 42000: Too big scale specified for 'sl'. Maximum is 38 create table t1 (sl decimal(67,38)); -ERROR 42000: Too big precision 67 specified for 'sl'. Maximum is 65 +ERROR 42000: Too big precision specified for 'sl'. Maximum is 65 create table t1 (sl decimal(0,50)); -ERROR 42000: Too big scale 50 specified for 'sl'. Maximum is 38 +ERROR 42000: Too big scale specified for 'sl'. Maximum is 38 create table t1 (sl decimal(0,30)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'sl') create table t1 (sl decimal(5, 5)); @@ -1482,12 +1482,12 @@ SELECT CAST(1 AS decimal(65,10)); CAST(1 AS decimal(65,10)) 1.0000000000 SELECT CAST(1 AS decimal(66,10)); -ERROR 42000: Too big precision 66 specified for '1'. Maximum is 65 +ERROR 42000: Too big precision specified for '1'. Maximum is 65 SELECT CAST(1 AS decimal(65,38)); CAST(1 AS decimal(65,38)) 1.00000000000000000000000000000000000000 SELECT CAST(1 AS decimal(65,39)); -ERROR 42000: Too big scale 39 specified for '1'. Maximum is 38 +ERROR 42000: Too big scale specified for '1'. Maximum is 38 CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL); INSERT INTO t1 VALUES (3,30), (1,10), (2,10); SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa; @@ -1496,7 +1496,7 @@ aa SUM(b) 3.000000000000000000000000000000 10 4.000000000000000000000000000000 30 SELECT a+CAST(1 AS decimal(65,49)) AS aa, SUM(b) FROM t1 GROUP BY aa; -ERROR 42000: Too big scale 49 specified for '1'. Maximum is 38 +ERROR 42000: Too big scale specified for '1'. Maximum is 38 DROP TABLE t1; CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL); INSERT INTO t1 VALUES (3,30), (1,10), (2,10); diff --git a/mysql-test/main/type_time_hires.result b/mysql-test/main/type_time_hires.result index 661ca0e98f5..bd193ba1ed6 100644 --- a/mysql-test/main/type_time_hires.result +++ b/mysql-test/main/type_time_hires.result @@ -1,7 +1,7 @@ SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30'); drop table if exists t1, t2, t3; create table t1 (a time(7)); -ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 create table t1 (a time(3), key(a)); insert t1 values ('2010-12-11 00:20:03.1234'); Warnings: @@ -907,3 +907,24 @@ a CEILING(a) CEILING_SP(a) CEILING(a)=CEILING_SP(a) DROP FUNCTION FLOOR_SP; DROP FUNCTION CEILING_SP; DROP TABLE t1; +# +# Start of 10.9 tests +# +# +# MDEV-27712 Reduce the size of Lex_length_and_dec_st from 16 to 8 +# +CREATE TABLE t1 (a TIME(4294967295)); +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 +CREATE TABLE t1 (a TIME(4294967296)); +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 +CREATE TABLE t1 (a TIME(999999999999999999999999999999)); +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 +SELECT CAST(1 AS TIME(4294967295)); +ERROR 42000: Too big precision specified for '1'. Maximum is 6 +SELECT CAST(1 AS TIME(4294967296)); +ERROR 42000: Too big precision specified for '1'. Maximum is 6 +SELECT CAST(1 AS TIME(999999999999999999999999999999)); +ERROR 42000: Too big precision specified for '1'. Maximum is 6 +# +# Start of 10.9 tests +# diff --git a/mysql-test/main/type_time_hires.test b/mysql-test/main/type_time_hires.test index f9b4a5a9f27..cb15113f8ec 100644 --- a/mysql-test/main/type_time_hires.test +++ b/mysql-test/main/type_time_hires.test @@ -196,3 +196,30 @@ DROP FUNCTION FLOOR_SP; DROP FUNCTION CEILING_SP; DROP TABLE t1; + + +--echo # +--echo # Start of 10.9 tests +--echo # + +--echo # +--echo # MDEV-27712 Reduce the size of Lex_length_and_dec_st from 16 to 8 +--echo # + +--error ER_TOO_BIG_PRECISION +CREATE TABLE t1 (a TIME(4294967295)); +--error ER_TOO_BIG_PRECISION +CREATE TABLE t1 (a TIME(4294967296)); +--error ER_TOO_BIG_PRECISION +CREATE TABLE t1 (a TIME(999999999999999999999999999999)); + +--error ER_TOO_BIG_PRECISION +SELECT CAST(1 AS TIME(4294967295)); +--error ER_TOO_BIG_PRECISION +SELECT CAST(1 AS TIME(4294967296)); +--error ER_TOO_BIG_PRECISION +SELECT CAST(1 AS TIME(999999999999999999999999999999)); + +--echo # +--echo # Start of 10.9 tests +--echo # diff --git a/mysql-test/main/type_timestamp_hires.result b/mysql-test/main/type_timestamp_hires.result index 64675ff9973..f19b26b09f6 100644 --- a/mysql-test/main/type_timestamp_hires.result +++ b/mysql-test/main/type_timestamp_hires.result @@ -1,7 +1,7 @@ SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30'); drop table if exists t1, t2, t3; create table t1 (a timestamp(7)); -ERROR 42000: Too big precision 7 specified for 'a'. Maximum is 6 +ERROR 42000: Too big precision specified for 'a'. Maximum is 6 create table t1 (a timestamp(3), key(a)); insert t1 values ('2010-12-11 00:20:03.1234'); insert t1 values ('2010-12-11 15:47:11.1234'); diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result index 38d33000547..3a5434cda59 100644 --- a/mysql-test/main/win.result +++ b/mysql-test/main/win.result @@ -3925,7 +3925,7 @@ DROP TABLE t1; # MDEV-18916: crash in Window_spec::print_partition() with decimals # SELECT cast((rank() over w1) as decimal (53,56)); -ERROR 42000: Too big scale 56 specified for 'rank() over w1'. Maximum is 38 +ERROR 42000: Too big scale specified for 'rank() over w1'. Maximum is 38 SELECT cast((rank() over w1) as decimal (53,30)); ERROR HY000: Window specification with name 'w1' is not defined # diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 42b298abb32..f68aaf9d10c 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -3931,7 +3931,7 @@ DROP TABLE t1; # MDEV-18916: crash in Window_spec::print_partition() with decimals # SELECT cast((rank() over w1) as decimal (53,56)); -ERROR 42000: Too big scale 56 specified for 'rank() over w1'. Maximum is 38 +ERROR 42000: Too big scale specified for 'rank() over w1'. Maximum is 38 SELECT cast((rank() over w1) as decimal (53,30)); ERROR HY000: Window specification with name 'w1' is not defined # diff --git a/mysql-test/suite/engines/iuds/r/insert_decimal.result b/mysql-test/suite/engines/iuds/r/insert_decimal.result index 2f174c5e70b..a36c6c852dc 100644 --- a/mysql-test/suite/engines/iuds/r/insert_decimal.result +++ b/mysql-test/suite/engines/iuds/r/insert_decimal.result @@ -1010,7 +1010,7 @@ ROUND(c1,c2) TRUNCATE(c1,c2) 1.133000 1.132000 DROP TABLE t5; CREATE TABLE t7(c1 DECIMAL(66,0)); -ERROR 42000: Too big precision 66 specified for 'c1'. Maximum is 65 +ERROR 42000: Too big precision specified for 'c1'. Maximum is 65 CREATE TABLE t7(c1 DECIMAL(5,10)); ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'c1') DROP TABLE t1,t2; diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index d2cc9353518..dd682534bf7 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -143,7 +143,7 @@ BEGIN SET @v1 = f1; SELECT @v1; END// -ERROR 42000: Too big precision 256 specified for 'f1'. Maximum is 65 +ERROR 42000: Too big precision specified for 'f1'. Maximum is 65 DROP PROCEDURE IF EXISTS sp1// Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -153,7 +153,7 @@ BEGIN SET @v1 = f1; SELECT @v1; END// -ERROR 42000: Too big precision 66 specified for 'f1'. Maximum is 65 +ERROR 42000: Too big precision specified for 'f1'. Maximum is 65 DROP PROCEDURE IF EXISTS sp1// Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -1549,7 +1549,7 @@ BEGIN SET f1 = 1000000 + f1; RETURN f1; END// -ERROR 42000: Too big scale 61 specified for 'f1'. Maximum is 38 +ERROR 42000: Too big scale specified for 'f1'. Maximum is 38 SELECT fn1( 1.3326e+8 ); ERROR 42000: FUNCTION db_storedproc.fn1 does not exist CREATE FUNCTION fn1( f1 DECIMAL(63, 30) ) RETURNS DECIMAL(63, 30) @@ -5837,7 +5837,7 @@ fetch cur1 into e; SELECT x, y, z, a, b, c, d, e; close cur1; END// -ERROR 42000: Too big scale 255 specified for 'b'. Maximum is 38 +ERROR 42000: Too big scale specified for 'b'. Maximum is 38 CALL sp6(); ERROR 42000: PROCEDURE db_storedproc.sp6 does not exist DROP PROCEDURE IF EXISTS sp6; diff --git a/sql/field.cc b/sql/field.cc index 767492fe17d..ae82d617ad3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10428,16 +10428,12 @@ void Column_definition_attributes::set_length_and_dec(const Lex_length_and_dec_st &type) { - if (type.length()) - { - int err; - length= my_strtoll10(type.length(), NULL, &err); - if (err) - length= ~0ULL; // safety - } + if (type.has_explicit_length()) + length= type.length_overflowed() ? (ulonglong) UINT_MAX32 + 1 : + (ulonglong) type.length(); - if (type.dec()) - decimals= (uint) atoi(type.dec()); + if (type.has_explicit_dec()) + decimals= type.dec(); } @@ -10536,7 +10532,7 @@ bool Column_definition::fix_attributes_real(uint default_length) } if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS) { - my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals), + my_error(ER_TOO_BIG_SCALE, MYF(0), field_name.str, static_cast<uint>(FLOATING_POINT_DECIMALS-1)); return true; } @@ -10548,14 +10544,14 @@ bool Column_definition::fix_attributes_decimal() { if (decimals >= NOT_FIXED_DEC) { - my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals), + my_error(ER_TOO_BIG_SCALE, MYF(0), field_name.str, static_cast<uint>(NOT_FIXED_DEC - 1)); return true; } my_decimal_trim(&length, &decimals); if (length > DECIMAL_MAX_PRECISION) { - my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str, + my_error(ER_TOO_BIG_PRECISION, MYF(0), field_name.str, DECIMAL_MAX_PRECISION); return true; } @@ -10584,7 +10580,7 @@ bool Column_definition::fix_attributes_temporal_with_time(uint int_part_length) { if (length > MAX_DATETIME_PRECISION) { - my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str, + my_error(ER_TOO_BIG_PRECISION, MYF(0), field_name.str, MAX_DATETIME_PRECISION); return true; } diff --git a/sql/item_create.cc b/sql/item_create.cc index 20b86cfc1dc..2d76b04ac5d 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5995,7 +5995,7 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums) Item *create_func_dyncol_get(THD *thd, Item *str, Item *num, const Type_handler *handler, - const char *c_len, const char *c_dec, + const Lex_length_and_dec_st &length_dec, CHARSET_INFO *cs) { Item *res; @@ -6003,5 +6003,5 @@ Item *create_func_dyncol_get(THD *thd, Item *str, Item *num, if (likely(!(res= new (thd->mem_root) Item_dyncol_get(thd, str, num)))) return res; // Return NULL return handler->create_typecast_item(thd, res, - Type_cast_attributes(c_len, c_dec, cs)); + Type_cast_attributes(length_dec, cs)); } diff --git a/sql/item_create.h b/sql/item_create.h index c04adad469c..ca5038582f8 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -313,7 +313,7 @@ Item *create_func_dyncol_add(THD *thd, Item *str, Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums); Item *create_func_dyncol_get(THD *thd, Item *num, Item *str, const Type_handler *handler, - const char *c_len, const char *c_dec, + const Lex_length_and_dec_st &length_and_dec, CHARSET_INFO *cs); Item *create_func_dyncol_json(THD *thd, Item *str); diff --git a/sql/item_func.h b/sql/item_func.h index d323dc27fcc..99b9a075d2c 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -3762,31 +3762,22 @@ struct Lex_cast_type_st: public Lex_length_and_dec_st private: const Type_handler *m_type_handler; public: - void set(const Type_handler *handler, const char *length, const char *dec) - { - m_type_handler= handler; - Lex_length_and_dec_st::set(length, dec); - } void set(const Type_handler *handler, Lex_length_and_dec_st length_and_dec) { m_type_handler= handler; Lex_length_and_dec_st::operator=(length_and_dec); } - void set(const Type_handler *handler, const char *length) - { - set(handler, length, 0); - } void set(const Type_handler *handler) { - set(handler, 0, 0); + m_type_handler= handler; + Lex_length_and_dec_st::reset(); } const Type_handler *type_handler() const { return m_type_handler; } Item *create_typecast_item(THD *thd, Item *item, CHARSET_INFO *cs= NULL) const { return m_type_handler-> - create_typecast_item(thd, item, - Type_cast_attributes(length(), dec(), cs)); + create_typecast_item(thd, item, Type_cast_attributes(*this, cs)); } Item *create_typecast_item_or_error(THD *thd, Item *item, CHARSET_INFO *cs= NULL) const; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0a24578ce85..148488680f0 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -1551,7 +1551,7 @@ bool Item_func_curtime::fix_fields(THD *thd, Item **items) { if (decimals > TIME_SECOND_PART_DIGITS) { - my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<ulonglong>(decimals), + my_error(ER_TOO_BIG_PRECISION, MYF(0), func_name(), TIME_SECOND_PART_DIGITS); return 1; } @@ -1627,7 +1627,7 @@ bool Item_func_now::fix_fields(THD *thd, Item **items) { if (decimals > TIME_SECOND_PART_DIGITS) { - my_error(ER_TOO_BIG_PRECISION, MYF(0), static_cast<ulonglong>(decimals), + my_error(ER_TOO_BIG_PRECISION, MYF(0), func_name(), TIME_SECOND_PART_DIGITS); return 1; } diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 64bfe1aefb9..7b530ee4f16 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -5771,13 +5771,13 @@ ER_SP_NO_RECURSION ger "Rekursive gespeicherte Routinen und Triggers sind nicht erlaubt" spa "No autorizadas funciones almacenadas recursivas ni disparadores" ER_TOO_BIG_SCALE 42000 S1009 - eng "Too big scale %llu specified for '%-.192s'. Maximum is %u" - ger "Zu großer Skalierungsfaktor %llu für '%-.192s' angegeben. Maximum ist %u" - spa "Escala %llu demasiado grande especificada para '%-.192s'. El máximo es de %u" + eng "Too big scale specified for '%-.192s'. Maximum is %u" + ger "Zu großer Skalierungsfaktor für '%-.192s' angegeben. Maximum ist %u" + spa "Escala demasiado grande especificada para '%-.192s'. El máximo es de %u" ER_TOO_BIG_PRECISION 42000 S1009 - eng "Too big precision %llu specified for '%-.192s'. Maximum is %u" - ger "Zu große Genauigkeit %llu für '%-.192s' angegeben. Maximum ist %u" - spa "Precisión %llu demasiado grande especificada para '%-.192s'. El máximo es de %u" + eng "Too big precision specified for '%-.192s'. Maximum is %u" + ger "Zu große Genauigkeit für '%-.192s' angegeben. Maximum ist %u" + spa "Precisión demasiado grande especificada para '%-.192s'. El máximo es de %u" ER_M_BIGGER_THAN_D 42000 S1009 eng "For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '%-.192s')" ger "Für FLOAT(M,D), DOUBLE(M,D) oder DECIMAL(M,D) muss M >= D sein (Feld '%-.192s')" diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e1fd7b5ae2b..8398b727841 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -11488,14 +11488,42 @@ Lex_cast_type_st::create_typecast_item_or_error(THD *thd, Item *item, } -void Lex_field_type_st::set_handler_length_flags(const Type_handler *handler, - const char *length, - uint32 flags) +void +Lex_length_and_dec_st::set(const char *plength, const char *pdec) +{ + reset(); + + if ((m_has_explicit_length= (plength != nullptr))) + { + int err; + ulonglong tmp= my_strtoll10(plength, NULL, &err); + if ((m_length_overflowed= (tmp > UINT_MAX32 || err))) + m_length= UINT_MAX32; + else + m_length= (uint32) tmp; + } + + if ((m_has_explicit_dec= (pdec != nullptr))) + { + int err; + ulonglong tmp= my_strtoll10(pdec, NULL, &err); + if ((m_dec_overflowed= (tmp > 255 || err))) + m_dec= 255; + else + m_dec= (uint8) tmp; + } +} + + +void +Lex_field_type_st::set_handler_length_flags(const Type_handler *handler, + const Lex_length_and_dec_st &attr, + uint32 flags) { DBUG_ASSERT(!handler->is_unsigned()); + set(handler, attr); if (flags & UNSIGNED_FLAG) - handler= handler->type_handler_unsigned(); - set(handler, length, NULL); + m_handler= m_handler->type_handler_unsigned(); } diff --git a/sql/sql_type.cc b/sql/sql_type.cc index adfe02e633b..269a4b072d4 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2751,7 +2751,7 @@ Type_handler_string::Column_definition_set_attributes( const { Type_handler::Column_definition_set_attributes(thd, def, attr, cs, type); - if (attr.length()) + if (attr.has_explicit_length()) return false; switch (type) { case COLUMN_DEFINITION_ROUTINE_PARAM: @@ -2783,7 +2783,7 @@ Type_handler_varchar::Column_definition_set_attributes( const { Type_handler::Column_definition_set_attributes(thd, def, attr, cs, type); - if (attr.length()) + if (attr.has_explicit_length()) return false; switch (type) { case COLUMN_DEFINITION_ROUTINE_PARAM: @@ -7698,11 +7698,10 @@ static const char* item_name(Item *a, String *str) } -static void wrong_precision_error(uint errcode, Item *a, - ulonglong number, uint maximum) +static void wrong_precision_error(uint errcode, Item *a, uint maximum) { StringBuffer<1024> buf(system_charset_info); - my_error(errcode, MYF(0), number, item_name(a, &buf), maximum); + my_error(errcode, MYF(0), item_name(a, &buf), maximum); } @@ -7721,12 +7720,12 @@ bool get_length_and_scale(ulonglong length, ulonglong decimals, { if (length > (ulonglong) max_precision) { - wrong_precision_error(ER_TOO_BIG_PRECISION, a, length, max_precision); + wrong_precision_error(ER_TOO_BIG_PRECISION, a, max_precision); return 1; } if (decimals > (ulonglong) max_scale) { - wrong_precision_error(ER_TOO_BIG_SCALE, a, decimals, max_scale); + wrong_precision_error(ER_TOO_BIG_SCALE, a, max_scale); return 1; } @@ -7769,8 +7768,7 @@ Item *Type_handler_time_common:: { if (attr.decimals() > MAX_DATETIME_PRECISION) { - wrong_precision_error(ER_TOO_BIG_PRECISION, item, attr.decimals(), - MAX_DATETIME_PRECISION); + wrong_precision_error(ER_TOO_BIG_PRECISION, item, MAX_DATETIME_PRECISION); return 0; } return new (thd->mem_root) @@ -7784,8 +7782,7 @@ Item *Type_handler_datetime_common:: { if (attr.decimals() > MAX_DATETIME_PRECISION) { - wrong_precision_error(ER_TOO_BIG_PRECISION, item, attr.decimals(), - MAX_DATETIME_PRECISION); + wrong_precision_error(ER_TOO_BIG_PRECISION, item, MAX_DATETIME_PRECISION); return 0; } return new (thd->mem_root) @@ -7863,8 +7860,7 @@ Item *Type_handler_interval_DDhhmmssff:: { if (attr.decimals() > MAX_DATETIME_PRECISION) { - wrong_precision_error(ER_TOO_BIG_PRECISION, item, attr.decimals(), - MAX_DATETIME_PRECISION); + wrong_precision_error(ER_TOO_BIG_PRECISION, item, MAX_DATETIME_PRECISION); return 0; } return new (thd->mem_root) Item_interval_DDhhmmssff_typecast(thd, item, diff --git a/sql/sql_type.h b/sql/sql_type.h index 0f74489719a..94ba8f5ffbc 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -3336,28 +3336,21 @@ class Type_cast_attributes bool m_length_specified; bool m_decimals_specified; public: - Type_cast_attributes(const char *c_len, const char *c_dec, CHARSET_INFO *cs) + Type_cast_attributes(const Lex_length_and_dec_st &length_and_dec, + CHARSET_INFO *cs) :m_charset(cs), m_length(0), m_decimals(0), m_length_specified(false), m_decimals_specified(false) { - set_length_and_dec(c_len, c_dec); + m_length= length_and_dec.length_overflowed() ? (ulonglong) UINT_MAX32 + 1 : + length_and_dec.length(); + m_decimals= length_and_dec.dec(); + m_length_specified= length_and_dec.has_explicit_length(); + m_decimals_specified= length_and_dec.has_explicit_dec(); } Type_cast_attributes(CHARSET_INFO *cs) :m_charset(cs), m_length(0), m_decimals(0), m_length_specified(false), m_decimals_specified(false) { } - void set_length_and_dec(const char *c_len, const char *c_dec) - { - int error; - /* - We don't have to check for error here as sql_yacc.yy has guaranteed - that the values are in range of ulonglong - */ - if ((m_length_specified= (c_len != NULL))) - m_length= (ulonglong) my_strtoll10(c_len, NULL, &error); - if ((m_decimals_specified= (c_dec != NULL))) - m_decimals= (ulonglong) my_strtoll10(c_dec, NULL, &error); - } CHARSET_INFO *charset() const { return m_charset; } bool length_specified() const { return m_length_specified; } bool decimals_specified() const { return m_decimals_specified; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ea1eebc1236..3abad020007 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1365,7 +1365,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); wild_and_where %type <const_simple_string> - field_length opt_field_length + field_length_str opt_compression_method %type <string> @@ -1565,6 +1565,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type <Lex_cast_type> cast_type cast_type_numeric cast_type_temporal %type <Lex_length_and_dec> precision opt_precision float_options + field_length opt_field_length + field_scale opt_field_scale %type <lex_user> user grant_user grant_role user_or_role current_role admin_option_for_role user_maybe_role @@ -5975,14 +5977,12 @@ field_type_numeric: | FLOAT_SYM float_options last_field_options { $$.set(&type_handler_float, $2); - if ($2.length() && !$2.dec()) + if ($2.has_explicit_length() && !$2.has_explicit_dec()) { - int err; - ulonglong tmp_length= my_strtoll10($2.length(), NULL, &err); - if (unlikely(err || tmp_length > PRECISION_FOR_DOUBLE)) + if (unlikely($2.length() > PRECISION_FOR_DOUBLE)) my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0), Lex->last_field->field_name.str)); - if (tmp_length > PRECISION_FOR_FLOAT) + if ($2.length() > PRECISION_FOR_FLOAT) $$.set(&type_handler_double); else $$.set(&type_handler_float); @@ -5994,17 +5994,17 @@ field_type_numeric: } | BOOL_SYM { - $$.set(&type_handler_stiny, "1"); + $$.set_handler_length(&type_handler_stiny, 1); } | BOOLEAN_SYM { - $$.set(&type_handler_stiny, "1"); + $$.set_handler_length(&type_handler_stiny, 1); } | DECIMAL_SYM float_options last_field_options { $$.set(&type_handler_newdecimal, $2);} | NUMBER_ORACLE_SYM float_options last_field_options { - if ($2.length() != 0) + if ($2.has_explicit_length()) $$.set(&type_handler_newdecimal, $2); else $$.set(&type_handler_double); @@ -6066,14 +6066,12 @@ field_type_string: field_type_temporal: YEAR_SYM opt_field_length last_field_options { - if ($2) + if ($2.has_explicit_length()) { - errno= 0; - ulong length= strtoul($2, NULL, 10); - if (errno == 0 && length <= MAX_FIELD_BLOBLENGTH && length != 4) + if ($2.length() != 4) { char buff[sizeof("YEAR()") + MY_INT64_NUM_DECIMAL_DIGITS + 1]; - my_snprintf(buff, sizeof(buff), "YEAR(%lu)", length); + my_snprintf(buff, sizeof(buff), "YEAR(%u)", (uint) $2.length()); push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_WARN_DEPRECATED_SYNTAX, ER_THD(thd, ER_WARN_DEPRECATED_SYNTAX), @@ -6220,9 +6218,9 @@ srid_option: ; float_options: - /* empty */ { $$.set(0, 0); } - | field_length { $$.set($1, 0); } - | precision { $$= $1; } + /* empty */ { $$.reset(); } + | field_length + | precision ; precision: @@ -6242,20 +6240,33 @@ last_field_options: field_options { Lex->last_field->flags|= ($$= $1); } ; -field_length: +field_length_str: '(' LONG_NUM ')' { $$= $2.str; } | '(' ULONGLONG_NUM ')' { $$= $2.str; } | '(' DECIMAL_NUM ')' { $$= $2.str; } | '(' NUM ')' { $$= $2.str; } ; +field_length: field_length_str { $$.set($1, NULL); } + ; + + +field_scale: field_length_str { $$.set(NULL, $1); } + ; + + opt_field_length: - /* empty */ { $$= (char*) 0; /* use default length */ } - | field_length { $$= $1; } + /* empty */ { $$.reset(); /* use default length */ } + | field_length + ; + +opt_field_scale: + /* empty */ { $$.reset(); } + | field_scale ; opt_precision: - /* empty */ { $$.set(0, 0); } + /* empty */ { $$.reset(); } | precision { $$= $1; } ; @@ -9418,8 +9429,8 @@ numeric_dyncol_type: temporal_dyncol_type: DATE_SYM { $$.set(DYN_COL_DATE); } - | TIME_SYM opt_field_length { $$.set(DYN_COL_TIME, 0, $2); } - | DATETIME opt_field_length { $$.set(DYN_COL_DATETIME, 0, $2); } + | TIME_SYM opt_field_scale { $$.set(DYN_COL_TIME, $2); } + | DATETIME opt_field_scale { $$.set(DYN_COL_DATETIME, $2); } ; string_dyncol_type: @@ -9448,12 +9459,12 @@ dyncall_create_element: $$->value= $3; $$->type= (DYNAMIC_COLUMN_TYPE)$4.dyncol_type(); $$->cs= lex->charset; - if ($4.length()) - $$->len= strtoul($4.length(), NULL, 10); + if ($4.has_explicit_length()) + $$->len= $4.length(); else $$->len= 0; - if ($4.dec()) - $$->frac= strtoul($4.dec(), NULL, 10); + if ($4.has_explicit_dec()) + $$->frac= $4.dec(); else $$->len= 0; } @@ -10142,8 +10153,7 @@ function_call_nonkeyword: { LEX *lex= Lex; $$= create_func_dyncol_get(thd, $3, $5, $7.type_handler(), - $7.length(), $7.dec(), - lex->charset); + $7, lex->charset); if (unlikely($$ == NULL)) MYSQL_YYABORT; } @@ -11060,7 +11070,7 @@ cast_type: | NCHAR_SYM opt_field_length { Lex->charset= national_charset_info; - $$.set(&type_handler_long_blob, $2, 0); + $$.set(&type_handler_long_blob, $2); } | cast_type_numeric { $$= $1; Lex->charset= NULL; } | cast_type_temporal { $$= $1; Lex->charset= NULL; } @@ -11094,11 +11104,11 @@ cast_type_numeric: cast_type_temporal: DATE_SYM { $$.set(&type_handler_newdate); } - | TIME_SYM opt_field_length { $$.set(&type_handler_time2, 0, $2); } - | DATETIME opt_field_length { $$.set(&type_handler_datetime2, 0, $2); } - | INTERVAL_SYM DAY_SECOND_SYM field_length + | TIME_SYM opt_field_scale { $$.set(&type_handler_time2, $2); } + | DATETIME opt_field_scale { $$.set(&type_handler_datetime2, $2); } + | INTERVAL_SYM DAY_SECOND_SYM field_scale { - $$.set(&type_handler_interval_DDhhmmssff, 0, $3); + $$.set(&type_handler_interval_DDhhmmssff, $3); } ; @@ -11282,7 +11292,7 @@ json_table_column_type: FOR_SYM ORDINALITY_SYM { Lex_field_type_st type; - type.set_handler_length_flags(&type_handler_slong, 0, 0); + type.set(&type_handler_slong); Lex->last_field->set_attributes(thd, type, Lex->charset, COLUMN_DEFINITION_TABLE_FIELD); Lex->json_table->m_cur_json_table_column-> diff --git a/sql/structs.h b/sql/structs.h index 59bab6c6f18..d5c363cdd25 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -602,16 +602,74 @@ public: struct Lex_length_and_dec_st { private: - const char *m_length; - const char *m_dec; + uint32 m_length; + uint8 m_dec; + bool m_has_explicit_length:1; + bool m_has_explicit_dec:1; + bool m_length_overflowed:1; + bool m_dec_overflowed:1; public: - void set(const char *length, const char *dec) + void reset() + { + m_length= 0; + m_dec= 0; + m_has_explicit_length= false; + m_has_explicit_dec= false; + m_length_overflowed= false; + m_dec_overflowed= false; + } + void set_length_only(uint32 length) + { + m_length= length; + m_dec= 0; + m_has_explicit_length= true; + m_has_explicit_dec= false; + m_length_overflowed= false; + m_dec_overflowed= false; + } + void set_dec_only(uint8 dec) + { + m_length= 0; + m_dec= dec; + m_has_explicit_length= false; + m_has_explicit_dec= true; + m_length_overflowed= false; + m_dec_overflowed= false; + } + void set_length_and_dec(uint32 length, uint8 dec) { m_length= length; m_dec= dec; + m_has_explicit_length= true; + m_has_explicit_dec= true; + m_length_overflowed= false; + m_dec_overflowed= false; + } + void set(const char *length, const char *dec); + uint32 length() const + { + return m_length; + } + uint8 dec() const + { + return m_dec; + } + bool has_explicit_length() const + { + return m_has_explicit_length; + } + bool has_explicit_dec() const + { + return m_has_explicit_dec; + } + bool length_overflowed() const + { + return m_length_overflowed; + } + bool dec_overflowed() const + { + return m_dec_overflowed; } - const char *length() const { return m_length; } - const char *dec() const { return m_dec; } }; @@ -619,26 +677,24 @@ struct Lex_field_type_st: public Lex_length_and_dec_st { private: const Type_handler *m_handler; - void set(const Type_handler *handler, const char *length, const char *dec) - { - m_handler= handler; - Lex_length_and_dec_st::set(length, dec); - } public: void set(const Type_handler *handler, Lex_length_and_dec_st length_and_dec) { m_handler= handler; Lex_length_and_dec_st::operator=(length_and_dec); } - void set_handler_length_flags(const Type_handler *handler, const char *length, + void set_handler_length_flags(const Type_handler *handler, + const Lex_length_and_dec_st &length, uint32 flags); - void set(const Type_handler *handler, const char *length) + void set_handler_length(const Type_handler *handler, uint32 length) { - set(handler, length, 0); + m_handler= handler; + Lex_length_and_dec_st::set_length_only(length); } void set(const Type_handler *handler) { - set(handler, 0, 0); + m_handler= handler; + Lex_length_and_dec_st::reset(); } void set_handler(const Type_handler *handler) { @@ -653,23 +709,15 @@ struct Lex_dyncol_type_st: public Lex_length_and_dec_st private: int m_type; // enum_dynamic_column_type is not visible here, so use int public: - void set(int type, const char *length, const char *dec) - { - m_type= type; - Lex_length_and_dec_st::set(length, dec); - } void set(int type, Lex_length_and_dec_st length_and_dec) { m_type= type; Lex_length_and_dec_st::operator=(length_and_dec); } - void set(int type, const char *length) - { - set(type, length, 0); - } void set(int type) { - set(type, 0, 0); + m_type= type; + Lex_length_and_dec_st::reset(); } int dyncol_type() const { return m_type; } }; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result index a3a138555ee..4a1fc17395d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_not_null.result @@ -1423,11 +1423,11 @@ d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NOT NULL; -ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NOT NULL; -ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NOT NULL; -ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38 +ERROR 42000: Too big scale specified for 'n66_66'. Maximum is 38 DROP TABLE t1; DROP TABLE IF EXISTS t1; #---------------------------------- @@ -1825,7 +1825,7 @@ r1_1 0.9 r1_1 0.9 ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NOT NULL; ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NOT NULL; -ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NOT NULL; DROP TABLE t1; DROP TABLE IF EXISTS t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result index f0d377890c5..d97fb8a2481 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_null.result @@ -1232,11 +1232,11 @@ d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) NULL; -ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) NULL; -ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) NULL; -ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38 +ERROR 42000: Too big scale specified for 'n66_66'. Maximum is 38 DROP TABLE t1; DROP TABLE IF EXISTS t1; CREATE TABLE t1 ( @@ -1612,7 +1612,7 @@ r1_1 0.9 r1_1 0.9 ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) NULL; ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) NULL; -ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) NULL; DROP TABLE t1; DROP TABLE IF EXISTS t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result index 13445fc9326..0a8f49ebf36 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/col_opt_unsigned.result @@ -148,11 +148,11 @@ d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) UNSIGNED; -ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) UNSIGNED; -ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) UNSIGNED; -ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38 +ERROR 42000: Too big scale specified for 'n66_66'. Maximum is 38 DROP TABLE t1; CREATE TABLE t1 ( a DECIMAL UNSIGNED, @@ -499,7 +499,7 @@ r1_1 0.9 r1_1 0.9 ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) UNSIGNED; ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) UNSIGNED; -ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) UNSIGNED; DROP TABLE t1; CREATE TABLE t1 ( diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result index 055952ea55f..fcbef547891 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_fixed.result @@ -123,9 +123,9 @@ d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999 ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66) ; -ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6) ; -ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66) ; -ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 38 +ERROR 42000: Too big scale specified for 'n66_66'. Maximum is 38 DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/type_float.result b/storage/rocksdb/mysql-test/rocksdb/r/type_float.result index 371b550d4ab..0cf5c5e0496 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/type_float.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/type_float.result @@ -309,6 +309,6 @@ r1_1 0.9 r1_1 0.9 ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ; ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1) ; -ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65 +ERROR 42000: Too big precision specified for 'n66_6'. Maximum is 65 ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35) ; DROP TABLE t1; |