summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <tnurnberg@white.intern.koehntopp.de>2008-03-10 07:07:56 +0100
committerunknown <tnurnberg@white.intern.koehntopp.de>2008-03-10 07:07:56 +0100
commit111de516ab972f076f5b6ec2399874391bfeb473 (patch)
tree51f2d1b0305bb5e58ebf2fe09ba255c8efdd44e2 /sql/item.cc
parent4a8c442f040db67763697df8f109f79ec6240979 (diff)
parenta0eec8abbb233d9e3f278d343eaed2e70b55161e (diff)
downloadmariadb-git-111de516ab972f076f5b6ec2399874391bfeb473.tar.gz
Merge mysql.com:/misc/mysql/34749/50-34749
into mysql.com:/misc/mysql/34749/51-34749 mysql-test/r/func_misc.result: Auto merged mysql-test/t/func_misc.test: Auto merged sql/ha_ndbcluster_cond.cc: Auto merged sql/ha_ndbcluster_cond.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_func.h: Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 34f6eb9dc61..827b6330a07 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1238,6 +1238,22 @@ bool Item_name_const::is_null()
return value_item->is_null();
}
+
+Item_name_const::Item_name_const(Item *name_arg, Item *val):
+ value_item(val), name_item(name_arg)
+{
+ if (!(valid_args= name_item->basic_const_item() &&
+ (value_item->basic_const_item() ||
+ ((value_item->type() == FUNC_ITEM) &&
+ (((Item_func *) value_item)->functype() ==
+ Item_func::NEG_FUNC) &&
+ (((Item_func *) value_item)->key_item()->type() !=
+ FUNC_ITEM)))))
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
+ Item::maybe_null= TRUE;
+}
+
+
Item::Type Item_name_const::type() const
{
/*
@@ -1249,8 +1265,17 @@ Item::Type Item_name_const::type() const
if (item->type() == FIELD_ITEM)
((Item_field *) item)->...
we return NULL_ITEM in the case to avoid wrong casting.
+
+ valid_args guarantees value_item->basic_const_item(); if type is
+ FUNC_ITEM, then we have a fudged item_func_neg() on our hands
+ and return the underlying type.
*/
- return valid_args ? value_item->type() : NULL_ITEM;
+ return valid_args ?
+ (((value_item->type() == FUNC_ITEM) &&
+ (((Item_func *) value_item)->functype() == Item_func::NEG_FUNC)) ?
+ ((Item_func *) value_item)->key_item()->type() :
+ value_item->type()) :
+ NULL_ITEM;
}