summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-09-02 20:56:47 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:27:29 +0200
commit8dd6ad573ce3c0bc72e2ec47f9833f6dc774cecf (patch)
tree1a51b8549496a6e8411c861b5e29e085b4d91af1
parent6079b46d8d371262882d1bbe7ebeec23b2f83075 (diff)
downloadmariadb-git-8dd6ad573ce3c0bc72e2ec47f9833f6dc774cecf.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.cc8
-rw-r--r--sql/item.h12
-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, 28 insertions, 28 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 34957a15aaf..84fb509f024 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -413,7 +413,7 @@ Item::Item(THD *thd):
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
DBUG_ASSERT(thd);
- 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;
@@ -446,7 +446,7 @@ Item::Item():
name(null_clex_str), orig_name(0), is_expensive_cache(-1)
{
DBUG_ASSERT(my_progname == NULL); // before main()
- 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;
@@ -1159,7 +1159,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];
@@ -5223,7 +5223,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 3c985d1f3bf..092fd6afcee 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -738,8 +738,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.
};
@@ -1037,8 +1037,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); }
@@ -1102,7 +1102,7 @@ public:
void share_name_with(const Item *item)
{
name= item->name;
- copy_flags(item, item_base_t::IS_AUTOGENERATED_NAME);
+ copy_flags(item, item_base_t::IS_EXPLICIT_NAME);
}
virtual void cleanup();
virtual void make_send_field(THD *thd, Send_field *field);
@@ -7480,7 +7480,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 3a08add73b7..ff71e36a5d1 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 c7f741793ec..6c98b913be5 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -5849,7 +5849,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);
@@ -5940,7 +5940,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 aed37df9c42..90a8e736460 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -993,7 +993,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 ef44b20308b..95e43ccd0e2 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -27993,7 +27993,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 ee698e51243..055fcb90a31 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 35987f08238..d971ccbf81c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9223,7 +9223,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)
@@ -10801,7 +10801,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);
}
/*