diff options
author | unknown <jani@a193-229-222-105.elisa-laajakaista.fi> | 2005-05-12 17:37:38 +0300 |
---|---|---|
committer | unknown <jani@a193-229-222-105.elisa-laajakaista.fi> | 2005-05-12 17:37:38 +0300 |
commit | 4acfc0b6111fb069cc718b6b87d821407190999e (patch) | |
tree | 3028ac975c41a4c2e21e44f1e36aef7649a7769f | |
parent | 7b36ac4819a02c25664a5f70f74262c3720eccab (diff) | |
download | mariadb-git-4acfc0b6111fb069cc718b6b87d821407190999e.tar.gz |
Fixed bug 10465.
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 9 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 10 | ||||
-rw-r--r-- | sql/field.cc | 7 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 35bd8d73675..e775724ff54 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -876,3 +876,12 @@ SELECT * FROM t1; f1 f2 9999999999999999999999999999999999.00000000000000000000 0.00 DROP TABLE t1; +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +GRADE +252 +SELECT GRADE FROM t1 WHERE GRADE= 151; +GRADE +151 +DROP TABLE t1; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 45a2034e8cc..78ad5ed2286 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -906,3 +906,13 @@ CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2)); INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0); SELECT * FROM t1; DROP TABLE t1; + +# +# Bug #10465 +# + +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +SELECT GRADE FROM t1 WHERE GRADE= 151; +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 78266441bda..34c5210b43c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8060,7 +8060,12 @@ void create_field::create_length_to_internal_length(void) } break; case MYSQL_TYPE_NEWDECIMAL: - key_length= pack_length= my_decimal_get_binary_size(length, decimals); + key_length= pack_length= + my_decimal_get_binary_size(my_decimal_length_to_precision(length, + decimals, + flags & + UNSIGNED_FLAG), + decimals); break; default: key_length= pack_length= calc_pack_length(sql_type, length); |