summaryrefslogtreecommitdiff
path: root/sql/sql_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r--sql/sql_view.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 0a4d26c3a95..c8abee1e7dc 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -58,13 +58,13 @@ static void make_unique_view_field_name(Item *target,
char *name= (target->orig_name ?
target->orig_name :
target->name);
- uint name_len;
- uint attempt= 0;
+ uint name_len, attempt;
char buff[NAME_LEN+1];
- for (;; attempt++)
+ List_iterator_fast<Item> itc(item_list);
+
+ for (attempt= 0;; attempt++)
{
Item *check;
- List_iterator_fast<Item> itc(item_list);
bool ok= TRUE;
if (attempt)
@@ -84,6 +84,7 @@ static void make_unique_view_field_name(Item *target,
} while (check != last_element);
if (ok)
break;
+ itc.rewind();
}
target->orig_name= target->name;
@@ -305,13 +306,14 @@ bool mysql_create_view(THD *thd,
{
Item *item;
List_iterator_fast<Item> it(select_lex->item_list);
+ List_iterator_fast<Item> itc(select_lex->item_list);
while ((item= it++))
{
Item *check;
- List_iterator_fast<Item> itc(select_lex->item_list);
/* treat underlying fields like set by user names */
if (item->real_item()->type() == Item::FIELD_ITEM)
item->is_autogenerated_name= FALSE;
+ itc.rewind();
while ((check= itc++) && check != item)
{
if (my_strcasecmp(system_charset_info, item->name, check->name) == 0)
@@ -822,6 +824,7 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
old_lex->can_use_merged()) &&
!old_lex->can_not_use_merged())
{
+ List_iterator_fast<TABLE_LIST> ti(view_select->top_join_list);
/* lex should contain at least one table */
DBUG_ASSERT(view_tables != 0);
@@ -865,13 +868,11 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
nested_join->join_list= view_select->top_join_list;
/* re-nest tables of VIEW */
+ ti.rewind();
+ while ((tbl= ti++))
{
- List_iterator_fast<TABLE_LIST> ti(nested_join->join_list);
- while ((tbl= ti++))
- {
- tbl->join_list= &nested_join->join_list;
- tbl->embedding= table;
- }
+ tbl->join_list= &nested_join->join_list;
+ tbl->embedding= table;
}
}