summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc18
1 files changed, 6 insertions, 12 deletions
diff --git a/sql/item.cc b/sql/item.cc
index a6b4402b6ba..47e10ba4004 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1952,7 +1952,12 @@ bool Item_name_const::is_null()
Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val):
Item_fixed_hybrid(thd), value_item(val), name_item(name_arg)
{
+ StringBuffer<128> name_buffer;
+ String *name_str;
Item::maybe_null= TRUE;
+ if (name_item->basic_const_item() &&
+ (name_str= name_item->val_str(&name_buffer))) // Can't have a NULL name
+ set_name(thd, name_str->ptr(), name_str->length(), name_str->charset());
}
@@ -1988,25 +1993,14 @@ Item::Type Item_name_const::type() const
bool Item_name_const::fix_fields(THD *thd, Item **ref)
{
- char buf[128];
- String *item_name;
- String s(buf, sizeof(buf), &my_charset_bin);
- s.length(0);
-
if (value_item->fix_fields_if_needed(thd, &value_item) ||
name_item->fix_fields_if_needed(thd, &name_item) ||
!value_item->const_item() ||
- !name_item->const_item() ||
- !(item_name= name_item->val_str(&s))) // Can't have a NULL name
+ !name_item->const_item())
{
my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST");
return TRUE;
}
- if (is_autogenerated_name)
- {
- set_name(thd, item_name->c_ptr(), (uint) item_name->length(),
- system_charset_info);
- }
if (value_item->collation.derivation == DERIVATION_NUMERIC)
collation.set_numeric();
else