From 4cf8696eae268d6595c825784a624d9146d58967 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Mon, 1 Aug 2005 17:00:03 -0700 Subject: [PATCH] Fix crash in 'INSERT DELAYED' statement that failed due to a conflict in a unique key. (Bug #12226) --- mysql-test/r/delayed.result | 7 +++++++ mysql-test/t/delayed.test | 9 +++++++++ sql/sql_insert.cc | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index e9766622cf6..f8ae61b03fb 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -32,3 +32,10 @@ a b 3 d 4 e drop table t1; +create table t1 (a int not null primary key); +insert into t1 values (1); +insert delayed into t1 values (1); +select * from t1; +a +1 +drop table t1; diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 3030ac20304..ca34cc020f3 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -38,3 +38,12 @@ select * from t1; drop table t1; # End of 4.1 tests + +# +# Bug #12226: Crash when a delayed insert fails due to a duplicate key +# +create table t1 (a int not null primary key); +insert into t1 values (1); +insert delayed into t1 values (1); +select * from t1; +drop table t1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 125390e4411..27342287fcd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1088,7 +1088,9 @@ ok_or_after_trg_err: err: info->last_errno= error; - thd->lex->current_select->no_error= 0; // Give 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: