diff options
-rw-r--r-- | mysql-test/r/func_misc.result | 6 | ||||
-rw-r--r-- | mysql-test/t/func_misc.test | 8 | ||||
-rw-r--r-- | sql/item_strfunc.h | 7 |
3 files changed, 20 insertions, 1 deletions
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 35101e26ff6..db2490bd261 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -185,4 +185,10 @@ ERROR 21000: Operand should contain 1 column(s) drop table table_26093; drop function func_26093_a; drop function func_26093_b; +create table t1 (a int not null); +insert into t1 values (-1), (-2); +select min(a) from t1 group by inet_ntoa(a); +min(a) +-2 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 8ff62f68e45..5a70daa50e8 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -189,4 +189,12 @@ drop table table_26093; drop function func_26093_a; drop function func_26093_b; +# +# Bug #31349: ERROR 1062 (23000): Duplicate entry '' for key 'group_key' +# +create table t1 (a int not null); +insert into t1 values (-1), (-2); +select min(a) from t1 group by inet_ntoa(a); +drop table t1; + --echo End of 5.0 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 6ca0b89a22b..4ffd8125422 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -683,7 +683,12 @@ public: } String* val_str(String* str); const char *func_name() const { return "inet_ntoa"; } - void fix_length_and_dec() { decimals = 0; max_length=3*8+7; } + void fix_length_and_dec() + { + decimals= 0; + max_length= 3 * 8 + 7; + maybe_null= 1; + } }; class Item_func_quote :public Item_str_func |