diff options
author | Michael Widenius <monty@askmonty.org> | 2011-12-11 19:28:05 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-12-11 19:28:05 +0200 |
commit | 24e452a208adebedce6a8a418265fced66bfb027 (patch) | |
tree | 83bc0c6e237fbd9f9dcbd2ac79f03a3b86756239 /sql/sql_insert.cc | |
parent | 8a09adb3eaf036b652b11afea7d9d86a978fa566 (diff) | |
parent | 148587461954b544355bc808a89bfed1a70694e1 (diff) | |
download | mariadb-git-24e452a208adebedce6a8a418265fced66bfb027.tar.gz |
Merge with 5.1 & fixes to IGNORE handling
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index cf199c27518..d01a594708e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,4 +1,5 @@ -/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc. +/* + Copyright (c) 2000, 2011, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,8 +12,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ /* Insert of records */ @@ -62,6 +63,8 @@ #include "slave.h" #include "rpl_mi.h" +#include "debug_sync.h" + #ifndef EMBEDDED_LIBRARY static bool delayed_get_table(THD *thd, TABLE_LIST *table_list); static int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, @@ -662,7 +665,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, lock_type= table_list->lock_type; thd_proc_info(thd, "init"); - thd->used_tables=0; + thd->lex->used_tables=0; values= its++; value_count= values->elements; @@ -813,7 +816,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } else { - if (thd->used_tables) // Column used in values() + if (thd->lex->used_tables) // Column used in values() restore_record(table,s->default_values); // Get empty record else { @@ -1481,6 +1484,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) error= HA_ERR_FOUND_DUPP_KEY; /* Database can't find key */ goto err; } + DEBUG_SYNC(thd, "write_row_replace"); + /* Read all columns for the row we are going to replace */ table->use_all_columns(); /* @@ -1574,11 +1579,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) else error= 0; /* - If ON DUP KEY UPDATE updates a row instead of inserting one, it's - like a regular UPDATE statement: it should not affect the value of a - next SELECT LAST_INSERT_ID() or mysql_insert_id(). - Except if LAST_INSERT_ID(#) was in the INSERT query, which is - handled separately by THD::arg_of_last_insert_id_function. + If ON DUP KEY UPDATE updates a row instead of inserting + one, it's like a regular UPDATE statement: it should not + affect the value of a next SELECT LAST_INSERT_ID() or + mysql_insert_id(). Except if LAST_INSERT_ID(#) was in the + INSERT query, which is handled separately by + THD::arg_of_last_insert_id_function. */ insert_id_for_cur_row= table->file->insert_id_for_cur_row= 0; trg_error= (table->triggers && @@ -1655,11 +1661,12 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } /* - If more than one iteration of the above while loop is done, from the second - one the row being inserted will have an explicit value in the autoinc field, - which was set at the first call of handler::update_auto_increment(). This - value is saved to avoid thd->insert_id_for_cur_row becoming 0. Use this saved - autoinc value. + If more than one iteration of the above while loop is done, from + the second one the row being inserted will have an explicit + value in the autoinc field, which was set at the first call of + handler::update_auto_increment(). This value is saved to avoid + thd->insert_id_for_cur_row becoming 0. Use this saved autoinc + value. */ if (table->file->insert_id_for_cur_row == 0) table->file->insert_id_for_cur_row= insert_id_for_cur_row; @@ -1675,6 +1682,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) } else if ((error=table->file->ha_write_row(table->record[0]))) { + DEBUG_SYNC(thd, "write_row_noreplace"); if (!info->ignore || table->file->is_fatal_error(error, HA_CHECK_DUP)) goto err; @@ -1698,9 +1706,6 @@ ok_or_after_trg_err: err: info->last_errno= error; - /* current_select is NULL if this is a delayed insert */ - if (thd->lex->current_select) - thd->lex->current_select->no_error= 0; // Give error table->file->print_error(error,MYF(0)); before_trg_err: @@ -3072,8 +3077,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) */ lex->current_select= &lex->select_lex; - /* Errors during check_insert_fields() should not be ignored. */ - lex->current_select->no_error= FALSE; res= (setup_fields(thd, 0, values, MARK_COLUMNS_READ, 0, 0) || check_insert_fields(thd, table_list, *fields, values, !insert_into_view, 1, &map)); @@ -3898,7 +3901,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) if (table->s->fields < values.elements) { - my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1); + my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), 1L); DBUG_RETURN(-1); } |