mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fix for bug #11314 (HAVING DEFAULT() hangs)
mysql-test/t/func_default.test: test result fixed sql/item.cc: code simplified using real_item() method, error returning added
This commit is contained in:
@@ -16,4 +16,13 @@ explain select * from t1 where str <> default(str);
|
|||||||
#show create table from t1;
|
#show create table from t1;
|
||||||
#insert into t2 select select default(str), default(strnull), default(intg), default(rel) from t1;
|
#insert into t2 select select default(str), default(strnull), default(intg), default(rel) from t1;
|
||||||
|
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #11314 (HAVING DEFAULT() hangs)
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (s varchar(20), id int(11));
|
||||||
|
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
|
||||||
|
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
14
sql/item.cc
14
sql/item.cc
@@ -4454,16 +4454,14 @@ bool Item_default_value::fix_fields(THD *thd,
|
|||||||
}
|
}
|
||||||
if (!arg->fixed && arg->fix_fields(thd, table_list, &arg))
|
if (!arg->fixed && arg->fix_fields(thd, table_list, &arg))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (arg->type() == REF_ITEM)
|
arg= arg->real_item();
|
||||||
|
if (arg->type() != FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Item_ref *ref= (Item_ref *)arg;
|
my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->name);
|
||||||
if (ref->ref[0]->type() != FIELD_ITEM)
|
return TRUE;
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
arg= ref->ref[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
field_arg= (Item_field *)arg;
|
field_arg= (Item_field *)arg;
|
||||||
if (field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)
|
if (field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user