Commit 2419fa26 authored by unknown's avatar unknown
Browse files

Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag

This allows use to use INSERT IGNORE ... ON DUPLICATE ...


mysql-test/r/drop.result:
  safety fix
mysql-test/t/drop.test:
  safety fix
mysql-test/t/multi_update.test:
  ensure we cover all possible errors
sql/log_event.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/log_event.h:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/mysql_priv.h:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_class.h:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_delete.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_insert.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_lex.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_lex.h:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_load.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_parse.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_repl.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_repl.h:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_select.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_table.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_union.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_update.cc:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
sql/sql_yacc.yy:
  Remove DUP_IGNORE from enum_duplicates and instead use a separate ignore flag
parent 7a3ad6eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
drop table if exists t1;
drop database if exists mysqltest;
drop database if exists client_test_db;
drop table t1;
ERROR 42S02: Unknown table 't1'
create table t1(n int);
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
--disable_warnings
drop table if exists t1;
drop database if exists mysqltest;
# If earlier test failed
drop database if exists client_test_db;
--enable_warnings

--error 1051;
+2 −2
Original line number Diff line number Diff line
@@ -5,9 +5,9 @@
--disable_warnings
drop table if exists t1,t2,t3;
drop database if exists mysqltest;
--error 0,1141
--error 0,1141,1147
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
--error 0,1141
--error 0,1141,1147
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1';
--enable_warnings
+14 −10
Original line number Diff line number Diff line
@@ -1418,7 +1418,7 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
			       const char *db_arg, const char *table_name_arg,
			       List<Item> &fields_arg,
			       enum enum_duplicates handle_dup,
			       bool using_trans)
			       bool ignore, bool using_trans)
  :Log_event(thd_arg, !thd_arg->tmp_table_used ?
	     0 : LOG_EVENT_THREAD_SPECIFIC_F, using_trans),
   thread_id(thd_arg->thread_id),
@@ -1456,9 +1456,6 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
  sql_ex.empty_flags= 0;

  switch (handle_dup) {
  case DUP_IGNORE:
    sql_ex.opt_flags|= IGNORE_FLAG;
    break;
  case DUP_REPLACE:
    sql_ex.opt_flags|= REPLACE_FLAG;
    break;
@@ -1466,6 +1463,8 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
  case DUP_ERROR:
    break;	
  }
  if (ignore)
    sql_ex.opt_flags|= IGNORE_FLAG;

  if (!ex->field_term->length())
    sql_ex.empty_flags |= FIELD_TERM_EMPTY;
@@ -1791,6 +1790,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
    {
      char llbuff[22];
      enum enum_duplicates handle_dup;
      bool ignore= 0;
      /*
        Make a simplified LOAD DATA INFILE query, for the information of the
        user in SHOW PROCESSLIST. Note that db is known in the 'db' column.
@@ -1807,21 +1807,24 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
      if (sql_ex.opt_flags & REPLACE_FLAG)
	handle_dup= DUP_REPLACE;
      else if (sql_ex.opt_flags & IGNORE_FLAG)
        handle_dup= DUP_IGNORE;
      {
        ignore= 1;
        handle_dup= DUP_ERROR;
      }
      else
      {
        /*
	  When replication is running fine, if it was DUP_ERROR on the
          master then we could choose DUP_IGNORE here, because if DUP_ERROR
          master then we could choose IGNORE here, because if DUP_ERROR
          suceeded on master, and data is identical on the master and slave,
          then there should be no uniqueness errors on slave, so DUP_IGNORE is
          then there should be no uniqueness errors on slave, so IGNORE is
          the same as DUP_ERROR. But in the unlikely case of uniqueness errors
          (because the data on the master and slave happen to be different
	  (user error or bug), we want LOAD DATA to print an error message on
	  the slave to discover the problem.

          If reading from net (a 3.23 master), mysql_load() will change this
          to DUP_IGNORE.
          to IGNORE.
        */
        handle_dup= DUP_ERROR;
      }
@@ -1855,7 +1858,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
	*/
	thd->net.pkt_nr = net->pkt_nr;
      }
      if (mysql_load(thd, &ex, &tables, field_list, handle_dup, net != 0,
      if (mysql_load(thd, &ex, &tables, field_list, handle_dup, ignore, net != 0,
		     TL_WRITE))
	thd->query_error = 1;
      if (thd->cuted_fields)
@@ -2747,8 +2750,9 @@ Create_file_log_event::
Create_file_log_event(THD* thd_arg, sql_exchange* ex,
		      const char* db_arg, const char* table_name_arg,
		      List<Item>& fields_arg, enum enum_duplicates handle_dup,
                      bool ignore,
		      char* block_arg, uint block_len_arg, bool using_trans)
  :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup,
  :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup, ignore,
		  using_trans),
   fake_base(0), block(block_arg), event_buf(0), block_len(block_len_arg),
   file_id(thd_arg->file_id = mysql_bin_log.next_file_id())
+2 −2
Original line number Diff line number Diff line
@@ -599,7 +599,7 @@ class Load_log_event: public Log_event
  
  Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
		 const char* table_name_arg,
		 List<Item>& fields_arg, enum enum_duplicates handle_dup,
		 List<Item>& fields_arg, enum enum_duplicates handle_dup, bool ignore,
		 bool using_trans);
  void set_fields(const char* db, List<Item> &fields_arg);
  const char* get_db() { return db; }
@@ -908,7 +908,7 @@ class Create_file_log_event: public Load_log_event
  Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
			const char* table_name_arg,
			List<Item>& fields_arg,
			enum enum_duplicates handle_dup,
			enum enum_duplicates handle_dup, bool ignore,
			char* block_arg, uint block_len_arg,
			bool using_trans);
#ifdef HAVE_REPLICATION
Loading