#At file:///data0/martin/bzr/bug44653/5.1bt-gca-commit/ based on revid:davi.arnaut@stripped
2936 Martin Hansson 2009-06-19
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, the
function returned immediately and it was not done. Crash happened if the table
was opened again. Fixed by resetting the flag before error checking.
@ 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 set this field before returning in case of error
modified:
mysql-test/r/trigger.result
mysql-test/t/trigger.test
sql/sql_insert.cc
=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result 2009-03-27 12:55:14 +0000
+++ b/mysql-test/r/trigger.result 2009-06-19 09:33:49 +0000
@@ -2073,4 +2073,18 @@ select @a, @b;
drop trigger trg1;
drop trigger trg2;
drop table t1, t2;
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY, b INT );
+INSERT INTO t1 (a) VALUES (1);
+CREATE TRIGGER tr1
+BEFORE INSERT ON t2
+FOR EACH ROW
+BEGIN
+UPDATE a_nonextisting_table SET a = 1;
+END//
+CREATE TABLE IF NOT EXISTS t2 ( a INT, b INT ) SELECT a, b FROM t1;
+ERROR 42S02: Table 'test.a_nonextisting_table' doesn't exist
+SELECT * FROM t2;
+a b
+DROP TABLE t1, t2;
End of 5.1 tests.
=== modified file 'mysql-test/t/trigger.test'
--- a/mysql-test/t/trigger.test 2009-03-27 12:55:14 +0000
+++ b/mysql-test/t/trigger.test 2009-06-19 09:33:49 +0000
@@ -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.
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2009-06-04 23:30:08 +0000
+++ b/sql/sql_insert.cc 2009-06-19 09:33:49 +0000
@@ -3099,6 +3099,7 @@ bool select_insert::send_data(List<Item>
thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields
store_values(values);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
+ table->auto_increment_field_not_null= FALSE;
if (thd->is_error())
DBUG_RETURN(1);
if (table_list) // Not CREATE ... SELECT
@@ -3115,7 +3116,6 @@ bool select_insert::send_data(List<Item>
ha_release_temporary_latches(thd);
error= write_record(thd, table, &info);
- table->auto_increment_field_not_null= FALSE;
if (!error)
{
Attachment: [text/bzr-bundle] bzr/mhansson@mysql.com-20090619093349-9d6lnb2lwrf0zrt5.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (mhansson:2936) Bug#44653 | Martin Hansson | 19 Jun |