diff options
-rw-r--r-- | mysql-test/r/cast.result | 18 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 13 | ||||
-rw-r--r-- | sql/item_func.h | 17 |
3 files changed, 41 insertions, 7 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index d7a7503707b..fc0d79e9568 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -477,4 +477,22 @@ WHERE CAST(a as BINARY)=x'62736D697468' AND CAST(a AS BINARY)=x'65736D697468'; a DROP TABLE t1; +# +# Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH +# LONGTEXT, UNION, USER VARIABLE +# Bug#14096619 UNABLE TO RESTORE DATABASE DUMP +# +CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)), +CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED)); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +Warning 1292 Truncated incorrect INTEGER value: '99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `CONCAT(CAST(REPEAT('9', 1000) AS SIGNED))` varbinary(21) NOT NULL DEFAULT '', + `CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED))` varbinary(21) NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# End of test for Bug#13581962, Bug#14096619 End of 5.1 tests diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 4474736200c..27eb5e88c54 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -309,4 +309,17 @@ WHERE CAST(a as BINARY)=x'62736D697468' DROP TABLE t1; +--echo # +--echo # Bug#13581962 HIGH MEMORY USAGE ATTEMPT, THEN CRASH WITH +--echo # LONGTEXT, UNION, USER VARIABLE +--echo # Bug#14096619 UNABLE TO RESTORE DATABASE DUMP +--echo # + +CREATE TABLE t1 AS SELECT CONCAT(CAST(REPEAT('9', 1000) AS SIGNED)), + CONCAT(CAST(REPEAT('9', 1000) AS UNSIGNED)); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # End of test for Bug#13581962, Bug#14096619 + --echo End of 5.1 tests diff --git a/sql/item_func.h b/sql/item_func.h index ec410ed3d3d..d769ceb0179 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -403,12 +403,17 @@ public: class Item_func_signed :public Item_int_func { public: - Item_func_signed(Item *a) :Item_int_func(a) {} + Item_func_signed(Item *a) :Item_int_func(a) + { + unsigned_flag= 0; + } const char *func_name() const { return "cast_as_signed"; } longlong val_int(); longlong val_int_from_str(int *error); void fix_length_and_dec() - { max_length=args[0]->max_length; unsigned_flag=0; } + { + max_length= min(args[0]->max_length,MY_INT64_NUM_DECIMAL_DIGITS); + } virtual void print(String *str, enum_query_type query_type); uint decimal_precision() const { return args[0]->decimal_precision(); } }; @@ -417,13 +422,11 @@ public: class Item_func_unsigned :public Item_func_signed { public: - Item_func_unsigned(Item *a) :Item_func_signed(a) {} - const char *func_name() const { return "cast_as_unsigned"; } - void fix_length_and_dec() + Item_func_unsigned(Item *a) :Item_func_signed(a) { - max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2); - unsigned_flag=1; + unsigned_flag= 1; } + const char *func_name() const { return "cast_as_unsigned"; } longlong val_int(); virtual void print(String *str, enum_query_type query_type); }; |