diff --git a/mysql-test/main/func_misc.result b/mysql-test/main/func_misc.result index e7a416f8ea6..0ab07664e6c 100644 --- a/mysql-test/main/func_misc.result +++ b/mysql-test/main/func_misc.result @@ -1562,3 +1562,23 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is def INET_ATON("255.255.255.255.255.255.255.255") 8 21 20 Y 32928 0 63 INET_ATON("255.255.255.255.255.255.255.255") 18446744073709551615 +# +# MDEV-8049 name_const() is not consistent about its signess +# +SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2; +Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr +def c1 8 20 20 N 32929 0 63 +def c2 8 20 20 Y 32928 0 63 +c1 c2 +18446744073709551615 18446744073709551615 +CREATE TABLE t1 AS SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` bigint(20) unsigned NOT NULL, + `c2` bigint(20) unsigned DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * FROM t1; +c1 c2 +18446744073709551615 18446744073709551615 +DROP TABLE t1; diff --git a/mysql-test/main/func_misc.test b/mysql-test/main/func_misc.test index f144236bfdb..f8f2147e182 100644 --- a/mysql-test/main/func_misc.test +++ b/mysql-test/main/func_misc.test @@ -1203,3 +1203,18 @@ SELECT INET_ATON("255.255.255.255.255.255.255.255"); --enable_ps_protocol --disable_metadata + +--echo # +--echo # MDEV-8049 name_const() is not consistent about its signess +--echo # + +--enable_metadata +--disable_ps_protocol +SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2; +--enable_ps_protocol +--disable_metadata + +CREATE TABLE t1 AS SELECT 18446744073709551615 AS c1, name_const('a',18446744073709551615) AS c2; +SHOW CREATE TABLE t1; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index 11ef4e3a457..5f5b60d1eda 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2267,6 +2267,7 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) collation.set(value_item->collation.collation, DERIVATION_IMPLICIT); max_length= value_item->max_length; decimals= value_item->decimals; + unsigned_flag= value_item->unsigned_flag; fixed= 1; return FALSE; }