summaryrefslogtreecommitdiff
path: root/mysql-test/suite/parts/inc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2010-11-11 11:34:55 +0100
committerMattias Jonsson <mattias.jonsson@oracle.com>2010-11-11 11:34:55 +0100
commite0a8c25438dac90ec697f5edaa712d9681acf96b (patch)
tree487faecc5ed75d2ff52d8e1d5a1ed8727bcac75d /mysql-test/suite/parts/inc
parent7b2e07232a9307220187ee858c7c12a0d899d593 (diff)
downloadmariadb-git-e0a8c25438dac90ec697f5edaa712d9681acf96b.tar.gz
Bug#57890: Assertion failed: next_insert_id == 0
with on duplicate key update There was a missed corner case in the partitioning handler, which caused the next_insert_id to be changed in the second level handlers (i.e the hander of a partition), which caused this debug assertion. The solution was to always ensure that only the partitioning level generates auto_increment values, since if it was done within a partition, it may fail to match the partition function. mysql-test/suite/parts/inc/partition_auto_increment.inc: Added tests mysql-test/suite/parts/r/partition_auto_increment_blackhole.result: updated results mysql-test/suite/parts/r/partition_auto_increment_innodb.result: updated results mysql-test/suite/parts/r/partition_auto_increment_memory.result: updated results mysql-test/suite/parts/r/partition_auto_increment_myisam.result: updated results sql/ha_partition.cc: In <engine>::write_row the auto_inc value is generated through handler::update_auto_increment (which calls <engine>::get_auto_increment() if needed). If: * INSERT_ID was set to 0 * it was updated to 0 by 'INSERT ... ON DUPLICATE KEY UPDATE' and changed partitions for the row Then it would try to generate a auto_increment value in the <engine for a specific partition>::write_row, which will trigger the assert. So the solution is to prevent this by, in ha_partition::write_row set auto_inc_field_not_null and add MODE_NO_AUTO_VALUE_ON_ZERO in ha_partition::update_row (when changing partition) temporary set table->next_number_field to NULL which calling the partitions ::write_row().
Diffstat (limited to 'mysql-test/suite/parts/inc')
-rw-r--r--mysql-test/suite/parts/inc/partition_auto_increment.inc49
1 files changed, 49 insertions, 0 deletions
diff --git a/mysql-test/suite/parts/inc/partition_auto_increment.inc b/mysql-test/suite/parts/inc/partition_auto_increment.inc
index 102e57d3d04..034460d49ac 100644
--- a/mysql-test/suite/parts/inc/partition_auto_increment.inc
+++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc
@@ -105,6 +105,30 @@ OPTIMIZE TABLE t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+if (!$skip_update)
+{
+eval CREATE TABLE t1
+(a INT NULL AUTO_INCREMENT,
+ UNIQUE KEY (a))
+ENGINE=$engine;
+SET LAST_INSERT_ID = 999;
+SET INSERT_ID = 0;
+INSERT INTO t1 SET a = 1 ON DUPLICATE KEY UPDATE a = NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+INSERT INTO t1 SET a = 1 ON DUPLICATE KEY UPDATE a = NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+UPDATE t1 SET a = 1 WHERE a IS NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+UPDATE t1 SET a = NULL WHERE a = 1;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+DROP TABLE t1;
+SET INSERT_ID = 1;
+}
+
-- echo # Simple test with NULL
eval CREATE TABLE t1 (
c1 INT NOT NULL AUTO_INCREMENT,
@@ -831,5 +855,30 @@ SELECT * FROM t ORDER BY c1 ASC;
DROP TABLE t;
+if (!$skip_update)
+{
+eval CREATE TABLE t1
+(a INT NULL AUTO_INCREMENT,
+ UNIQUE KEY (a))
+ENGINE=$engine
+PARTITION BY KEY(a) PARTITIONS 2;
+SET LAST_INSERT_ID = 999;
+SET INSERT_ID = 0;
+INSERT INTO t1 SET a = 1 ON DUPLICATE KEY UPDATE a = NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+INSERT INTO t1 SET a = 1 ON DUPLICATE KEY UPDATE a = NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+UPDATE t1 SET a = 1 WHERE a IS NULL;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+UPDATE t1 SET a = NULL WHERE a = 1;
+SELECT LAST_INSERT_ID();
+SELECT * FROM t1;
+DROP TABLE t1;
+}
+
+
--echo ##############################################################################
}