1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00
Merge from 4.0
This commit is contained in:
acurtis@pcgem.rdg.cyberkinetica.com
2005-01-31 12:48:00 +00:00
6 changed files with 196 additions and 20 deletions

View File

@ -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)