Merge lp:~vkolesnikov/pbxt/pbxt-bug-340316 into lp:pbxt
- pbxt-bug-340316
- Merge into trunk
Proposed by
Vladimir Kolesnikov
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~vkolesnikov/pbxt/pbxt-bug-340316 | ||||
Merge into: | lp:pbxt | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~vkolesnikov/pbxt/pbxt-bug-340316 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PBXT Core | Pending | ||
Review via email: mp+4370@code.launchpad.net |
Commit message
Description of the change
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 'ChangeLog' | |||
2 | --- ChangeLog 2009-03-05 15:28:42 +0000 | |||
3 | +++ ChangeLog 2009-03-10 17:43:39 +0000 | |||
4 | @@ -3,6 +3,10 @@ | |||
5 | 3 | 3 | ||
6 | 4 | ------- 1.0.08 RC - Not yet released | 4 | ------- 1.0.08 RC - Not yet released |
7 | 5 | 5 | ||
8 | 6 | RN226: Fixed bug #340316: Issue with bigint unsigned auto-increment field | ||
9 | 7 | |||
10 | 8 | RN225: Fixed bug #308557: UPDATE fails to match all rows in a transactional scenario | ||
11 | 9 | |||
12 | 6 | RN224: Fixed a deadlock which could occur during table scans. | 10 | RN224: Fixed a deadlock which could occur during table scans. |
13 | 7 | 11 | ||
14 | 8 | RN223: Index scans now use handles to cache buffers instead of making a copy of the index page. The handles are "copy-on-write". | 12 | RN223: Index scans now use handles to cache buffers instead of making a copy of the index page. The handles are "copy-on-write". |
15 | 9 | 13 | ||
16 | === modified file 'src/ha_pbxt.cc' | |||
17 | --- src/ha_pbxt.cc 2009-02-27 09:22:44 +0000 | |||
18 | +++ src/ha_pbxt.cc 2009-03-11 11:18:00 +0000 | |||
19 | @@ -2065,7 +2065,7 @@ | |||
20 | 2065 | MX_ULONGLONG_T *nb_reserved_values __attribute__((unused))) | 2065 | MX_ULONGLONG_T *nb_reserved_values __attribute__((unused))) |
21 | 2066 | { | 2066 | { |
22 | 2067 | register XTTableHPtr tab; | 2067 | register XTTableHPtr tab; |
24 | 2068 | MX_ULONGLONG_T nr; | 2068 | MX_ULONGLONG_T nr, nr_plus_inc; |
25 | 2069 | 2069 | ||
26 | 2070 | ASSERT_NS(pb_ex_in_use); | 2070 | ASSERT_NS(pb_ex_in_use); |
27 | 2071 | 2071 | ||
28 | @@ -2077,7 +2077,11 @@ | |||
29 | 2077 | nr = offset; | 2077 | nr = offset; |
30 | 2078 | else if (increment > 1 && ((nr - offset) % increment) != 0) | 2078 | else if (increment > 1 && ((nr - offset) % increment) != 0) |
31 | 2079 | nr += increment - ((nr - offset) % increment); | 2079 | nr += increment - ((nr - offset) % increment); |
33 | 2080 | tab->tab_auto_inc = (xtWord8) (nr + increment); | 2080 | nr_plus_inc = nr + increment; |
34 | 2081 | if (table->next_number_field->cmp((const unsigned char *)&nr, (const unsigned char *)&nr_plus_inc) < 0) | ||
35 | 2082 | tab->tab_auto_inc = (xtWord8) (nr_plus_inc); | ||
36 | 2083 | else | ||
37 | 2084 | nr = ~0; /* indicate error to the caller */ | ||
38 | 2081 | xt_spinlock_unlock(&tab->tab_ainc_lock); | 2085 | xt_spinlock_unlock(&tab->tab_ainc_lock); |
39 | 2082 | 2086 | ||
40 | 2083 | *first_value = nr; | 2087 | *first_value = nr; |
41 | @@ -2091,25 +2095,34 @@ | |||
42 | 2091 | * insert into t1 values (-1); | 2095 | * insert into t1 values (-1); |
43 | 2092 | * insert into t1 values (NULL); | 2096 | * insert into t1 values (NULL); |
44 | 2093 | */ | 2097 | */ |
46 | 2094 | void ha_pbxt::set_auto_increment(MX_LONGLONG_T nr) | 2098 | void ha_pbxt::set_auto_increment(Field *nr) |
47 | 2095 | { | 2099 | { |
48 | 2096 | register XTTableHPtr tab; | 2100 | register XTTableHPtr tab; |
49 | 2101 | MX_ULONGLONG_T nr_int_val; | ||
50 | 2102 | |||
51 | 2103 | nr_int_val = nr->val_int(); | ||
52 | 2104 | tab = pb_open_tab->ot_table; | ||
53 | 2097 | 2105 | ||
56 | 2098 | tab = pb_open_tab->ot_table; | 2106 | if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) { |
55 | 2099 | if ((MX_LONGLONG_T) tab->tab_auto_inc <= nr) { | ||
57 | 2100 | xt_spinlock_lock(&tab->tab_ainc_lock); | 2107 | xt_spinlock_lock(&tab->tab_ainc_lock); |
60 | 2101 | if ((MX_LONGLONG_T) tab->tab_auto_inc <= nr && nr > 0) | 2108 | |
61 | 2102 | tab->tab_auto_inc = nr + 1; | 2109 | if (nr->cmp((const unsigned char *)&tab->tab_auto_inc) > 0) { |
62 | 2110 | MX_ULONGLONG_T nr_int_val_plus_one = nr_int_val + 1; | ||
63 | 2111 | if (nr->cmp((const unsigned char *)&nr_int_val_plus_one) < 0) | ||
64 | 2112 | tab->tab_auto_inc = nr_int_val_plus_one; | ||
65 | 2113 | else | ||
66 | 2114 | tab->tab_auto_inc = nr_int_val; | ||
67 | 2115 | } | ||
68 | 2103 | xt_spinlock_unlock(&tab->tab_ainc_lock); | 2116 | xt_spinlock_unlock(&tab->tab_ainc_lock); |
69 | 2104 | } | 2117 | } |
70 | 2105 | 2118 | ||
71 | 2106 | if (xt_db_auto_increment_mode == 1) { | 2119 | if (xt_db_auto_increment_mode == 1) { |
73 | 2107 | if (nr > (MX_LONGLONG_T) tab->tab_dic.dic_min_auto_inc) { | 2120 | if (nr_int_val > (MX_ULONGLONG_T) tab->tab_dic.dic_min_auto_inc) { |
74 | 2108 | /* Do this every 100 calls: */ | 2121 | /* Do this every 100 calls: */ |
75 | 2109 | #ifdef DEBUG | 2122 | #ifdef DEBUG |
77 | 2110 | tab->tab_dic.dic_min_auto_inc = nr + 5; | 2123 | tab->tab_dic.dic_min_auto_inc = nr_int_val + 5; |
78 | 2111 | #else | 2124 | #else |
80 | 2112 | tab->tab_dic.dic_min_auto_inc = nr + 100; | 2125 | tab->tab_dic.dic_min_auto_inc = nr_int_val + 100; |
81 | 2113 | #endif | 2126 | #endif |
82 | 2114 | pb_open_tab->ot_thread = xt_get_self(); | 2127 | pb_open_tab->ot_thread = xt_get_self(); |
83 | 2115 | if (!xt_tab_write_min_auto_inc(pb_open_tab)) | 2128 | if (!xt_tab_write_min_auto_inc(pb_open_tab)) |
84 | @@ -2187,8 +2200,12 @@ | |||
85 | 2187 | table->timestamp_field->set_time(); | 2200 | table->timestamp_field->set_time(); |
86 | 2188 | 2201 | ||
87 | 2189 | if (table->next_number_field && buf == table->record[0]) { | 2202 | if (table->next_number_field && buf == table->record[0]) { |
90 | 2190 | update_auto_increment(); | 2203 | int err = update_auto_increment(); |
91 | 2191 | set_auto_increment(table->next_number_field->val_int()); | 2204 | if (err) { |
92 | 2205 | ha_log_pbxt_thread_error_for_mysql(pb_ignore_dup_key); | ||
93 | 2206 | return err; | ||
94 | 2207 | } | ||
95 | 2208 | set_auto_increment(table->next_number_field); | ||
96 | 2192 | } | 2209 | } |
97 | 2193 | 2210 | ||
98 | 2194 | if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf)) | 2211 | if (!xt_tab_new_record(pb_open_tab, (xtWord1 *) buf)) |
99 | @@ -2281,8 +2298,8 @@ | |||
100 | 2281 | 2298 | ||
101 | 2282 | old_map = mx_tmp_use_all_columns(table, table->read_set); | 2299 | old_map = mx_tmp_use_all_columns(table, table->read_set); |
102 | 2283 | nr = table->found_next_number_field->val_int(); | 2300 | nr = table->found_next_number_field->val_int(); |
103 | 2301 | set_auto_increment(table->found_next_number_field); | ||
104 | 2284 | mx_tmp_restore_column_map(table, old_map); | 2302 | mx_tmp_restore_column_map(table, old_map); |
105 | 2285 | set_auto_increment(nr); | ||
106 | 2286 | } | 2303 | } |
107 | 2287 | 2304 | ||
108 | 2288 | if (!xt_tab_update_record(pb_open_tab, (xtWord1 *) old_data, (xtWord1 *) new_data)) | 2305 | if (!xt_tab_update_record(pb_open_tab, (xtWord1 *) old_data, (xtWord1 *) new_data)) |
109 | 2289 | 2306 | ||
110 | === modified file 'src/ha_pbxt.h' | |||
111 | --- src/ha_pbxt.h 2008-12-10 20:34:30 +0000 | |||
112 | +++ src/ha_pbxt.h 2009-03-10 17:43:39 +0000 | |||
113 | @@ -171,7 +171,7 @@ | |||
114 | 171 | MX_ULONGLONG_T nb_desired_values, | 171 | MX_ULONGLONG_T nb_desired_values, |
115 | 172 | MX_ULONGLONG_T *first_value, | 172 | MX_ULONGLONG_T *first_value, |
116 | 173 | MX_ULONGLONG_T *nb_reserved_values); | 173 | MX_ULONGLONG_T *nb_reserved_values); |
118 | 174 | void set_auto_increment(MX_LONGLONG_T nr); | 174 | void set_auto_increment(Field *nr); |
119 | 175 | 175 | ||
120 | 176 | int write_row(byte * buf); | 176 | int write_row(byte * buf); |
121 | 177 | int update_row(const byte * old_data, byte * new_data); | 177 | int update_row(const byte * old_data, byte * new_data); |
122 | 178 | 178 | ||
123 | === modified file 'src/index_xt.cc' | |||
124 | --- src/index_xt.cc 2009-03-06 13:40:00 +0000 | |||
125 | +++ src/index_xt.cc 2009-03-10 08:28:54 +0000 | |||
126 | @@ -2327,7 +2327,9 @@ | |||
127 | 2327 | #endif | 2327 | #endif |
128 | 2328 | ASSERT_NS(ot->ot_ind_rhandle); | 2328 | ASSERT_NS(ot->ot_ind_rhandle); |
129 | 2329 | xt_ind_lock_handle(ot->ot_ind_rhandle); | 2329 | xt_ind_lock_handle(ot->ot_ind_rhandle); |
131 | 2330 | if (!ot->ot_ind_state.i_node_ref_size && ot->ot_ind_state.i_item_offset < ot->ot_ind_state.i_total_size) { | 2330 | if (!ot->ot_ind_state.i_node_ref_size && |
132 | 2331 | ot->ot_ind_state.i_item_offset < ot->ot_ind_state.i_total_size && | ||
133 | 2332 | ot->ot_ind_rhandle->ih_cache_reference) { | ||
134 | 2331 | key_value.sv_key = &ot->ot_ind_rhandle->ih_branch->tb_data[ot->ot_ind_state.i_item_offset]; | 2333 | key_value.sv_key = &ot->ot_ind_rhandle->ih_branch->tb_data[ot->ot_ind_state.i_item_offset]; |
135 | 2332 | key_value.sv_length = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE; | 2334 | key_value.sv_length = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE; |
136 | 2333 | 2335 | ||
137 | 2334 | 2336 | ||
138 | === modified file 'test/mysql-test/r/pbxt_bugs.result' | |||
139 | --- test/mysql-test/r/pbxt_bugs.result 2008-12-16 13:39:34 +0000 | |||
140 | +++ test/mysql-test/r/pbxt_bugs.result 2009-03-11 11:18:00 +0000 | |||
141 | @@ -986,3 +986,62 @@ | |||
142 | 986 | insert into t1 values ("1"); | 986 | insert into t1 values ("1"); |
143 | 987 | insert into t2 values ("1"); | 987 | insert into t2 values ("1"); |
144 | 988 | DROP TABLE IF EXISTS t2,t1; | 988 | DROP TABLE IF EXISTS t2,t1; |
145 | 989 | DROP TABLE IF EXISTS t5; | ||
146 | 990 | CREATE TABLE t5 ( | ||
147 | 991 | c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
148 | 992 | c2 BIGINT SIGNED NULL, | ||
149 | 993 | c3 BIGINT SIGNED NOT NULL, | ||
150 | 994 | c4 TINYINT, c5 SMALLINT, | ||
151 | 995 | c6 MEDIUMINT, | ||
152 | 996 | c7 INT, | ||
153 | 997 | c8 INTEGER, | ||
154 | 998 | PRIMARY KEY(c1,c2), UNIQUE INDEX(c3)); | ||
155 | 999 | INSERT INTO t5 VALUES | ||
156 | 1000 | (0,-9223372036854775808,1,2,3,4,5,5), | ||
157 | 1001 | (255,-2147483648,6,7,8,9,10,10), | ||
158 | 1002 | (65535,-8388608,11,12,13,14,15,15), | ||
159 | 1003 | (16777215,-32768,16,17,18,19,20,20), | ||
160 | 1004 | (4294967295,-128,21,22,23,24,25,25), | ||
161 | 1005 | (18446744073709551615,9223372036854775807,26,27,28,29,30,30); | ||
162 | 1006 | INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */; | ||
163 | 1007 | ERROR HY000: Failed to read auto-increment value from storage engine | ||
164 | 1008 | INSERT INTO t5(c2,c3) VALUES(33,34); | ||
165 | 1009 | ERROR HY000: Failed to read auto-increment value from storage engine | ||
166 | 1010 | SELECT * FROM t5; | ||
167 | 1011 | c1 c2 c3 c4 c5 c6 c7 c8 | ||
168 | 1012 | 1 -9223372036854775808 1 2 3 4 5 5 | ||
169 | 1013 | 255 -2147483648 6 7 8 9 10 10 | ||
170 | 1014 | 65535 -8388608 11 12 13 14 15 15 | ||
171 | 1015 | 16777215 -32768 16 17 18 19 20 20 | ||
172 | 1016 | 4294967295 -128 21 22 23 24 25 25 | ||
173 | 1017 | 18446744073709551615 9223372036854775807 26 27 28 29 30 30 | ||
174 | 1018 | DROP TABLE t5; | ||
175 | 1019 | /* same test as above with signed bigint */ | ||
176 | 1020 | CREATE TABLE t5 ( | ||
177 | 1021 | c1 BIGINT SIGNED NOT NULL AUTO_INCREMENT, | ||
178 | 1022 | c2 BIGINT SIGNED NULL, | ||
179 | 1023 | c3 BIGINT SIGNED NOT NULL, | ||
180 | 1024 | c4 TINYINT, c5 SMALLINT, | ||
181 | 1025 | c6 MEDIUMINT, | ||
182 | 1026 | c7 INT, | ||
183 | 1027 | c8 INTEGER, | ||
184 | 1028 | PRIMARY KEY(c1,c2), UNIQUE INDEX(c3)); | ||
185 | 1029 | INSERT INTO t5 VALUES | ||
186 | 1030 | (0,-9223372036854775808,1,2,3,4,5,5), | ||
187 | 1031 | (255,-2147483648,6,7,8,9,10,10), | ||
188 | 1032 | (65535,-8388608,11,12,13,14,15,15), | ||
189 | 1033 | (16777215,-32768,16,17,18,19,20,20), | ||
190 | 1034 | (4294967295,-128,21,22,23,24,25,25), | ||
191 | 1035 | (9223372036854775807,9223372036854775807,26,27,28,29,30,30); | ||
192 | 1036 | INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */; | ||
193 | 1037 | ERROR HY000: Failed to read auto-increment value from storage engine | ||
194 | 1038 | INSERT INTO t5(c2,c3) VALUES(33,34); | ||
195 | 1039 | ERROR HY000: Failed to read auto-increment value from storage engine | ||
196 | 1040 | SELECT * FROM t5; | ||
197 | 1041 | c1 c2 c3 c4 c5 c6 c7 c8 | ||
198 | 1042 | 1 -9223372036854775808 1 2 3 4 5 5 | ||
199 | 1043 | 255 -2147483648 6 7 8 9 10 10 | ||
200 | 1044 | 65535 -8388608 11 12 13 14 15 15 | ||
201 | 1045 | 16777215 -32768 16 17 18 19 20 20 | ||
202 | 1046 | 4294967295 -128 21 22 23 24 25 25 | ||
203 | 1047 | 9223372036854775807 9223372036854775807 26 27 28 29 30 30 | ||
204 | 989 | 1048 | ||
205 | === modified file 'test/mysql-test/t/pbxt_bugs.test' | |||
206 | --- test/mysql-test/t/pbxt_bugs.test 2008-12-16 13:39:34 +0000 | |||
207 | +++ test/mysql-test/t/pbxt_bugs.test 2009-03-11 11:18:00 +0000 | |||
208 | @@ -807,3 +807,61 @@ | |||
209 | 807 | insert into t2 values ("1"); | 807 | insert into t2 values ("1"); |
210 | 808 | 808 | ||
211 | 809 | DROP TABLE IF EXISTS t2,t1; | 809 | DROP TABLE IF EXISTS t2,t1; |
212 | 810 | |||
213 | 811 | # bug 340316: Issue with bigint unsigned auto-increment field | ||
214 | 812 | |||
215 | 813 | --disable_warnings | ||
216 | 814 | DROP TABLE IF EXISTS t5; | ||
217 | 815 | --enable_warnings | ||
218 | 816 | CREATE TABLE t5 ( | ||
219 | 817 | c1 BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
220 | 818 | c2 BIGINT SIGNED NULL, | ||
221 | 819 | c3 BIGINT SIGNED NOT NULL, | ||
222 | 820 | c4 TINYINT, c5 SMALLINT, | ||
223 | 821 | c6 MEDIUMINT, | ||
224 | 822 | c7 INT, | ||
225 | 823 | c8 INTEGER, | ||
226 | 824 | PRIMARY KEY(c1,c2), UNIQUE INDEX(c3)); | ||
227 | 825 | |||
228 | 826 | INSERT INTO t5 VALUES | ||
229 | 827 | (0,-9223372036854775808,1,2,3,4,5,5), | ||
230 | 828 | (255,-2147483648,6,7,8,9,10,10), | ||
231 | 829 | (65535,-8388608,11,12,13,14,15,15), | ||
232 | 830 | (16777215,-32768,16,17,18,19,20,20), | ||
233 | 831 | (4294967295,-128,21,22,23,24,25,25), | ||
234 | 832 | (18446744073709551615,9223372036854775807,26,27,28,29,30,30); | ||
235 | 833 | |||
236 | 834 | --error 1467 | ||
237 | 835 | INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */; | ||
238 | 836 | --error 1467 | ||
239 | 837 | INSERT INTO t5(c2,c3) VALUES(33,34); | ||
240 | 838 | |||
241 | 839 | SELECT * FROM t5; | ||
242 | 840 | |||
243 | 841 | DROP TABLE t5; | ||
244 | 842 | |||
245 | 843 | /* same test as above with signed bigint */ | ||
246 | 844 | CREATE TABLE t5 ( | ||
247 | 845 | c1 BIGINT SIGNED NOT NULL AUTO_INCREMENT, | ||
248 | 846 | c2 BIGINT SIGNED NULL, | ||
249 | 847 | c3 BIGINT SIGNED NOT NULL, | ||
250 | 848 | c4 TINYINT, c5 SMALLINT, | ||
251 | 849 | c6 MEDIUMINT, | ||
252 | 850 | c7 INT, | ||
253 | 851 | c8 INTEGER, | ||
254 | 852 | PRIMARY KEY(c1,c2), UNIQUE INDEX(c3)); | ||
255 | 853 | |||
256 | 854 | INSERT INTO t5 VALUES | ||
257 | 855 | (0,-9223372036854775808,1,2,3,4,5,5), | ||
258 | 856 | (255,-2147483648,6,7,8,9,10,10), | ||
259 | 857 | (65535,-8388608,11,12,13,14,15,15), | ||
260 | 858 | (16777215,-32768,16,17,18,19,20,20), | ||
261 | 859 | (4294967295,-128,21,22,23,24,25,25), | ||
262 | 860 | (9223372036854775807,9223372036854775807,26,27,28,29,30,30); | ||
263 | 861 | |||
264 | 862 | --error 1467 | ||
265 | 863 | INSERT INTO t5(c2,c3) VALUES(33,34) /* tries to increment out of range */; | ||
266 | 864 | --error 1467 | ||
267 | 865 | INSERT INTO t5(c2,c3) VALUES(33,34); | ||
268 | 866 | |||
269 | 867 | SELECT * FROM t5; |