1
0
mirror of https://github.com/MariaDB/server.git synced 2025-06-13 13:01:51 +03:00
This commit is contained in:
bell@sanja.is.com.ua
2004-10-05 13:41:51 +03:00
51 changed files with 1292 additions and 259 deletions

View File

@ -2756,18 +2756,29 @@ unsent_create_error:
lex->duplicates);
if (thd->net.report_error)
res= -1;
break;
if (res != 2)
break;
case SQLCOM_UPDATE_MULTI:
{
bool converted= 0;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
if ((res= multi_update_precheck(thd, all_tables)))
break;
if (res != 2)
{
if ((res= multi_update_precheck(thd, all_tables)))
break;
}
else
{
res= 0;
converted= 1;
}
res= mysql_multi_update(thd, all_tables,
&select_lex->item_list,
&lex->value_list,
select_lex->where,
select_lex->options,
lex->duplicates, unit, select_lex);
lex->duplicates, unit, select_lex,
converted);
break;
}
case SQLCOM_REPLACE:
@ -2805,35 +2816,28 @@ unsent_create_error:
if (!(res= open_and_lock_tables(thd, all_tables)))
{
/*
Is table which we are changing used somewhere in other parts of
query
*/
if (unique_table(first_table, all_tables->next_independent()))
{
/* Using same table for INSERT and SELECT */
select_lex->options |= OPTION_BUFFER_RESULT;
}
/* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*)first_table->next_local;
if ((res= mysql_insert_select_prepare(thd)))
break;
if ((result= new select_insert(first_table, first_table->table,
&lex->field_list, lex->duplicates,
lex->duplicates == DUP_IGNORE)))
res= mysql_insert_select_prepare(thd);
if (!res && (result= new select_insert(first_table, first_table->table,
&lex->field_list,
lex->duplicates,
lex->duplicates == DUP_IGNORE)))
{
/* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*) first_table->next_local;
TABLE_LIST *first_select_table;
/*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
lex->select_lex.resolve_mode= SELECT_LEX::SELECT_MODE;
res= handle_select(thd, lex, result);
/* revert changes for SP */
lex->select_lex.table_list.first= (byte*) first_table;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
delete result;
}
/* revert changes for SP */
lex->select_lex.table_list.first= (byte*) first_table;
if (thd->net.report_error)
res= -1;
}
@ -2897,6 +2901,16 @@ unsent_create_error:
if ((res= open_and_lock_tables(thd, all_tables)))
break;
if (!first_table->table)
{
DBUG_ASSERT(first_table->view &&
first_table->ancestor && first_table->ancestor->next_local);
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
first_table->view_db.str, first_table->view_name.str);
res= -1;
break;
}
if ((res= mysql_multi_delete_prepare(thd)))
break;
@ -4366,7 +4380,7 @@ mysql_init_query(THD *thd, uchar *buf, uint length, bool lexonly)
lex->found_colon= 0;
lex->safe_to_cache_query= 1;
lex->time_zone_tables_used= 0;
lex->proc_table= lex->query_tables= 0;
lex->leaf_tables_insert= lex->proc_table= lex->query_tables= 0;
lex->query_tables_last= &lex->query_tables;
lex->variables_used= 0;
lex->select_lex.parent_lex= lex;