diff options
-rw-r--r-- | mysql-test/r/auto_increment.result | 14 | ||||
-rw-r--r-- | mysql-test/t/auto_increment.test | 18 | ||||
-rw-r--r-- | sql/sql_update.cc | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 21e6347cb47..4a2e108f8c6 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -462,3 +462,17 @@ select last_insert_id(); last_insert_id() 3 drop table t1; +# +# Bug#46616: Assertion `!table->auto_increment_field_not_null' on view +# manipulations +# +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (1); +CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY ); +CREATE TABLE IF NOT EXISTS t2 AS SELECT a FROM t1; +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +UPDATE t2 SET a = 2; +SELECT a FROM t2; +a +2 +DROP TABLE t1, t2; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index 32f065171f2..076e32eb22c 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -324,3 +324,21 @@ insert into t1 values(null,0,0,0,null); replace into t1 values(null,1,0,2,null); select last_insert_id(); drop table t1; + +--echo # +--echo # Bug#46616: Assertion `!table->auto_increment_field_not_null' on view +--echo # manipulations +--echo # +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1), (1); + +CREATE TABLE t2 ( a INT AUTO_INCREMENT KEY ); +--error ER_DUP_ENTRY +CREATE TABLE IF NOT EXISTS t2 AS SELECT a FROM t1; + +UPDATE t2 SET a = 2; + +SELECT a FROM t2; + +DROP TABLE t1, t2; + diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 6884f863326..152613c0009 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -730,6 +730,7 @@ int mysql_update(THD *thd, break; } } + table->auto_increment_field_not_null= FALSE; dup_key_found= 0; /* Caching the killed status to pass as the arg to query event constuctor; |