summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <sasha@asksasha.com>2005-09-14 06:37:52 -0600
committerunknown <sasha@asksasha.com>2005-09-14 06:37:52 -0600
commit3be8c9074a8f65bfe82ed218b64f989da295f674 (patch)
tree9429b2253660211c1617ac89d98074c61fe2e785 /sql/sql_parse.cc
parent02fce1c316e7a33748eb7ccf13a49fbaa2926ee6 (diff)
parentf89424f8b69d50fb26c0af3d226ac20afe2a32da (diff)
downloadmariadb-git-3be8c9074a8f65bfe82ed218b64f989da295f674.tar.gz
Merge spachev@bk-internal.mysql.com:/home/bk/mysql-4.1
into asksasha.com:/reiser-data/mysql-dev/mysql-4.1-bug11139 sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc50
1 files changed, 39 insertions, 11 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 131fe3d691d..a2df59e56c7 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -59,6 +59,9 @@ static void remove_escape(char *name);
static void refresh_status(void);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name);
+
+static TABLE_LIST* get_table_by_alias(TABLE_LIST* tl, const char* db,
+ const char* alias);
const char *any_db="*any*"; // Special symbol for check_access
@@ -125,10 +128,7 @@ static bool end_active_trans(THD *thd)
*/
inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables)
{
- return (table_rules_on && tables && !tables_ok(thd,tables) &&
- ((thd->lex->sql_command != SQLCOM_DELETE_MULTI) ||
- !tables_ok(thd,
- (TABLE_LIST *)thd->lex->auxilliary_table_list.first)));
+ return (table_rules_on && tables && !tables_ok(thd,tables));
}
#endif
@@ -4245,6 +4245,40 @@ void create_select_for_variable(const char *var_name)
DBUG_VOID_RETURN;
}
+static TABLE_LIST* get_table_by_alias(TABLE_LIST* tl, const char* db,
+ const char* alias)
+{
+ for (;tl;tl= tl->next)
+ {
+ if (!strcmp(db,tl->db) &&
+ tl->alias && !my_strcasecmp(table_alias_charset,tl->alias,alias))
+ return tl;
+ }
+
+ return 0;
+}
+
+/* Sets up lex->auxilliary_table_list */
+void fix_multi_delete_lex(LEX* lex)
+{
+ TABLE_LIST *tl;
+ TABLE_LIST *good_list= (TABLE_LIST*)lex->select_lex.table_list.first;
+
+ for (tl= (TABLE_LIST*)lex->auxilliary_table_list.first; tl; tl= tl->next)
+ {
+ TABLE_LIST* good_table= get_table_by_alias(good_list,tl->db,tl->alias);
+ if (good_table && !good_table->derived)
+ {
+ /*
+ real_name points to a member of Table_ident which is
+ allocated via thd->strmake() from THD memroot
+ */
+ tl->real_name= good_table->real_name;
+ tl->real_name_length= good_table->real_name_length;
+ good_table->updating= tl->updating;
+ }
+ }
+}
void mysql_init_multi_delete(LEX *lex)
{
@@ -5567,13 +5601,7 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
(*table_count)++;
/* All tables in aux_tables must be found in FROM PART */
TABLE_LIST *walk;
- for (walk= delete_tables; walk; walk= walk->next)
- {
- if (!my_strcasecmp(table_alias_charset,
- target_tbl->alias, walk->alias) &&
- !strcmp(walk->db, target_tbl->db))
- break;
- }
+ walk= get_table_by_alias(delete_tables,target_tbl->db,target_tbl->alias);
if (!walk)
{
my_error(ER_UNKNOWN_TABLE, MYF(0), target_tbl->real_name,