mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge mysql.com:/home/hf/work/mrg/mysql-5.0-opt
into mysql.com:/home/hf/work/mrg/mysql-5.1-opt
This commit is contained in:
@ -468,10 +468,15 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
thd->proc_info="init";
|
||||
thd->used_tables=0;
|
||||
values= its++;
|
||||
value_count= values->elements;
|
||||
|
||||
if (mysql_prepare_insert(thd, table_list, table, fields, values,
|
||||
update_fields, update_values, duplic, &unused_conds,
|
||||
FALSE))
|
||||
FALSE,
|
||||
(fields.elements || !value_count),
|
||||
!ignore && (thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES))))
|
||||
goto abort;
|
||||
|
||||
/* mysql_prepare_insert set table_list->table if it was not set */
|
||||
@ -497,7 +502,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
table_list->next_local= 0;
|
||||
context->resolve_in_table_list_only(table_list);
|
||||
|
||||
value_count= values->elements;
|
||||
while ((values= its++))
|
||||
{
|
||||
counter++;
|
||||
@ -567,17 +571,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
table->file->ha_start_bulk_insert(values_list.elements);
|
||||
|
||||
thd->no_trans_update= 0;
|
||||
thd->abort_on_warning= (!ignore &&
|
||||
(thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES)));
|
||||
|
||||
if ((fields.elements || !value_count) &&
|
||||
check_that_all_fields_are_given_values(thd, table, table_list))
|
||||
{
|
||||
/* thd->net.report_error is now set, which will abort the next loop */
|
||||
error= 1;
|
||||
}
|
||||
thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES)));
|
||||
|
||||
table->mark_columns_needed_for_insert();
|
||||
|
||||
@ -954,6 +950,10 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list,
|
||||
be taken from table_list->table)
|
||||
where Where clause (for insert ... select)
|
||||
select_insert TRUE if INSERT ... SELECT statement
|
||||
check_fields TRUE if need to check that all INSERT fields are
|
||||
given values.
|
||||
abort_on_warning whether to report if some INSERT field is not
|
||||
assigned as an error (TRUE) or as a warning (FALSE).
|
||||
|
||||
TODO (in far future)
|
||||
In cases of:
|
||||
@ -974,7 +974,8 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
|
||||
TABLE *table, List<Item> &fields, List_item *values,
|
||||
List<Item> &update_fields, List<Item> &update_values,
|
||||
enum_duplicates duplic,
|
||||
COND **where, bool select_insert)
|
||||
COND **where, bool select_insert,
|
||||
bool check_fields, bool abort_on_warning)
|
||||
{
|
||||
SELECT_LEX *select_lex= &thd->lex->select_lex;
|
||||
Name_resolution_context *context= &select_lex->context;
|
||||
@ -1036,10 +1037,22 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
|
||||
table_list->next_local= 0;
|
||||
context->resolve_in_table_list_only(table_list);
|
||||
|
||||
if (!(res= check_insert_fields(thd, context->table_list, fields, *values,
|
||||
!insert_into_view, &map) ||
|
||||
setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0))
|
||||
&& duplic == DUP_UPDATE)
|
||||
res= check_insert_fields(thd, context->table_list, fields, *values,
|
||||
!insert_into_view, &map) ||
|
||||
setup_fields(thd, 0, *values, MARK_COLUMNS_READ, 0, 0)
|
||||
|
||||
if (!res && check_fields)
|
||||
{
|
||||
bool saved_abort_on_warning= thd->abort_on_warning;
|
||||
thd->abort_on_warning= abort_on_warning;
|
||||
res= check_that_all_fields_are_given_values(thd,
|
||||
table ? table :
|
||||
context->table_list->table,
|
||||
context->table_list);
|
||||
thd->abort_on_warning= saved_abort_on_warning;
|
||||
}
|
||||
|
||||
if (!res && duplic == DUP_UPDATE)
|
||||
{
|
||||
select_lex->no_wrap_view_item= TRUE;
|
||||
res= check_update_fields(thd, context->table_list, update_fields, &map);
|
||||
@ -2443,7 +2456,7 @@ bool mysql_insert_select_prepare(THD *thd)
|
||||
lex->query_tables->table, lex->field_list, 0,
|
||||
lex->update_list, lex->value_list,
|
||||
lex->duplicates,
|
||||
&select_lex->where, TRUE))
|
||||
&select_lex->where, TRUE, FALSE, FALSE))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
/*
|
||||
@ -2506,7 +2519,18 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
!insert_into_view, &map) ||
|
||||
setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0);
|
||||
|
||||
if (info.handle_duplicates == DUP_UPDATE)
|
||||
if (!res && fields->elements)
|
||||
{
|
||||
bool saved_abort_on_warning= thd->abort_on_warning;
|
||||
thd->abort_on_warning= !info.ignore && (thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES));
|
||||
res= check_that_all_fields_are_given_values(thd, table_list->table,
|
||||
table_list);
|
||||
thd->abort_on_warning= saved_abort_on_warning;
|
||||
}
|
||||
|
||||
if (info.handle_duplicates == DUP_UPDATE && !res)
|
||||
{
|
||||
Name_resolution_context *context= &lex->select_lex.context;
|
||||
Name_resolution_context_state ctx_state;
|
||||
@ -2617,9 +2641,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
(thd->variables.sql_mode &
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES)));
|
||||
res= ((fields->elements &&
|
||||
check_that_all_fields_are_given_values(thd, table, table_list)) ||
|
||||
table_list->prepare_where(thd, 0, TRUE) ||
|
||||
res= (table_list->prepare_where(thd, 0, TRUE) ||
|
||||
table_list->prepare_check_option(thd));
|
||||
|
||||
if (!res)
|
||||
|
Reference in New Issue
Block a user