From bb42494438aa33eba06506724fea1a1485979b1f Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 7 May 2005 13:31:37 +0100 Subject: [PATCH] Bug#9725 - "disapearing query/hang" and "unknown error" with "on duplicate key update" INSERT IGNORE...UPDATE causes break in protocol or unknown error message. Fix so that protocol doesn't break by properly ignoring dups. mysql-test/r/insert_update.result: Test for Bug#9725 mysql-test/t/insert_update.test: Test for Bug#9725 sql/sql_insert.cc: Ignore the failure in update_row when IGNORE is set. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/insert_update.result | 13 +++++++++++++ mysql-test/t/insert_update.test | 12 ++++++++++++ sql/sql_insert.cc | 4 ++++ 4 files changed, 30 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 5049352c8d4..1323f7a72f1 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -13,6 +13,7 @@ administrador@light.hegel.local ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com antony@ltantony.dsl-verizon.net +antony@ltantony.mysql.com antony@ltantony.rdg.cyberkinetica.com antony@ltantony.rdg.cyberkinetica.homeunix.net arjen@bitbike.com diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index ff7ec1ba73f..f78372541f2 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -167,3 +167,16 @@ a b c VALUES(a) 2 1 11 NULL DROP TABLE t1; DROP TABLE t2; +create table t1 (a int not null unique); +insert into t1 values (1),(2); +insert ignore into t1 select 1 on duplicate key update a=2; +select * from t1; +a +1 +2 +insert ignore into t1 select a from t1 on duplicate key update a=a+1 ; +select * from t1; +a +1 +3 +drop table t1; diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index 188de8a5379..0fa366586b3 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -80,3 +80,15 @@ INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); SELECT *, VALUES(a) FROM t1; DROP TABLE t1; DROP TABLE t2; + +# +# Bug#9725 - "disapearing query/hang" and "unknown error" with "on duplicate key update" +# INSERT INGORE...UPDATE gives bad error or breaks protocol. +# +create table t1 (a int not null unique); +insert into t1 values (1),(2); +insert ignore into t1 select 1 on duplicate key update a=2; +select * from t1; +insert ignore into t1 select a from t1 on duplicate key update a=a+1 ; +select * from t1; +drop table t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 3ced5921076..a3a42ce385d 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -632,7 +632,11 @@ int write_record(TABLE *table,COPY_INFO *info) if (fill_record(*info->update_fields, *info->update_values, 0)) goto err; if ((error=table->file->update_row(table->record[1],table->record[0]))) + { + if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) + break; goto err; + } info->updated++; break; }