summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-09-02 20:56:47 +0300
committerMonty <monty@mariadb.org>2021-01-19 20:17:45 +0200
commit1b86a41391dd01a3df830f4292b742f206474e05 (patch)
tree2b923ab5057d7ca5496c835b47ee5d12c9cea1d7
parentb45380e159c2a0a52684c1bacef0148ff89aff93 (diff)
downloadmariadb-git-1b86a41391dd01a3df830f4292b742f206474e05.tar.gz
Replaced base_flags_t::IS_AUTOGENERATED_NAME with IS_EXPLICT_NAME
The name change was to make the intention of the flag more clear and also because most usage of the old flag was to test for NOT IS_AUTOGENERATED_NAME. Note that the new flag is the inverse of the old one!
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item.h10
-rw-r--r--sql/item_create.cc14
-rw-r--r--sql/sql_base.cc4
-rw-r--r--sql/sql_cte.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_view.cc10
-rw-r--r--sql/sql_yacc.yy4
8 files changed, 26 insertions, 26 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 539ffabbe17..8e9d076d3a1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -412,7 +412,7 @@ int Item::save_str_value_in_field(Field *field, String *result)
Item::Item(THD *thd):
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
- base_flags= item_base_t::FIXED | item_base_t::IS_AUTOGENERATED_NAME;
+ base_flags= item_base_t::FIXED;
with_flags= item_with_t::NONE;
null_value= 0;
marker= 0;
@@ -1146,7 +1146,7 @@ void Item::set_name(THD *thd, const char *str, size_t length, CHARSET_INFO *cs)
str++;
}
}
- if (str != str_start && !is_autogenerated_name())
+ if (str != str_start && is_explicit_name())
{
char buff[SAFE_NAME_LEN];
@@ -5209,7 +5209,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
/* SELECT list element with explicit alias */
if ((*(cur_group->item))->name.str && !table_name.str &&
- !(*(cur_group->item))->is_autogenerated_name() &&
+ (*(cur_group->item))->is_explicit_name() &&
!lex_string_cmp(system_charset_info,
&(*(cur_group->item))->name, &field_name))
{
diff --git a/sql/item.h b/sql/item.h
index beda47f87fa..31df4f19edd 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -730,8 +730,8 @@ enum class item_base_t : item_flags_t
IN_ROLLUP= (1<<1), // Appears in GROUP BY list
// of a query with ROLLUP.
FIXED= (1<<2), // Was fixed with fix_fields().
- IS_AUTOGENERATED_NAME= (1<<3), // The name if this Item was
- // generated or set by the user.
+ IS_EXPLICIT_NAME= (1<<3), // The name of this Item was set by the user
+ // (or was auto generated otherwise)
IS_IN_WITH_CYCLE= (1<<4) // This item is in CYCLE clause
// of WITH.
};
@@ -1029,8 +1029,8 @@ public:
{ return (bool) (base_flags & item_base_t::IN_ROLLUP); }
inline bool fixed() const
{ return (bool) (base_flags & item_base_t::FIXED); }
- inline bool is_autogenerated_name() const
- { return (bool) (base_flags & item_base_t::IS_AUTOGENERATED_NAME); }
+ inline bool is_explicit_name() const
+ { return (bool) (base_flags & item_base_t::IS_EXPLICIT_NAME); }
inline bool is_in_with_cycle() const
{ return (bool) (base_flags & item_base_t::IS_IN_WITH_CYCLE); }
@@ -7375,7 +7375,7 @@ public:
Type_std_attributes::set(*attr);
set_maybe_null(maybe_null_arg);
copy_flags(item,
- item_base_t::IS_AUTOGENERATED_NAME |
+ item_base_t::IS_EXPLICIT_NAME |
item_base_t::IS_IN_WITH_CYCLE);
}
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 62f4d9f9fee..41bb749307c 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -2387,7 +2387,7 @@ static bool has_named_parameters(List<Item> *params)
List_iterator<Item> it(*params);
while ((param= it++))
{
- if (! param->is_autogenerated_name())
+ if (param->is_explicit_name())
return true;
}
}
@@ -2633,7 +2633,7 @@ Create_func_arg1::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop();
- if (unlikely(! param_1->is_autogenerated_name()))
+ if (unlikely(param_1->is_explicit_name()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -2660,8 +2660,8 @@ Create_func_arg2::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_1= item_list->pop();
Item *param_2= item_list->pop();
- if (unlikely(!param_1->is_autogenerated_name() ||
- !param_2->is_autogenerated_name()))
+ if (unlikely(param_1->is_explicit_name() ||
+ param_2->is_explicit_name()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
@@ -2689,9 +2689,9 @@ Create_func_arg3::create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list
Item *param_2= item_list->pop();
Item *param_3= item_list->pop();
- if (unlikely(!param_1->is_autogenerated_name() ||
- !param_2->is_autogenerated_name() ||
- !param_3->is_autogenerated_name()))
+ if (unlikely(param_1->is_explicit_name() ||
+ param_2->is_explicit_name() ||
+ param_3->is_explicit_name()))
{
my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name->str);
return NULL;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8acf93f1bfb..b9e77a56285 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5807,7 +5807,7 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
replace. If the item was aliased by the user, set the alias to
the replacing item.
*/
- if (*ref && !(*ref)->is_autogenerated_name())
+ if (*ref && (*ref)->is_explicit_name())
item->set_name(thd, (*ref)->name);
if (register_tree_change)
thd->change_item_tree(ref, item);
@@ -5898,7 +5898,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, si
replace. If the item was aliased by the user, set the alias to
the replacing item.
*/
- if (*ref && !(*ref)->is_autogenerated_name())
+ if (*ref && (*ref)->is_explicit_name())
item->set_name(thd, (*ref)->name);
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index faa2b424f12..e9d3579434e 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -992,7 +992,7 @@ With_element::process_columns_of_derived_unit(THD *thd,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
+ item->base_flags|= item_base_t::IS_EXPLICIT_NAME;
}
if (arena)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 881eaa034ee..675c314b277 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -27658,7 +27658,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
else
str->append(',');
- if (is_subquery_function() && item->is_autogenerated_name())
+ if (is_subquery_function() && !item->is_explicit_name())
{
/*
Do not print auto-generated aliases in subqueries. It has no purpose
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index dd41cfd3e84..8ed03c23f8e 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -137,7 +137,7 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
Item *check;
/* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM)
- item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
+ item->base_flags|= item_base_t::IS_EXPLICIT_NAME;
itc.rewind();
while ((check= itc++) && check != item)
{
@@ -145,9 +145,9 @@ bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view
{
if (!gen_unique_view_name)
goto err;
- if (item->is_autogenerated_name())
+ if (!item->is_explicit_name())
make_unique_view_field_name(thd, item, item_list, item);
- else if (check->is_autogenerated_name())
+ else if (!check->is_explicit_name())
make_unique_view_field_name(thd, check, item_list, item);
else
goto err;
@@ -179,7 +179,7 @@ void make_valid_column_names(THD *thd, List<Item> &item_list)
for (uint column_no= 1; (item= it++); column_no++)
{
- if (!item->is_autogenerated_name() || !check_column_name(item->name.str))
+ if (item->is_explicit_name() || !check_column_name(item->name.str))
continue;
name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no);
item->orig_name= item->name.str;
@@ -566,7 +566,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
while ((item= it++, name= nm++))
{
item->set_name(thd, *name);
- item->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
+ item->base_flags|= item_base_t::IS_EXPLICIT_NAME;
}
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d9b28610748..31c813342cf 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9154,7 +9154,7 @@ select_item:
if (unlikely(Lex->sql_command == SQLCOM_CREATE_VIEW &&
check_column_name($4.str)))
my_yyabort_error((ER_WRONG_COLUMN_NAME, MYF(0), $4.str));
- $2->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
+ $2->base_flags|= item_base_t::IS_EXPLICIT_NAME;
$2->set_name(thd, $4);
}
else if (!$2->name.str || $2->name.str == item_empty_name)
@@ -10732,7 +10732,7 @@ udf_expr:
*/
if ($4.str)
{
- $2->base_flags&= ~item_base_t::IS_AUTOGENERATED_NAME;
+ $2->base_flags|= item_base_t::IS_EXPLICIT_NAME;
$2->set_name(thd, $4);
}
/*