Commit 1b9d0b34 authored by mskold@mysql.com's avatar mskold@mysql.com

Adjusted so auto_increment value after bulk insert will be exactly +1 after...

Adjusted so auto_increment value after bulk insert will be exactly +1 after last (if no parallel inserts)
parent f29939c4
......@@ -94,16 +94,60 @@ b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (9410,9412);
ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1;
select * from t1 order by a;
a b c
9410 9412 0
select * from t1;
select * from t1 order by a;
a b c
9410 9412 0
alter table t1 drop c;
select * from t1;
select * from t1 order by a;
a b
9410 9412
drop table t1;
select * from t1;
select * from t1 order by a;
ERROR 42S02: Table 'test.t1' doesn't exist
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1 order by a;
a b
0 1
17 18
alter table t1 modify column a int not null auto_increment;
select * from t1 order by a;
a b
0 1
17 18
INSERT INTO t1 VALUES (0,19),(20,21);
select * from t1 order by a;
a b
0 1
17 18
18 19
20 21
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1;
a b
17 18
0 1
alter table t1 add c int not null unique auto_increment;
select * from t1 order by a;
a b c
0 1 2
17 18 1
INSERT INTO t1 VALUES (18,19,3),(20,21,0);
select * from t1 order by a;
a b c
0 1 2
17 18 1
18 19 3
20 21 4
drop table t1;
......@@ -74,19 +74,45 @@ connect (con2,localhost,,,test);
connection con1;
ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1;
select * from t1 order by a;
connection con2;
select * from t1;
select * from t1 order by a;
alter table t1 drop c;
connection con1;
select * from t1;
select * from t1 order by a;
drop table t1;
connection con2;
--error 1146
select * from t1 order by a;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1 order by a;
alter table t1 modify column a int not null auto_increment;
select * from t1 order by a;
INSERT INTO t1 VALUES (0,19),(20,21);
select * from t1 order by a;
drop table t1;
CREATE TABLE t1 (
a INT NOT NULL PRIMARY KEY,
b INT NOT NULL
) ENGINE=ndbcluster;
INSERT INTO t1 VALUES (0,1),(17,18);
select * from t1;
alter table t1 add c int not null unique auto_increment;
select * from t1 order by a;
INSERT INTO t1 VALUES (18,19,3),(20,21,0);
select * from t1 order by a;
drop table t1;
#--disable_warnings
#DROP TABLE IF EXISTS t2;
......
......@@ -3402,7 +3402,9 @@ longlong ha_ndbcluster::get_auto_increment()
DBUG_ENTER("get_auto_increment");
DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
int cache_size=
(rows_to_insert > autoincrement_prefetch) ?
(rows_to_insert - rows_inserted < autoincrement_prefetch) ?
rows_to_insert - rows_inserted
: (rows_to_insert > autoincrement_prefetch) ?
rows_to_insert
: autoincrement_prefetch;
Uint64 auto_value=
......
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