diff --git a/mysql-test/suite/parts/r/mdev_24610.result b/mysql-test/suite/parts/r/mdev_24610.result new file mode 100644 index 00000000000..6b49b059993 --- /dev/null +++ b/mysql-test/suite/parts/r/mdev_24610.result @@ -0,0 +1,24 @@ +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY PARTITION BY KEY(); +INSERT INTO t VALUES (18446744073709551615); +select * from t; +c +18446744073709551615 +drop table t; +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (1); +select * from t; +c +18446744073709551615 +1 +drop table t; +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (NULL); +ERROR HY000: Failed to read auto-increment value from storage engine +select * from t; +c +18446744073709551615 +drop table t; diff --git a/mysql-test/suite/parts/t/mdev_24610.test b/mysql-test/suite/parts/t/mdev_24610.test new file mode 100644 index 00000000000..df3ce9fdf0b --- /dev/null +++ b/mysql-test/suite/parts/t/mdev_24610.test @@ -0,0 +1,22 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY PARTITION BY KEY(); +INSERT INTO t VALUES (18446744073709551615); +select * from t; +drop table t; + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +INSERT INTO t VALUES (1); +select * from t; +drop table t; + +CREATE TABLE t (c BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=MEMORY; +INSERT INTO t VALUES (18446744073709551615); +ALTER TABLE t PARTITION BY KEY(); +--error ER_AUTOINC_READ_FAILED +INSERT INTO t VALUES (NULL); +select * from t; +drop table t; diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c index 41596d864a2..47b1ed6e846 100644 --- a/storage/heap/hp_info.c +++ b/storage/heap/hp_info.c @@ -40,6 +40,10 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag ) x->errkey = info->errkey; x->create_time = info->s->create_time; if (flag & HA_STATUS_AUTO) - x->auto_increment= info->s->auto_increment + 1; + { + x->auto_increment= info->s->auto_increment+1; + if (!x->auto_increment) /* This shouldn't happen */ + x->auto_increment= ~(ulonglong) 0; + } DBUG_RETURN(0); } /* heap_info */