Commit c4020b54 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-24610 MEMORY SE: check overflow in info calls with HA_STATUS_AUTO

parent 266495b9
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;
--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;
......@@ -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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment