summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorunknown <acurtis@pcgem.rdg.cyberkinetica.com>2005-01-30 10:24:03 +0000
committerunknown <acurtis@pcgem.rdg.cyberkinetica.com>2005-01-30 10:24:03 +0000
commit934fde094cc092baa110dc3821e098d3d286e0c6 (patch)
treebda1004d18f8e154dab73080aead4599e04c4706 /sql/sql_update.cc
parent360d32f20120c8aebdb26dd5450cae8fbfaf81cf (diff)
downloadmariadb-git-934fde094cc092baa110dc3821e098d3d286e0c6.tar.gz
Bug#7011
Fix replication for multi-update new test - rpl_multi_update2 sql/mysql_priv.h: Bug#7011 New function mysql_multi_update_lock() sql/sql_parse.cc: Bug#7011 New function check_multi_update_lock() For multi-update on slave, perform an early open&lock sql/sql_update.cc: Bug#7011 Split out multi-update locking into its own function, mysql_multi_update_lock()
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc51
1 files changed, 33 insertions, 18 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 4f7e34ec74f..b1b30a29639 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -403,26 +403,20 @@ static table_map get_table_map(List<Item> *items)
}
-
/*
- Setup multi-update handling and call SELECT to do the join
+ Prepare tables for multi-update
+ Analyse which tables need specific privileges and perform locking
+ as required
*/
-int mysql_multi_update(THD *thd,
- TABLE_LIST *table_list,
- List<Item> *fields,
- List<Item> *values,
- COND *conds,
- ulong options,
- enum enum_duplicates handle_duplicates)
+int mysql_multi_update_lock(THD *thd,
+ TABLE_LIST *table_list,
+ List<Item> *fields)
{
int res;
- multi_update *result;
TABLE_LIST *tl;
const bool using_lock_tables= thd->locked_tables != 0;
- DBUG_ENTER("mysql_multi_update");
-
- thd->select_limit= HA_POS_ERROR;
+ DBUG_ENTER("mysql_multi_update_lock");
for (;;)
{
@@ -490,7 +484,7 @@ int mysql_multi_update(THD *thd,
(grant_option && check_grant(thd, wants, tl, 0, 0)))
{
tl->next= save;
- DBUG_RETURN(0);
+ DBUG_RETURN(1);
}
tl->next= save;
}
@@ -498,11 +492,7 @@ int mysql_multi_update(THD *thd,
/* Relock the tables with the correct modes */
res= lock_tables(thd,table_list);
if (using_lock_tables)
- {
- if (res)
- DBUG_RETURN(res);
break; // Don't have to do setup_field()
- }
/*
We must setup fields again as the file may have been reopened
@@ -535,6 +525,31 @@ int mysql_multi_update(THD *thd,
*/
close_thread_tables(thd);
}
+
+ DBUG_RETURN(res);
+}
+
+/*
+ Setup multi-update handling and call SELECT to do the join
+*/
+
+int mysql_multi_update(THD *thd,
+ TABLE_LIST *table_list,
+ List<Item> *fields,
+ List<Item> *values,
+ COND *conds,
+ ulong options,
+ enum enum_duplicates handle_duplicates)
+{
+ int res;
+ TABLE_LIST *tl;
+ multi_update *result;
+ DBUG_ENTER("mysql_multi_update");
+
+ thd->select_limit= HA_POS_ERROR;
+
+ if ((res= mysql_multi_update_lock(thd, table_list, fields)))
+ DBUG_RETURN(res);
/*
Count tables and setup timestamp handling