diff options
author | unknown <acurtis@pcgem.rdg.cyberkinetica.com> | 2005-01-31 12:48:00 +0000 |
---|---|---|
committer | unknown <acurtis@pcgem.rdg.cyberkinetica.com> | 2005-01-31 12:48:00 +0000 |
commit | ed9f48455617b57a449861ae6fab5c9a4d759620 (patch) | |
tree | f2a7202988f5c81c96b4d87f17d111c24ba50ac9 /sql/sql_update.cc | |
parent | a88ca8f548a2e7d2ce4f992620bff508d2b9236d (diff) | |
parent | 934fde094cc092baa110dc3821e098d3d286e0c6 (diff) | |
download | mariadb-git-ed9f48455617b57a449861ae6fab5c9a4d759620.tar.gz |
Bug#7011
Merge from 4.0
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c2894a0c86b..6ca794283f1 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -464,30 +464,23 @@ 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, bool ignore, - SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) +int mysql_multi_update_lock(THD *thd, + TABLE_LIST *table_list, + List<Item> *fields, + SELECT_LEX *select_lex) { int res; - multi_update *result; TABLE_LIST *tl; TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; - List<Item> total_list; const bool using_lock_tables= thd->locked_tables != 0; bool initialized_dervied= 0; - DBUG_ENTER("mysql_multi_update"); - - select_lex->select_limit= HA_POS_ERROR; + DBUG_ENTER("mysql_multi_update_lock"); /* The following loop is here to to ensure that we only lock tables @@ -593,7 +586,7 @@ int mysql_multi_update(THD *thd, (grant_option && check_grant(thd, wants, tl, 0, 0, 0))) { tl->next= save; - DBUG_RETURN(0); + DBUG_RETURN(1); } tl->next= save; } @@ -616,11 +609,7 @@ int mysql_multi_update(THD *thd, /* Relock the tables with the correct modes */ res= lock_tables(thd, table_list, table_count); 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 @@ -651,6 +640,32 @@ 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, bool ignore, + SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) +{ + int res; + TABLE_LIST *tl; + TABLE_LIST *update_list= (TABLE_LIST*) thd->lex->select_lex.table_list.first; + List<Item> total_list; + multi_update *result; + DBUG_ENTER("mysql_multi_update"); + + if ((res= mysql_multi_update_lock(thd, table_list, fields, select_lex))) + DBUG_RETURN(res); /* Setup timestamp handling */ for (tl= update_list; tl; tl= tl->next) |