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
1=== modified file 'plugin/innobase/handler/ha_innodb.cc'
2--- plugin/innobase/handler/ha_innodb.cc 2010-05-28 17:31:42 +0000
3+++ plugin/innobase/handler/ha_innodb.cc 2010-06-02 08:35:39 +0000
4@@ -4197,6 +4197,40 @@
5
6 ut_a(prebuilt->template_type == ROW_MYSQL_WHOLE_ROW);
7
8+ if (table->found_next_number_field)
9+ {
10+ uint64_t auto_inc;
11+ uint64_t col_max_value;
12+
13+ auto_inc = table->found_next_number_field->val_int();
14+
15+ /* We need the upper limit of the col type to check for
16+ whether we update the table autoinc counter or not. */
17+ col_max_value = innobase_get_int_col_max_value(
18+ table->found_next_number_field);
19+
20+ uint64_t current_autoinc;
21+ ulint error= innobase_get_autoinc(&current_autoinc);
22+ if (error == DB_SUCCESS
23+ && auto_inc <= col_max_value && auto_inc != 0
24+ && auto_inc >= current_autoinc)
25+ {
26+
27+ uint64_t need;
28+ uint64_t offset;
29+
30+ offset = prebuilt->autoinc_offset;
31+ need = prebuilt->autoinc_increment;
32+
33+ auto_inc = innobase_next_autoinc(
34+ auto_inc, need, offset, col_max_value);
35+
36+ dict_table_autoinc_update_if_greater(prebuilt->table, auto_inc);
37+ }
38+
39+ dict_table_autoinc_unlock(prebuilt->table);
40+ }
41+
42 innodb_srv_conc_enter_innodb(trx);
43
44 error = row_update_for_mysql((byte*) old_row, prebuilt);
45
46=== modified file 'tests/r/auto_increment.result'
47--- tests/r/auto_increment.result 2010-05-13 05:00:09 +0000
48+++ tests/r/auto_increment.result 2010-06-02 08:35:39 +0000
49@@ -169,7 +169,7 @@
50 201 4
51 203 6
52 300 7
53-205 8
54+301 8
55 400 9
56 0 10
57 401 11
58@@ -185,7 +185,7 @@
59 201 4
60 203 6
61 300 7
62-205 8
63+301 8
64 400 9
65 401 11
66 0 12
67@@ -202,7 +202,7 @@
68 201 4
69 203 6
70 300 7
71-205 8
72+301 8
73 400 9
74 401 11
75 403 13
76
77=== added file 'tests/r/auto_increment_update.result'
78--- tests/r/auto_increment_update.result 1970-01-01 00:00:00 +0000
79+++ tests/r/auto_increment_update.result 2010-06-02 08:35:39 +0000
80@@ -0,0 +1,5 @@
81+create table t1 (a int not null auto_increment primary key, val int);
82+insert into t1 (val) values (1);
83+update t1 set a=2 where a=1;
84+insert into t1 (val) values (1);
85+drop table t1;
86
87=== modified file 'tests/r/innodb.result'
88--- tests/r/innodb.result 2010-05-13 05:00:09 +0000
89+++ tests/r/innodb.result 2010-06-02 08:35:39 +0000
90@@ -2119,15 +2119,6 @@
91 3 1
92 4 2
93 drop table t1;
94-create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
95-insert into t1 (val) values (1);
96-update t1 set a=2 where a=1;
97-insert into t1 (val) values (1);
98-ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
99-select * from t1;
100-a val
101-2 1
102-drop table t1;
103 CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB;
104 INSERT INTO t1 (GRADE) VALUES (151),(252),(343);
105 SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300;
106
107=== added file 'tests/t/auto_increment_update.test'
108--- tests/t/auto_increment_update.test 1970-01-01 00:00:00 +0000
109+++ tests/t/auto_increment_update.test 2010-06-02 08:35:39 +0000
110@@ -0,0 +1,5 @@
111+create table t1 (a int not null auto_increment primary key, val int);
112+insert into t1 (val) values (1);
113+update t1 set a=2 where a=1;
114+insert into t1 (val) values (1);
115+drop table t1;
116
117=== modified file 'tests/t/innodb.test'
118--- tests/t/innodb.test 2010-05-13 05:00:09 +0000
119+++ tests/t/innodb.test 2010-06-02 08:35:39 +0000
120@@ -1149,18 +1149,6 @@
121 drop table t1;
122
123 #
124-# Test that update does not change internal auto-increment value
125-#
126-
127-create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
128-insert into t1 (val) values (1);
129-update t1 set a=2 where a=1;
130-# We should get the following error because InnoDB does not update the counter
131---error ER_DUP_ENTRY
132-insert into t1 (val) values (1);
133-select * from t1;
134-drop table t1;
135-#
136 # Bug #10465
137 #
138