summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorAnurag Shekhar <anurag.shekhar@sun.com>2009-05-06 15:00:14 +0530
committerAnurag Shekhar <anurag.shekhar@sun.com>2009-05-06 15:00:14 +0530
commitb1a02aef5096ea386597bc4b7bffff5fb09c3b27 (patch)
treefa4f8d41c441672db8ddbdc5d3611990578b9255 /sql/sql_delete.cc
parent3636eab703213bde361dbd0040c205c21ee540b4 (diff)
parent69fcfa67d3a28574498b6e438fc89f0db5ba12df (diff)
downloadmariadb-git-b1a02aef5096ea386597bc4b7bffff5fb09c3b27.tar.gz
merging with local fix.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 1b42e522491..7b967206305 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -582,6 +582,11 @@ int mysql_multi_delete_prepare(THD *thd)
}
}
}
+ /*
+ Reset the exclude flag to false so it doesn't interfare
+ with further calls to unique_table
+ */
+ lex->select_lex.exclude_from_table_unique_test= FALSE;
DBUG_RETURN(FALSE);
}
@@ -617,11 +622,24 @@ multi_delete::initialize_tables(JOIN *join)
DBUG_RETURN(1);
table_map tables_to_delete_from=0;
+ delete_while_scanning= 1;
for (walk= delete_tables; walk; walk= walk->next_local)
+ {
tables_to_delete_from|= walk->table->map;
+ if (delete_while_scanning &&
+ unique_table(thd, walk, join->tables_list, false))
+ {
+ /*
+ If the table we are going to delete from appears
+ in join, we need to defer delete. So the delete
+ doesn't interfers with the scaning of results.
+ */
+ delete_while_scanning= 0;
+ }
+ }
+
walk= delete_tables;
- delete_while_scanning= 1;
for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables;
tab < end;
tab++)