diff options
-rw-r--r-- | mysql-test/r/type_bit.result | 19 | ||||
-rw-r--r-- | mysql-test/r/type_int.result | 13 | ||||
-rw-r--r-- | mysql-test/t/type_bit.test | 25 | ||||
-rw-r--r-- | mysql-test/t/type_int.test | 12 | ||||
-rw-r--r-- | sql/field.h | 4 |
5 files changed, 73 insertions, 0 deletions
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 30cd94c9277..eeedc501dc4 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -830,3 +830,22 @@ def COALESCE(val, 1) 246 2 1 Y 32896 0 63 COALESCE(val, 1) 0 DROP TABLE t1; +# +# End of 10.1 tests +# +# +# Start of 10.2 tests +# +# +# MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result +# +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); +ALTER TABLE t1 MODIFY a BIT(64); +SELECT a+0 FROM t1; +a+0 +18446744073709551615 +DROP TABLE IF EXISTS t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/r/type_int.result b/mysql-test/r/type_int.result index 39e2e91ecc7..77e6ee14c25 100644 --- a/mysql-test/r/type_int.result +++ b/mysql-test/r/type_int.result @@ -91,5 +91,18 @@ a 10 DROP TABLE t1; # +# MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result +# +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); +SELECT * FROM t1; +a +18446744073709551615 +ALTER TABLE t1 MODIFY a BIGINT UNSIGNED; +SELECT * FROM t1; +a +18446744073709551615 +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index bb282fc15e5..04db1511833 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -458,3 +458,28 @@ DROP TABLE t2; SELECT COALESCE(val, 1) FROM t1; --disable_metadata DROP TABLE t1; + +--echo # +--echo # End of 10.1 tests +--echo # + + +--echo # +--echo # Start of 10.2 tests +--echo # + +--echo # +--echo # MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result +--echo # + +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); +ALTER TABLE t1 MODIFY a BIT(64); +SELECT a+0 FROM t1; +DROP TABLE IF EXISTS t1; + + +--echo # +--echo # End of 10.2 tests +--echo # + diff --git a/mysql-test/t/type_int.test b/mysql-test/t/type_int.test index 271b4d5862a..76ed7eee824 100644 --- a/mysql-test/t/type_int.test +++ b/mysql-test/t/type_int.test @@ -74,5 +74,17 @@ SELECT * FROM t1; DROP TABLE t1; --echo # +--echo # MDEV-9334 ALTER from DECIMAL to BIGINT UNSIGNED returns a wrong result +--echo # + +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (CAST(0xFFFFFFFFFFFFFFFF AS UNSIGNED)); +SELECT * FROM t1; +ALTER TABLE t1 MODIFY a BIGINT UNSIGNED; +SELECT * FROM t1; +DROP TABLE t1; + + +--echo # --echo # End of 10.2 tests --echo # diff --git a/sql/field.h b/sql/field.h index ca85a7c276f..e554f92031c 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1636,6 +1636,8 @@ public: bool eq_def(const Field *field) const; Copy_func *get_copy_func(const Field *from) const { + if (unsigned_flag && from->cmp_type() == DECIMAL_RESULT) + return do_field_decimal; return do_field_int; } int save_in_field(Field *to) @@ -3661,6 +3663,8 @@ public: } Copy_func *get_copy_func(const Field *from) const { + if (from->cmp_type() == DECIMAL_RESULT) + return do_field_decimal; return do_field_int; } int save_in_field(Field *to) { return to->store(val_int(), true); } |