summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/create.result34
-rw-r--r--mysql-test/t/create.test53
-rw-r--r--sql/sql_insert.cc1
3 files changed, 88 insertions, 0 deletions
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index b829ef30fb1..471cc6e9a3d 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1922,3 +1922,37 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
# -- End of Bug#45829
End of 5.1 tests
+
+# --
+# -- Bug #43054 Assertion `!table->auto_increment_field_not_null'
+# -- failed when redefining trigger
+
+CREATE TABLE B (
+pk INTEGER AUTO_INCREMENT,
+int_key INTEGER NOT NULL,
+PRIMARY KEY (pk),
+KEY (int_key)
+);
+INSERT IGNORE INTO B VALUES ('9', '9');
+CREATE TABLE IF NOT EXISTS t1 (
+`pk` INTEGER NOT NULL AUTO_INCREMENT ,
+`int` INTEGER ,
+PRIMARY KEY ( `pk` )
+) SELECT `pk` , `int_key` FROM B ;
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+INSERT INTO t1 ( `int` ) VALUES (4 ),( 8 ),( 2 ) ;
+END ; |
+CREATE TABLE IF NOT EXISTS t1 (
+`pk` INTEGER NOT NULL AUTO_INCREMENT ,
+`int` INTEGER ,
+PRIMARY KEY ( `pk` )
+) SELECT `pk` , `int_key` FROM B ;
+ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+UPDATE A SET `pk`=1 WHERE `pk`=0 ;
+END ;|
+ERROR 42000: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
+DROP TABLE t1;
+DROP TABLE B;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 5ffa1b93929..9f3c3a88151 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1582,3 +1582,56 @@ create table t3 (a int) row_format=page;
--echo
--echo End of 5.1 tests
+
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug #43054 Assertion `!table->auto_increment_field_not_null'
+--echo # -- failed when redefining trigger
+--echo
+
+#--disable_abort_on_error
+
+CREATE TABLE B (
+ pk INTEGER AUTO_INCREMENT,
+ int_key INTEGER NOT NULL,
+ PRIMARY KEY (pk),
+ KEY (int_key)
+);
+
+INSERT IGNORE INTO B VALUES ('9', '9');
+
+CREATE TABLE IF NOT EXISTS t1 (
+ `pk` INTEGER NOT NULL AUTO_INCREMENT ,
+ `int` INTEGER ,
+ PRIMARY KEY ( `pk` )
+) SELECT `pk` , `int_key` FROM B ;
+
+--delimiter |
+
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ INSERT INTO t1 ( `int` ) VALUES (4 ),( 8 ),( 2 ) ;
+END ; |
+
+--delimiter ;
+--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
+CREATE TABLE IF NOT EXISTS t1 (
+ `pk` INTEGER NOT NULL AUTO_INCREMENT ,
+ `int` INTEGER ,
+ PRIMARY KEY ( `pk` )
+) SELECT `pk` , `int_key` FROM B ;
+
+--delimiter |
+--error ER_NOT_SUPPORTED_YET
+CREATE TRIGGER f BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ UPDATE A SET `pk`=1 WHERE `pk`=0 ;
+END ;|
+
+--delimiter ;
+
+DROP TABLE t1;
+DROP TABLE B;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index fd19a025429..e9b8254aeb3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -3843,6 +3843,7 @@ void select_create::abort()
{
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
+ table->auto_increment_field_not_null= FALSE;
if (!create_info->table_existed)
drop_open_table(thd, table, create_table->db, create_table->table_name);
table=0; // Safety