Merge lp:~akopytov/percona-server/bug858945-5.1 into lp:percona-server/5.1
- bug858945-5.1
- Merge into 5.1
Proposed by
Alexey Kopytov
Status: | Merged | ||||
---|---|---|---|---|---|
Merge reported by: | Alexey Kopytov | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~akopytov/percona-server/bug858945-5.1 | ||||
Merge into: | lp:percona-server/5.1 | ||||
Diff against target: |
419 lines (+198/-81) 1 file modified
patches/innodb_expand_fast_index_creation.patch (+198/-81) |
||||
To merge this branch: | bzr merge lp:~akopytov/percona-server/bug858945-5.1 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Oleg Tsarev (community) | Approve | ||
Review via email: mp+77544@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote : | # |
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
LGTM with
diff line 329: s/InnoDB/the InnoDB
line 330: s/fast/the fast
Enable/disable improvements to the InnoDB fast index creation functionality.
Has no effect when the fast index creation is disabled with the
review:
Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote : | # |
Agree on line 329.
Disagree on line 330: creation is an uncountable noun in this context. So it should used without an article.
Compare, for example, http://
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'patches/innodb_expand_fast_index_creation.patch' |
2 | --- patches/innodb_expand_fast_index_creation.patch 2011-09-24 18:49:30 +0000 |
3 | +++ patches/innodb_expand_fast_index_creation.patch 2011-09-29 14:44:31 +0000 |
4 | @@ -595,39 +595,6 @@ |
5 | + |
6 | +###################################### |
7 | +DROP TABLE t1, t2, t3, t4; |
8 | ---- a/mysql-test/suite/innodb_plugin/r/innodb.result |
9 | -+++ b/mysql-test/suite/innodb_plugin/r/innodb.result |
10 | -@@ -1679,7 +1679,7 @@ |
11 | - 71 |
12 | - SELECT variable_value - @innodb_rows_inserted_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_inserted'; |
13 | - variable_value - @innodb_rows_inserted_orig |
14 | --1067 |
15 | -+1109 |
16 | - SELECT variable_value - @innodb_rows_updated_orig FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_rows_updated'; |
17 | - variable_value - @innodb_rows_updated_orig |
18 | - 866 |
19 | ---- a/mysql-test/suite/innodb_plugin/t/innodb-index.test |
20 | -+++ b/mysql-test/suite/innodb_plugin/t/innodb-index.test |
21 | -@@ -97,6 +97,11 @@ |
22 | - show create table t1; |
23 | - --error ER_MULTIPLE_PRI_KEY |
24 | - alter table t1 add primary key (c); |
25 | -+# Suppress the error log messages occuring on duplicate key error |
26 | -+# during ALTER TABLE when using fast index creation |
27 | -+--disable_query_log |
28 | -+call mtr.add_suppression("Cannot find index PRIMARY in InnoDB index translation table."); |
29 | -+--enable_query_log |
30 | - --error ER_DUP_ENTRY |
31 | - alter table t1 drop primary key, add primary key (b); |
32 | - create unique index c on t1 (c); |
33 | -@@ -355,6 +360,7 @@ |
34 | - length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1; |
35 | - show create table t1; |
36 | - check table t1; |
37 | -+--replace_column 9 X |
38 | - explain select * from t1 where b like 'adfd%'; |
39 | - |
40 | - # |
41 | --- a/mysql-test/suite/innodb_plugin/t/innodb.test |
42 | +++ b/mysql-test/suite/innodb_plugin/t/innodb.test |
43 | @@ -15,6 +15,12 @@ |
44 | @@ -854,24 +821,7 @@ |
45 | tablespace_op= NO_TABLESPACE_OP; |
46 | --- a/sql/sql_table.cc |
47 | +++ b/sql/sql_table.cc |
48 | -@@ -2560,7 +2560,7 @@ |
49 | - file The handler for the new table. |
50 | - key_info_buffer OUT An array of KEY structs for the indexes. |
51 | - key_count OUT The number of elements in the array. |
52 | -- select_field_count The number of fields coming from a select table. |
53 | -+ select_field_count The number of fields coming from a select table. |
54 | - |
55 | - DESCRIPTION |
56 | - Prepares the table and key structures for table creation. |
57 | -@@ -2915,7 +2915,6 @@ |
58 | - } |
59 | - |
60 | - /* Create keys */ |
61 | -- |
62 | - List_iterator<Key> key_iterator(alter_info->key_list); |
63 | - List_iterator<Key> key_iterator2(alter_info->key_list); |
64 | - uint key_parts=0, fk_key_count=0; |
65 | -@@ -3015,6 +3014,14 @@ |
66 | +@@ -3015,6 +3015,14 @@ |
67 | if (!*key_info_buffer || ! key_part_info) |
68 | DBUG_RETURN(TRUE); // Out of memory |
69 | |
70 | @@ -886,7 +836,7 @@ |
71 | key_iterator.rewind(); |
72 | key_number=0; |
73 | for (; (key=key_iterator++) ; key_number++) |
74 | -@@ -3393,8 +3400,26 @@ |
75 | +@@ -3393,8 +3401,26 @@ |
76 | my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length); |
77 | DBUG_RETURN(TRUE); |
78 | } |
79 | @@ -913,7 +863,7 @@ |
80 | if (!unique_key && !primary_key && |
81 | (file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY)) |
82 | { |
83 | -@@ -6093,6 +6118,10 @@ |
84 | +@@ -6093,6 +6119,10 @@ |
85 | List<Create_field> new_create_list; |
86 | /* New key definitions are added here */ |
87 | List<Key> new_key_list; |
88 | @@ -924,7 +874,7 @@ |
89 | List_iterator<Alter_drop> drop_it(alter_info->drop_list); |
90 | List_iterator<Create_field> def_it(alter_info->create_list); |
91 | List_iterator<Alter_column> alter_it(alter_info->alter_list); |
92 | -@@ -6105,6 +6134,7 @@ |
93 | +@@ -6105,6 +6135,7 @@ |
94 | uint used_fields= create_info->used_fields; |
95 | KEY *key_info=table->key_info; |
96 | bool rc= TRUE; |
97 | @@ -932,7 +882,7 @@ |
98 | |
99 | DBUG_ENTER("mysql_prepare_alter_table"); |
100 | |
101 | -@@ -6132,6 +6162,7 @@ |
102 | +@@ -6132,6 +6163,7 @@ |
103 | char *tablespace= static_cast<char *>(thd->alloc(FN_LEN + 1)); |
104 | /* |
105 | Regular alter table of disk stored table (no tablespace/storage change) |
106 | @@ -940,7 +890,7 @@ |
107 | Copy tablespace name |
108 | */ |
109 | if (tablespace && |
110 | -@@ -6282,7 +6313,23 @@ |
111 | +@@ -6282,7 +6314,26 @@ |
112 | /* |
113 | Collect all keys which isn't in drop list. Add only those |
114 | for which some fields exists. |
115 | @@ -950,6 +900,8 @@ |
116 | + the InnoDB fast index creation. The following conditions must be |
117 | + met: |
118 | + |
119 | ++ - fast_index_creation is enabled for the current session |
120 | ++ - expand_fast_index_creation is enabled for the current session; |
121 | + - we are going to create an InnoDB table (this is checked later when the |
122 | + target engine is known); |
123 | + - the key most be a non-UNIQUE one; |
124 | @@ -959,13 +911,14 @@ |
125 | + key constraints in the table. |
126 | + */ |
127 | + |
128 | -+ skip_secondary= |
129 | ++ skip_secondary= thd->variables.online_alter_index && |
130 | ++ thd->variables.expand_fast_index_creation && |
131 | + !table->file->get_foreign_key_list(thd, &f_key_list) && |
132 | + f_key_list.elements == 0; |
133 | |
134 | for (uint i=0 ; i < table->s->keys ; i++,key_info++) |
135 | { |
136 | -@@ -6385,6 +6432,8 @@ |
137 | +@@ -6385,6 +6436,8 @@ |
138 | test(key_info->flags & HA_GENERATED_KEY), |
139 | key_parts); |
140 | new_key_list.push_back(key); |
141 | @@ -974,7 +927,7 @@ |
142 | } |
143 | } |
144 | { |
145 | -@@ -6392,7 +6441,21 @@ |
146 | +@@ -6392,7 +6445,21 @@ |
147 | while ((key=key_it++)) // Add new keys |
148 | { |
149 | if (key->type != Key::FOREIGN_KEY) |
150 | @@ -997,7 +950,7 @@ |
151 | if (key->name && |
152 | !my_strcasecmp(system_charset_info,key->name,primary_key_name)) |
153 | { |
154 | -@@ -6441,12 +6504,100 @@ |
155 | +@@ -6441,12 +6508,100 @@ |
156 | rc= FALSE; |
157 | alter_info->create_list.swap(new_create_list); |
158 | alter_info->key_list.swap(new_key_list); |
159 | @@ -1098,7 +1051,7 @@ |
160 | Alter table |
161 | |
162 | SYNOPSIS |
163 | -@@ -7230,6 +7381,12 @@ |
164 | +@@ -7230,6 +7385,12 @@ |
165 | else |
166 | create_info->data_file_name=create_info->index_file_name=0; |
167 | |
168 | @@ -1111,7 +1064,7 @@ |
169 | DEBUG_SYNC(thd, "alter_table_before_create_table_no_lock"); |
170 | /* |
171 | Create a table with a temporary name. |
172 | -@@ -7286,15 +7443,33 @@ |
173 | +@@ -7286,15 +7447,33 @@ |
174 | */ |
175 | if (new_table && !(new_table->file->ha_table_flags() & HA_NO_COPY_ON_ALTER)) |
176 | { |
177 | @@ -1147,7 +1100,10 @@ |
178 | { |
179 | --- /dev/null |
180 | +++ b/mysql-test/r/percona_innodb_expand_fast_index_creation.result |
181 | -@@ -0,0 +1,32 @@ |
182 | +@@ -0,0 +1,67 @@ |
183 | ++SELECT @@expand_fast_index_creation; |
184 | ++@@expand_fast_index_creation |
185 | ++0 |
186 | +CREATE TABLE t1( |
187 | +id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, |
188 | +a CHAR(1) NOT NULL, |
189 | @@ -1158,6 +1114,37 @@ |
190 | +INSERT INTO t1(a,b) SELECT a,b FROM t1; |
191 | +INSERT INTO t1(a,b) SELECT a,b FROM t1; |
192 | +ALTER TABLE t1 ADD KEY (a); |
193 | ++affected rows: 0 |
194 | ++info: Records: 0 Duplicates: 0 Warnings: 0 |
195 | ++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b; |
196 | ++id 1 |
197 | ++select_type SIMPLE |
198 | ++table t1 |
199 | ++type ALL |
200 | ++possible_keys a |
201 | ++key NULL |
202 | ++key_len NULL |
203 | ++ref NULL |
204 | ++rows 16 |
205 | ++Extra |
206 | ++id 1 |
207 | ++select_type SIMPLE |
208 | ++table t2 |
209 | ++type ref |
210 | ++possible_keys a |
211 | ++key a |
212 | ++key_len 1 |
213 | ++ref test.t1.a |
214 | ++rows 1 |
215 | ++Extra Using where |
216 | ++ALTER TABLE t1 DROP KEY a; |
217 | ++SET expand_fast_index_creation = 1; |
218 | ++SELECT @@expand_fast_index_creation; |
219 | ++@@expand_fast_index_creation |
220 | ++1 |
221 | ++ALTER TABLE t1 ADD KEY (a); |
222 | ++affected rows: 0 |
223 | ++info: Records: 0 Duplicates: 0 Warnings: 0 |
224 | +EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b; |
225 | +id 1 |
226 | +select_type SIMPLE |
227 | @@ -1179,12 +1166,15 @@ |
228 | +ref NULL |
229 | +rows 16 |
230 | +Extra Using where; Using join buffer |
231 | ++SET expand_fast_index_creation = 0; |
232 | +DROP TABLE t1; |
233 | --- /dev/null |
234 | +++ b/mysql-test/t/percona_innodb_expand_fast_index_creation.test |
235 | -@@ -0,0 +1,23 @@ |
236 | +@@ -0,0 +1,46 @@ |
237 | +--source include/have_innodb.inc |
238 | + |
239 | ++SELECT @@expand_fast_index_creation; |
240 | ++ |
241 | +######################################################################## |
242 | +# Bug #857590: Fast index creation does not update index statistics |
243 | +######################################################################## |
244 | @@ -1200,31 +1190,158 @@ |
245 | +INSERT INTO t1(a,b) SELECT a,b FROM t1; |
246 | +INSERT INTO t1(a,b) SELECT a,b FROM t1; |
247 | + |
248 | -+ALTER TABLE t1 ADD KEY (a); |
249 | -+ |
250 | -+--vertical_results |
251 | -+EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b; |
252 | ++# Check that fast index creation is used |
253 | ++--enable_info |
254 | ++ALTER TABLE t1 ADD KEY (a); |
255 | ++--disable_info |
256 | ++ |
257 | ++# The default (wrong) plan due to bogus statistics |
258 | ++--vertical_results |
259 | ++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b; |
260 | ++--horizontal_results |
261 | ++ |
262 | ++ALTER TABLE t1 DROP KEY a; |
263 | ++ |
264 | ++SET expand_fast_index_creation = 1; |
265 | ++SELECT @@expand_fast_index_creation; |
266 | ++ |
267 | ++# Check that stats are updated with the option enabled |
268 | ++ |
269 | ++--enable_info |
270 | ++ALTER TABLE t1 ADD KEY (a); |
271 | ++--disable_info |
272 | ++--vertical_results |
273 | ++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b; |
274 | ++--horizontal_results |
275 | ++ |
276 | ++SET expand_fast_index_creation = 0; |
277 | + |
278 | +DROP TABLE t1; |
279 | --- a/storage/innodb_plugin/row/row0merge.c |
280 | +++ b/storage/innodb_plugin/row/row0merge.c |
281 | -@@ -2630,6 +2630,8 @@ |
282 | +@@ -56,6 +56,7 @@ |
283 | + #include "log0log.h" |
284 | + #include "ut0sort.h" |
285 | + #include "handler0alter.h" |
286 | ++#include "ha_prototypes.h" |
287 | + |
288 | + #ifdef UNIV_DEBUG |
289 | + /** Set these in order ot enable debug printout. */ |
290 | +@@ -2630,6 +2631,9 @@ |
291 | } |
292 | } |
293 | |
294 | -+ dict_update_statistics(new_table, FALSE, TRUE); |
295 | ++ if (trx->mysql_thd && thd_expand_fast_index_creation(trx->mysql_thd)) |
296 | ++ dict_update_statistics(new_table, FALSE, TRUE); |
297 | + |
298 | func_exit: |
299 | close(tmpfd); |
300 | |
301 | ---- a/mysql-test/suite/innodb_plugin/r/innodb-index.result |
302 | -+++ b/mysql-test/suite/innodb_plugin/r/innodb-index.result |
303 | -@@ -884,7 +884,7 @@ |
304 | - test.t1 check status OK |
305 | - explain select * from t1 where b like 'adfd%'; |
306 | - id select_type table type possible_keys key key_len ref rows Extra |
307 | --1 SIMPLE t1 ALL b NULL NULL NULL 15 Using where |
308 | -+1 SIMPLE t1 range b b 769 NULL X Using where |
309 | - create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb; |
310 | - insert into t2 select a,left(b,255) from t1; |
311 | - drop table t1; |
312 | +--- a/sql/mysqld.cc |
313 | ++++ b/sql/mysqld.cc |
314 | +@@ -6058,7 +6058,8 @@ |
315 | + OPT_IGNORE_BUILTIN_INNODB, |
316 | + OPT_BINLOG_DIRECT_NON_TRANS_UPDATE, |
317 | + OPT_DEFAULT_CHARACTER_SET_OLD, |
318 | +- OPT_MAX_LONG_DATA_SIZE |
319 | ++ OPT_MAX_LONG_DATA_SIZE, |
320 | ++ OPT_EXPAND_FAST_INDEX_CREATION |
321 | + }; |
322 | + |
323 | + |
324 | +@@ -6294,6 +6295,13 @@ |
325 | + each time the SQL thread starts.", |
326 | + &opt_init_slave, &opt_init_slave, 0, GET_STR_ALLOC, |
327 | + REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
328 | ++ {"expand-fast-index-creation", OPT_EXPAND_FAST_INDEX_CREATION, |
329 | ++ "Enable/disable improvements to InnoDB fast index creation functionality. " |
330 | ++ "Has no effect when fast index creation is disabled with the " |
331 | ++ "fast-index-creation option", |
332 | ++ &global_system_variables.expand_fast_index_creation, |
333 | ++ &max_system_variables.expand_fast_index_creation, |
334 | ++ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, NULL}, |
335 | + {"language", 'L', |
336 | + "Client error messages in given language. May be given as a full path.", |
337 | + &language_ptr, &language_ptr, 0, GET_STR, REQUIRED_ARG, |
338 | +--- a/sql/set_var.cc |
339 | ++++ b/sql/set_var.cc |
340 | +@@ -1054,6 +1054,9 @@ |
341 | + SHOW_LONGLONG, |
342 | + get_myisam_mmap_size); |
343 | + |
344 | ++static sys_var_thd_bool |
345 | ++sys_expand_fast_index_creation(&vars, |
346 | ++ "expand_fast_index_creation", &SV::expand_fast_index_creation); |
347 | + |
348 | + bool sys_var::check(THD *thd, set_var *var) |
349 | + { |
350 | +--- a/sql/sql_class.h |
351 | ++++ b/sql/sql_class.h |
352 | +@@ -423,6 +423,8 @@ |
353 | + ulong innodb_lock_que_wait_timer; |
354 | + ulong innodb_innodb_que_wait_timer; |
355 | + ulong innodb_page_access; |
356 | ++ |
357 | ++ my_bool expand_fast_index_creation; |
358 | + }; |
359 | + |
360 | + |
361 | +--- a/storage/innodb_plugin/include/ha_prototypes.h |
362 | ++++ b/storage/innodb_plugin/include/ha_prototypes.h |
363 | +@@ -276,4 +276,14 @@ |
364 | + /*================================*/ |
365 | + void* thd); |
366 | + |
367 | ++/******************************************************************//** |
368 | ++Returns true if innodb_expand_fast_index_creation is enabled for the current |
369 | ++session. |
370 | ++@return the value of the server's innodb_expand_fast_index_creation variable */ |
371 | ++ |
372 | ++ibool |
373 | ++thd_expand_fast_index_creation( |
374 | ++/*==================*/ |
375 | ++ void* thd); /*!< in: thread handle (THD*) */ |
376 | ++ |
377 | + #endif |
378 | +--- a/mysql-test/r/percona_server_variables_debug.result |
379 | ++++ b/mysql-test/r/percona_server_variables_debug.result |
380 | +@@ -40,6 +40,7 @@ |
381 | + ENGINE_CONDITION_PUSHDOWN |
382 | + ERROR_COUNT |
383 | + EVENT_SCHEDULER |
384 | ++EXPAND_FAST_INDEX_CREATION |
385 | + EXPIRE_LOGS_DAYS |
386 | + FAST_INDEX_CREATION |
387 | + FLUSH |
388 | +--- a/mysql-test/r/percona_server_variables_release.result |
389 | ++++ b/mysql-test/r/percona_server_variables_release.result |
390 | +@@ -38,6 +38,7 @@ |
391 | + ENGINE_CONDITION_PUSHDOWN |
392 | + ERROR_COUNT |
393 | + EVENT_SCHEDULER |
394 | ++EXPAND_FAST_INDEX_CREATION |
395 | + EXPIRE_LOGS_DAYS |
396 | + FAST_INDEX_CREATION |
397 | + FLUSH |
398 | +--- a/storage/innodb_plugin/handler/ha_innodb.cc |
399 | ++++ b/storage/innodb_plugin/handler/ha_innodb.cc |
400 | +@@ -762,6 +762,19 @@ |
401 | + return(THDVAR((THD*) thd, flush_log_at_trx_commit_session)); |
402 | + } |
403 | + |
404 | ++/******************************************************************//** |
405 | ++Returns true if expand_fast_index_creation is enabled for the current |
406 | ++session. |
407 | ++@return the value of the server's expand_fast_index_creation variable */ |
408 | ++extern "C" UNIV_INTERN |
409 | ++ibool |
410 | ++thd_expand_fast_index_creation( |
411 | ++/*================================*/ |
412 | ++ void* thd) |
413 | ++{ |
414 | ++ return((ibool) (((THD*) thd)->variables.expand_fast_index_creation)); |
415 | ++} |
416 | ++ |
417 | + /********************************************************************//** |
418 | + Obtain the InnoDB transaction of a MySQL thread. |
419 | + @return reference to transaction pointer */ |
http:// jenkins. percona. com/view/ Percona% 20Server% 205.1/job/ percona- server- 5.1-param/ 157/