summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagne Mahre <magne.mahre@sun.com>2009-11-18 10:32:03 +0100
committerMagne Mahre <magne.mahre@sun.com>2009-11-18 10:32:03 +0100
commit3987c7ac4b7ecfde471c10386bb413205809dfe1 (patch)
tree1ada061831543d420f8600738954bcf6ff60f1d6
parenteb7bfcac405045541a4fc156e9c34a448d4dd128 (diff)
downloadmariadb-git-3987c7ac4b7ecfde471c10386bb413205809dfe1.tar.gz
Bug #46425 crash in Diagnostics_area::set_ok_status , empty statement,
DELETE IGNORE The ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG error was set in the diagnostics area when it happened, but the DELETE cleanup code never checked for a non-fatal error condition, thus trying to set diag.area to "ok". This triggered an assert checking that the diag.area was empty. The fix was to test if there existed a non-fatal error condition (thd->is_error() before ok'ing the operation.
-rw-r--r--mysql-test/r/delete.result13
-rw-r--r--mysql-test/t/delete.test22
-rw-r--r--sql/sql_delete.cc3
3 files changed, 37 insertions, 1 deletions
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index 0124a7da35a..1df19a75854 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -324,3 +324,16 @@ a
1
2
DROP TABLE t1, t2, t3;
+#
+# Bug #46425 crash in Diagnostics_area::set_ok_status,
+# empty statement, DELETE IGNORE
+#
+CREATE table t1 (i INTEGER);
+INSERT INTO t1 VALUES (1);
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+INSERT INTO t1 SELECT * FROM t1 AS A;
+END |
+DELETE IGNORE FROM t1;
+ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
+DROP TABLE t1;
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index d77f5eb128b..a5dff38c078 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -336,3 +336,25 @@ SELECT * FROM t2;
SELECT * FROM t3;
DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # Bug #46425 crash in Diagnostics_area::set_ok_status,
+--echo # empty statement, DELETE IGNORE
+--echo #
+
+CREATE table t1 (i INTEGER);
+
+INSERT INTO t1 VALUES (1);
+
+--delimiter |
+
+CREATE TRIGGER tr1 AFTER DELETE ON t1 FOR EACH ROW
+BEGIN
+ INSERT INTO t1 SELECT * FROM t1 AS A;
+END |
+
+--delimiter ;
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+DELETE IGNORE FROM t1;
+
+DROP TABLE t1; \ No newline at end of file
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index b80138af7f2..93b19c5b233 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -426,7 +426,8 @@ cleanup:
}
DBUG_ASSERT(transactional_table || !deleted || thd->transaction.stmt.modified_non_trans_table);
free_underlaid_joins(thd, select_lex);
- if (error < 0 || (thd->lex->ignore && !thd->is_fatal_error))
+ if (error < 0 ||
+ (thd->lex->ignore && !thd->is_error() && !thd->is_fatal_error))
{
/*
If a TRUNCATE TABLE was issued, the number of rows should be reported as