diff --git a/mysql-test/main/type_float.result b/mysql-test/main/type_float.result index e944b4bb64f..ad47afeb06d 100644 --- a/mysql-test/main/type_float.result +++ b/mysql-test/main/type_float.result @@ -1283,5 +1283,18 @@ h varchar(16) YES NULL DROP TABLE t1, t2; SET sql_mode=DEFAULT; # +# MDEV-25174 DOUBLE columns do not accept large hex hybrids +# +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF); +INSERT INTO t1 VALUES (0x8000000000000000); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 ORDER BY a; +a +9.223372036854776e18 +9.223372036854776e18 +1.8446744073709552e19 +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test index ebf1883d301..837705f870e 100644 --- a/mysql-test/main/type_float.test +++ b/mysql-test/main/type_float.test @@ -798,6 +798,17 @@ DROP TABLE t1, t2; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-25174 DOUBLE columns do not accept large hex hybrids +--echo # + +CREATE TABLE t1 (a DOUBLE); +INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF); +INSERT INTO t1 VALUES (0x8000000000000000); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result index 9bd848ddea9..41760bcc40b 100644 --- a/mysql-test/main/type_newdecimal.result +++ b/mysql-test/main/type_newdecimal.result @@ -2873,5 +2873,18 @@ h varchar(16) YES NULL DROP TABLE t1, t2; SET sql_mode=DEFAULT; # +# MDEV-25174 DOUBLE columns do not accept large hex hybrids +# +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF); +INSERT INTO t1 VALUES (0x8000000000000000); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 ORDER BY a; +a +9223372036854775807 +9223372036854775808 +18446744073709551615 +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index babfb4e1db8..21e4e8ccd04 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -2050,6 +2050,17 @@ DROP TABLE t1, t2; SET sql_mode=DEFAULT; +--echo # +--echo # MDEV-25174 DOUBLE columns do not accept large hex hybrids +--echo # + +CREATE TABLE t1 (a DECIMAL(30,0)); +INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF); +INSERT INTO t1 VALUES (0x8000000000000000); +INSERT INTO t1 VALUES (0xFFFFFFFFFFFFFFFF); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/field.cc b/sql/field.cc index 3a8dc305db0..8b96c473ab6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1339,7 +1339,8 @@ int Field::store_hex_hybrid(const char *str, size_t length) goto warn; } nr= (ulonglong) longlong_from_hex_hybrid(str, length); - if ((length == 8) && !(flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX)) + if ((length == 8) && cmp_type()== INT_RESULT && + !(flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX)) { nr= LONGLONG_MAX; goto warn;