diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 70fb5acdffd..7bdc6873e6f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -61,7 +61,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc); static void decrease_user_connections(USER_CONN *uc); static bool check_db_used(THD *thd,TABLE_LIST *tables); static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables); -static bool check_dup(const char *db, const char *name, TABLE_LIST *tables); static void remove_escape(char *name); static void refresh_status(void); static bool append_file_to_dir(THD *thd, char **filename_ptr, @@ -1645,7 +1644,7 @@ mysql_execute_command(THD *thd) select_result *result; if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && - check_dup(tables->db, tables->real_name, tables->next)) + find_real_table_in_list(tables->next, tables->db, tables->real_name)) { net_printf(thd,ER_INSERT_TABLE_USED,tables->real_name); DBUG_VOID_RETURN; @@ -2007,7 +2006,7 @@ mysql_execute_command(THD *thd) if (unit->select_limit_cnt < select_lex->select_limit) unit->select_limit_cnt= HA_POS_ERROR; // No limit - if (check_dup(tables->db, tables->real_name, tables->next)) + if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) { net_printf(thd,ER_INSERT_TABLE_USED,tables->real_name); DBUG_VOID_RETURN; @@ -2100,6 +2099,17 @@ mysql_execute_command(THD *thd) /* Fix tables-to-be-deleted-from list to point at opened tables */ for (auxi=(TABLE_LIST*) aux_tables ; auxi ; auxi=auxi->next) auxi->table= auxi->table_list->table; + if (&lex->select_lex != lex->all_selects_list) + for (TABLE_LIST *t= select_lex->get_table_list(); + t; t= t->next) + { + if (find_real_table_in_list(t->table_list->next, t->db, t->real_name)) + { + my_error(ER_INSERT_TABLE_USED, MYF(0), t->real_name); + res= -1; + break; + } + } fix_tables_pointers(lex->all_selects_list); if (!thd->fatal_error && (result= new multi_delete(thd,aux_tables, table_count))) @@ -3521,16 +3531,6 @@ void add_join_natural(TABLE_LIST *a,TABLE_LIST *b) b->natural_join=a; } - /* Check if name is used in table list */ - -static bool check_dup(const char *db, const char *name, TABLE_LIST *tables) -{ - for (; tables ; tables=tables->next) - if (!strcmp(name,tables->real_name) && !strcmp(db,tables->db)) - return 1; - return 0; -} - bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables) { bool result=0; |