summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger.test
diff options
context:
space:
mode:
authorMartin Hansson <martin.hansson@sun.com>2009-06-22 14:51:33 +0200
committerMartin Hansson <martin.hansson@sun.com>2009-06-22 14:51:33 +0200
commit543885d1b1402bea2475ad76161de5a62929e8c2 (patch)
tree975e56055845ed8efe4d6a0af0dc9aecb836ea58 /mysql-test/t/trigger.test
parenteac6619ff00ef2c13f30eb5bfb894857b10e4bc0 (diff)
downloadmariadb-git-543885d1b1402bea2475ad76161de5a62929e8c2.tar.gz
Bug#44653: Server crash noticed when executing random queries with partitions.
When opening a table, it is imperative that the flag TABLE::auto_increment_field_not_null be false. But if an error occured during the creation of a table (e.g. the table exists already) with an auto_increment column and a BEFORE trigger that used the INSERT ... SELECT construct, the flag was not reset until after error checking. Thus if an error occured, select_insert::send_data() returned immediately and it was not reset (see * in pseudocode below). Crash happened if the table was opened again. Fixed by resetting the flag after error checking. nested-loops_join(): for each row in SELECT table { select_insert::send_data(): if a values is supplied for AUTO_INCREMENT column table->auto_increment_field_not_null= TRUE else table->auto_increment_field_not_null= FALSE if (error) return 1; * if (table->auto_increment_field_not_null == FALSE) ... table->auto_increment_field_not_null == FALSE } <-- table returned to table cache and later retrieved by open_table: open_table(): assert(table->auto_increment_field_not_null) mysql-test/r/trigger.result: Bug#44653: Test result mysql-test/t/trigger.test: Bug#44653: Test case sql/sql_insert.cc: Bug#44653: Fix: Make sure to unset this field before returning in case of error
Diffstat (limited to 'mysql-test/t/trigger.test')
-rw-r--r--mysql-test/t/trigger.test26
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 9a5556c518d..1e55f9d5993 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -2370,4 +2370,30 @@ drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
+#
+# Bug#44653: Server crash noticed when executing random queries with partitions.
+#
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+
+INSERT INTO t1 (a) VALUES (1);
+
+delimiter //;
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW
+BEGIN
+ UPDATE a_nonextisting_table SET a = 1;
+END//
+delimiter ;//
+
+--disable_abort_on_error
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+--enable_abort_on_error
+
+# Caused failed assertion
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
--echo End of 5.1 tests.