diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index c423f17f52b..dcedfcb6d84 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1791,9 +1791,10 @@ void Item_ident::print(String *str) } } - if (!table_name || !field_name) + if (!table_name || !field_name || !field_name[0]) { - const char *nm= field_name ? field_name : name ? name : "tmp_field"; + const char *nm= (field_name && field_name[0]) ? + field_name : name ? name : "tmp_field"; append_identifier(thd, str, nm, (uint) strlen(nm)); return; } @@ -5002,6 +5003,22 @@ Item *Item_field::update_value_transformer(byte *select_arg) } +void Item_field::print(String *str) +{ + if (field && field->table->const_table) + { + char buff[MAX_FIELD_WIDTH]; + String tmp(buff,sizeof(buff),str->charset()); + field->val_str(&tmp); + str->append('\''); + str->append(tmp); + str->append('\''); + return; + } + Item_ident::print(str); +} + + Item_ref::Item_ref(Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, |