diff options
author | Sergey Glukhov <sergey.glukhov@oracle.com> | 2011-03-28 12:28:30 +0400 |
---|---|---|
committer | Sergey Glukhov <sergey.glukhov@oracle.com> | 2011-03-28 12:28:30 +0400 |
commit | ff23f5360ee328bd6adb14436e68e080cfe1d110 (patch) | |
tree | a42581f217bef4defbed4810cd9fef5a17b16c27 | |
parent | d499851be03a2a20f7cb230d9b2d69e169aa81c8 (diff) | |
download | mariadb-git-ff23f5360ee328bd6adb14436e68e080cfe1d110.tar.gz |
Bug#11766424 59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE
Assertion happens due to missing initialization of unsigned_flag
for Item_func_set_user_var object. It leads to incorrect
calculation of decimal field size.
The fix is to add initialization of unsigned_flag.
mysql-test/r/variables.result:
test case
mysql-test/t/variables.test:
test case
sql/item_func.cc:
add initialization of unsigned_flag.
-rw-r--r-- | mysql-test/r/variables.result | 16 | ||||
-rw-r--r-- | mysql-test/t/variables.test | 13 | ||||
-rw-r--r-- | sql/item_func.cc | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index af3b76b09f3..f92e1dec4c9 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -1547,6 +1547,22 @@ Warning 1292 Truncated incorrect key_cache_block_size value: '0' select @@max_long_data_size; @@max_long_data_size 1048576 +# +# Bug#11766424 59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE +# +CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED); +INSERT INTO t1 VALUES (0.2),(0.1); +SELECT 1 FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1); +1 +1 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(1) unsigned NOT NULL DEFAULT '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; SET @@global.max_binlog_cache_size=DEFAULT; SET @@global.max_join_size=DEFAULT; SET @@global.key_buffer_size=@kbs; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 383bdfc79a9..8f111e7cf3b 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -1298,6 +1298,19 @@ SET @@global.key_cache_block_size=0; # select @@max_long_data_size; +--echo # +--echo # Bug#11766424 59527: DECIMAL_BIN_SIZE: ASSERTION `SCALE >= 0 && PRECISION > 0 && SCALE <= PRE +--echo # + +CREATE TABLE t1(f1 DECIMAL(1,1) UNSIGNED); +INSERT INTO t1 VALUES (0.2),(0.1); +SELECT 1 FROM t1 GROUP BY @a:= (SELECT ROUND(f1) FROM t1 WHERE @a=f1); +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT @a:= CAST(1 AS UNSIGNED) AS a; +SHOW CREATE TABLE t1; +DROP TABLE t1; + # cleanup SET @@global.max_binlog_cache_size=DEFAULT; SET @@global.max_join_size=DEFAULT; diff --git a/sql/item_func.cc b/sql/item_func.cc index efae928a8b6..d4fd2c94e1d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3840,6 +3840,7 @@ Item_func_set_user_var::fix_length_and_dec() maybe_null=args[0]->maybe_null; max_length=args[0]->max_length; decimals=args[0]->decimals; + unsigned_flag= args[0]->unsigned_flag; collation.set(args[0]->collation.collation, DERIVATION_IMPLICIT); } |