diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index 9d244954b85..880275ec997 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -569,6 +569,24 @@ uint Item::temporal_precision(enum_field_types type_arg) } +void Item::print_parenthesised(String *str, enum_query_type query_type, + enum precedence parent_prec) +{ + bool need_parens= precedence() < parent_prec; + if (need_parens) + str->append('('); + print(str, query_type); + if (need_parens) + str->append(')'); +} + + +void Item::print(String *str, enum_query_type query_type) +{ + str->append(full_name()); +} + + void Item::print_item_w_name(String *str, enum_query_type query_type) { print(str, query_type); @@ -10462,9 +10480,11 @@ void Item::register_in(THD *thd) void Virtual_column_info::print(String *str) { - expr->print(str, (enum_query_type)(QT_ITEM_ORIGINAL_FUNC_NULLIF | + expr->print_parenthesised(str, + (enum_query_type)(QT_ITEM_ORIGINAL_FUNC_NULLIF | QT_ITEM_IDENT_SKIP_DB_NAMES | QT_ITEM_IDENT_SKIP_TABLE_NAMES | QT_ITEM_CACHE_WRAPPER_SKIP_DETAILS | - QT_TO_SYSTEM_CHARSET)); + QT_TO_SYSTEM_CHARSET), + LOWEST_PRECEDENCE); } |