summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-06-14 17:43:51 +0500
committerunknown <hf@deer.(none)>2005-06-14 17:43:51 +0500
commit0473ce99fa1f9ed6ab2f37a3b043013dcd38c53e (patch)
tree7c282b77876ef0ab3ed7b6a25adad2ed6a5cdd44
parentff40f3034917957fef5bb7f80e556d4835bc3410 (diff)
downloadmariadb-git-0473ce99fa1f9ed6ab2f37a3b043013dcd38c53e.tar.gz
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
-rw-r--r--mysql-test/t/func_default.test11
-rw-r--r--sql/item.cc14
2 files changed, 16 insertions, 9 deletions
diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test
index 6ae9f088f92..963d069fdd2 100644
--- a/mysql-test/t/func_default.test
+++ b/mysql-test/t/func_default.test
@@ -16,4 +16,13 @@ explain select * from t1 where str <> default(str);
#show create table from t1;
#insert into t2 select select default(str), default(strnull), default(intg), default(rel) from t1;
-drop table t1; \ No newline at end of file
+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;
+
diff --git a/sql/item.cc b/sql/item.cc
index 680b771f908..5be43f3137d 100644
--- a/sql/item.cc
+++ b/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))
return TRUE;
-
- if (arg->type() == REF_ITEM)
+
+ arg= arg->real_item();
+ if (arg->type() != FIELD_ITEM)
{
- Item_ref *ref= (Item_ref *)arg;
- if (ref->ref[0]->type() != FIELD_ITEM)
- {
- return TRUE;
- }
- arg= ref->ref[0];
+ my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), arg->name);
+ return TRUE;
}
+
field_arg= (Item_field *)arg;
if (field_arg->field->flags & NO_DEFAULT_VALUE_FLAG)
{