Merge lp:~stewart/drizzle/bug314570 into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Merged
Approved by: Brian Aker
Approved revision: 1580
Merged at revision: 1587
Proposed branch: lp:~stewart/drizzle/bug314570
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 137 lines (+47/-24)
6 files modified
plugin/innobase/handler/ha_innodb.cc (+34/-0)
tests/r/auto_increment.result (+3/-3)
tests/r/auto_increment_update.result (+5/-0)
tests/r/innodb.result (+0/-9)
tests/t/auto_increment_update.test (+5/-0)
tests/t/innodb.test (+0/-12)
To merge this branch: bzr merge lp:~stewart/drizzle/bug314570
Reviewer Review Type Date Requested Status
Drizzle Developers Pending
Review via email: mp+26564@code.launchpad.net

Description of the change

update is not changing internal auto increment value

fix innobase plugin so that auto_increment behaviour is the same as MyISAM.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugin/innobase/handler/ha_innodb.cc'
--- plugin/innobase/handler/ha_innodb.cc 2010-05-28 17:31:42 +0000
+++ plugin/innobase/handler/ha_innodb.cc 2010-06-02 08:35:39 +0000
@@ -4197,6 +4197,40 @@
41974197
4198 ut_a(prebuilt->template_type == ROW_MYSQL_WHOLE_ROW);4198 ut_a(prebuilt->template_type == ROW_MYSQL_WHOLE_ROW);
41994199
4200 if (table->found_next_number_field)
4201 {
4202 uint64_t auto_inc;
4203 uint64_t col_max_value;
4204
4205 auto_inc = table->found_next_number_field->val_int();
4206
4207 /* We need the upper limit of the col type to check for
4208 whether we update the table autoinc counter or not. */
4209 col_max_value = innobase_get_int_col_max_value(
4210 table->found_next_number_field);
4211
4212 uint64_t current_autoinc;
4213 ulint error= innobase_get_autoinc(&current_autoinc);
4214 if (error == DB_SUCCESS
4215 && auto_inc <= col_max_value && auto_inc != 0
4216 && auto_inc >= current_autoinc)
4217 {
4218
4219 uint64_t need;
4220 uint64_t offset;
4221
4222 offset = prebuilt->autoinc_offset;
4223 need = prebuilt->autoinc_increment;
4224
4225 auto_inc = innobase_next_autoinc(
4226 auto_inc, need, offset, col_max_value);
4227
4228 dict_table_autoinc_update_if_greater(prebuilt->table, auto_inc);
4229 }
4230
4231 dict_table_autoinc_unlock(prebuilt->table);
4232 }
4233
4200 innodb_srv_conc_enter_innodb(trx);4234 innodb_srv_conc_enter_innodb(trx);
42014235
4202 error = row_update_for_mysql((byte*) old_row, prebuilt);4236 error = row_update_for_mysql((byte*) old_row, prebuilt);
42034237
=== modified file 'tests/r/auto_increment.result'
--- tests/r/auto_increment.result 2010-05-13 05:00:09 +0000
+++ tests/r/auto_increment.result 2010-06-02 08:35:39 +0000
@@ -169,7 +169,7 @@
169201 4169201 4
170203 6170203 6
171300 7171300 7
172205 8172301 8
173400 9173400 9
1740 101740 10
175401 11175401 11
@@ -185,7 +185,7 @@
185201 4185201 4
186203 6186203 6
187300 7187300 7
188205 8188301 8
189400 9189400 9
190401 11190401 11
1910 121910 12
@@ -202,7 +202,7 @@
202201 4202201 4
203203 6203203 6
204300 7204300 7
205205 8205301 8
206400 9206400 9
207401 11207401 11
208403 13208403 13
209209
=== added file 'tests/r/auto_increment_update.result'
--- tests/r/auto_increment_update.result 1970-01-01 00:00:00 +0000
+++ tests/r/auto_increment_update.result 2010-06-02 08:35:39 +0000
@@ -0,0 +1,5 @@
1create table t1 (a int not null auto_increment primary key, val int);
2insert into t1 (val) values (1);
3update t1 set a=2 where a=1;
4insert into t1 (val) values (1);
5drop table t1;
06
=== modified file 'tests/r/innodb.result'
--- tests/r/innodb.result 2010-05-13 05:00:09 +0000
+++ tests/r/innodb.result 2010-06-02 08:35:39 +0000
@@ -2119,15 +2119,6 @@
21193 121193 1
21204 221204 2
2121drop table t1;2121drop table t1;
2122create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
2123insert into t1 (val) values (1);
2124update t1 set a=2 where a=1;
2125insert into t1 (val) values (1);
2126ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
2127select * from t1;
2128a val
21292 1
2130drop table t1;
2131CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;2122CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
2132INSERT INTO t1 (GRADE) VALUES (151),(252),(343);2123INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
2133SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;2124SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
21342125
=== added file 'tests/t/auto_increment_update.test'
--- tests/t/auto_increment_update.test 1970-01-01 00:00:00 +0000
+++ tests/t/auto_increment_update.test 2010-06-02 08:35:39 +0000
@@ -0,0 +1,5 @@
1create table t1 (a int not null auto_increment primary key, val int);
2insert into t1 (val) values (1);
3update t1 set a=2 where a=1;
4insert into t1 (val) values (1);
5drop table t1;
06
=== modified file 'tests/t/innodb.test'
--- tests/t/innodb.test 2010-05-13 05:00:09 +0000
+++ tests/t/innodb.test 2010-06-02 08:35:39 +0000
@@ -1149,18 +1149,6 @@
1149drop table t1;1149drop table t1;
11501150
1151#1151#
1152# Test that update does not change internal auto-increment value
1153#
1154
1155create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
1156insert into t1 (val) values (1);
1157update t1 set a=2 where a=1;
1158# We should get the following error because InnoDB does not update the counter
1159--error ER_DUP_ENTRY
1160insert into t1 (val) values (1);
1161select * from t1;
1162drop table t1;
1163#
1164# Bug #104651152# Bug #10465
1165#1153#
11661154