Merge lp:~akopytov/percona-server/bug858945-5.5 into lp:percona-server/5.5

Proposed by Alexey Kopytov
Status: Merged
Merge reported by: Alexey Kopytov
Merged at revision: not available
Proposed branch: lp:~akopytov/percona-server/bug858945-5.5
Merge into: lp:percona-server/5.5
Diff against target: 437 lines (+209/-86)
2 files modified
patches/innodb_expand_fast_index_creation.patch (+207/-86)
patches/mysql-test.diff (+2/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug858945-5.5
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+77701@code.launchpad.net
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 313: s/InnoDB/the InnoDB
diff line 314: 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

review: Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote :

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-23 20:26:34 +0000
3+++ patches/innodb_expand_fast_index_creation.patch 2011-09-30 13:21:33 +0000
4@@ -596,46 +596,6 @@
5 +
6 +######################################
7 +DROP TABLE t1, t2, t3, t4;
8---- a/mysql-test/suite/innodb/r/innodb.result
9-+++ b/mysql-test/suite/innodb/r/innodb.result
10-@@ -1673,7 +1673,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--1066
15-+1108
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/t/innodb-index.test
20-+++ b/mysql-test/suite/innodb/t/innodb-index.test
21-@@ -87,6 +87,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---- a/mysql-test/suite/innodb/t/innodb.test
34-+++ b/mysql-test/suite/innodb/t/innodb.test
35-@@ -21,6 +21,12 @@
36-
37- -- source include/have_innodb.inc
38-
39-+# Suppress the error log message occuring on duplicate key error
40-+# during ALTER TABLE when using fast index creation
41-+--disable_query_log
42-+call mtr.add_suppression("Cannot find index v_2 in InnoDB index translation table.");
43-+--enable_query_log
44-+
45- let $MYSQLD_DATADIR= `select @@datadir`;
46-
47- # Save the original values of some variables in order to be able to
48 --- /dev/null
49 +++ b/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test
50 @@ -0,0 +1,155 @@
51@@ -847,24 +807,7 @@
52 tablespace_op= NO_TABLESPACE_OP;
53 --- a/sql/sql_table.cc
54 +++ b/sql/sql_table.cc
55-@@ -2776,7 +2776,7 @@
56- file The handler for the new table.
57- key_info_buffer OUT An array of KEY structs for the indexes.
58- key_count OUT The number of elements in the array.
59-- select_field_count The number of fields coming from a select table.
60-+ select_field_count The number of fields coming from a select table.
61-
62- DESCRIPTION
63- Prepares the table and key structures for table creation.
64-@@ -3122,7 +3122,6 @@
65- }
66-
67- /* Create keys */
68--
69- List_iterator<Key> key_iterator(alter_info->key_list);
70- List_iterator<Key> key_iterator2(alter_info->key_list);
71- uint key_parts=0, fk_key_count=0;
72-@@ -3220,6 +3219,14 @@
73+@@ -3220,6 +3220,14 @@
74 if (!*key_info_buffer || ! key_part_info)
75 DBUG_RETURN(TRUE); // Out of memory
76
77@@ -879,7 +822,7 @@
78 key_iterator.rewind();
79 key_number=0;
80 for (; (key=key_iterator++) ; key_number++)
81-@@ -3638,6 +3645,22 @@
82+@@ -3638,6 +3646,22 @@
83 key_info->comment.str= key->key_create_info.comment.str;
84 }
85
86@@ -902,7 +845,7 @@
87 key_info++;
88 }
89 if (!unique_key && !primary_key &&
90-@@ -5256,6 +5279,10 @@
91+@@ -5256,6 +5280,10 @@
92 List<Create_field> new_create_list;
93 /* New key definitions are added here */
94 List<Key> new_key_list;
95@@ -913,7 +856,7 @@
96 List_iterator<Alter_drop> drop_it(alter_info->drop_list);
97 List_iterator<Create_field> def_it(alter_info->create_list);
98 List_iterator<Alter_column> alter_it(alter_info->alter_list);
99-@@ -5268,6 +5295,7 @@
100+@@ -5268,6 +5296,7 @@
101 uint used_fields= create_info->used_fields;
102 KEY *key_info=table->key_info;
103 bool rc= TRUE;
104@@ -921,7 +864,7 @@
105
106 DBUG_ENTER("mysql_prepare_alter_table");
107
108-@@ -5457,7 +5485,23 @@
109+@@ -5457,7 +5486,26 @@
110 /*
111 Collect all keys which isn't in drop list. Add only those
112 for which some fields exists.
113@@ -931,6 +874,8 @@
114 + the InnoDB fast index creation. The following conditions must be
115 + met:
116 +
117++ - fast_index_creation is enabled for the current session
118++ - expand_fast_index_creation is enabled for the current session;
119 + - we are going to create an InnoDB table (this is checked later when the
120 + target engine is known);
121 + - the key most be a non-UNIQUE one;
122@@ -940,13 +885,14 @@
123 + key constraints in the table.
124 + */
125 +
126-+ skip_secondary=
127++ skip_secondary= thd->variables.online_alter_index &&
128++ thd->variables.expand_fast_index_creation &&
129 + !table->file->get_foreign_key_list(thd, &f_key_list) &&
130 + f_key_list.elements == 0;
131
132 for (uint i=0 ; i < table->s->keys ; i++,key_info++)
133 {
134-@@ -5574,6 +5618,8 @@
135+@@ -5574,6 +5622,8 @@
136 test(key_info->flags & HA_GENERATED_KEY),
137 key_parts);
138 new_key_list.push_back(key);
139@@ -955,7 +901,7 @@
140 }
141 }
142 {
143-@@ -5581,7 +5627,21 @@
144+@@ -5581,7 +5631,21 @@
145 while ((key=key_it++)) // Add new keys
146 {
147 if (key->type != Key::FOREIGN_KEY)
148@@ -977,7 +923,7 @@
149 if (key->name.str &&
150 !my_strcasecmp(system_charset_info, key->name.str, primary_key_name))
151 {
152-@@ -5630,12 +5690,104 @@
153+@@ -5630,12 +5694,104 @@
154 rc= FALSE;
155 alter_info->create_list.swap(new_create_list);
156 alter_info->key_list.swap(new_key_list);
157@@ -1082,7 +1028,7 @@
158 Alter table
159
160 SYNOPSIS
161-@@ -6428,19 +6580,38 @@
162+@@ -6428,19 +6584,38 @@
163 */
164 if (new_table && !(new_table->file->ha_table_flags() & HA_NO_COPY_ON_ALTER))
165 {
166@@ -1123,7 +1069,7 @@
167 {
168 --- /dev/null
169 +++ b/mysql-test/r/percona_innodb_expand_fast_index_creation.result
170-@@ -0,0 +1,32 @@
171+@@ -0,0 +1,64 @@
172 +CREATE TABLE t1(
173 +id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
174 +a CHAR(1) NOT NULL,
175@@ -1134,6 +1080,37 @@
176 +INSERT INTO t1(a,b) SELECT a,b FROM t1;
177 +INSERT INTO t1(a,b) SELECT a,b FROM t1;
178 +ALTER TABLE t1 ADD KEY (a);
179++affected rows: 0
180++info: Records: 0 Duplicates: 0 Warnings: 0
181++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
182++id 1
183++select_type SIMPLE
184++table t1
185++type ALL
186++possible_keys a
187++key NULL
188++key_len NULL
189++ref NULL
190++rows 16
191++Extra
192++id 1
193++select_type SIMPLE
194++table t2
195++type ref
196++possible_keys a
197++key a
198++key_len 1
199++ref test.t1.a
200++rows 1
201++Extra Using where
202++ALTER TABLE t1 DROP KEY a;
203++SET expand_fast_index_creation = 1;
204++SELECT @@expand_fast_index_creation;
205++@@expand_fast_index_creation
206++1
207++ALTER TABLE t1 ADD KEY (a);
208++affected rows: 0
209++info: Records: 0 Duplicates: 0 Warnings: 0
210 +EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
211 +id 1
212 +select_type SIMPLE
213@@ -1155,10 +1132,11 @@
214 +ref NULL
215 +rows 16
216 +Extra Using where; Using join buffer
217++SET expand_fast_index_creation = 0;
218 +DROP TABLE t1;
219 --- /dev/null
220 +++ b/mysql-test/t/percona_innodb_expand_fast_index_creation.test
221-@@ -0,0 +1,23 @@
222+@@ -0,0 +1,45 @@
223 +--source include/have_innodb.inc
224 +
225 +########################################################################
226@@ -1176,31 +1154,174 @@
227 +INSERT INTO t1(a,b) SELECT a,b FROM t1;
228 +INSERT INTO t1(a,b) SELECT a,b FROM t1;
229 +
230-+ALTER TABLE t1 ADD KEY (a);
231-+
232-+--vertical_results
233-+EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
234++# Check that fast index creation is used
235++--enable_info
236++ALTER TABLE t1 ADD KEY (a);
237++--disable_info
238++
239++# The default (wrong) plan due to bogus statistics
240++--vertical_results
241++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
242++--horizontal_results
243++
244++ALTER TABLE t1 DROP KEY a;
245++
246++SET expand_fast_index_creation = 1;
247++SELECT @@expand_fast_index_creation;
248++
249++# Check that stats are updated with the option enabled
250++
251++--enable_info
252++ALTER TABLE t1 ADD KEY (a);
253++--disable_info
254++
255++--vertical_results
256++EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
257++--horizontal_results
258++
259++SET expand_fast_index_creation = 0;
260 +
261 +DROP TABLE t1;
262 --- a/storage/innobase/row/row0merge.c
263 +++ b/storage/innobase/row/row0merge.c
264-@@ -2672,6 +2672,8 @@
265+@@ -56,6 +56,7 @@
266+ #include "log0log.h"
267+ #include "ut0sort.h"
268+ #include "handler0alter.h"
269++#include "ha_prototypes.h"
270+
271+ /* Ignore posix_fadvise() on those platforms where it does not exist */
272+ #if defined __WIN__
273+@@ -2672,6 +2673,9 @@
274 }
275 }
276
277-+ dict_update_statistics(new_table, FALSE, TRUE);
278++ if (trx->mysql_thd && thd_expand_fast_index_creation(trx->mysql_thd))
279++ dict_update_statistics(new_table, FALSE, TRUE);
280 +
281 func_exit:
282 row_merge_file_destroy_low(tmpfd);
283
284---- a/mysql-test/suite/innodb/r/innodb-index.result
285-+++ b/mysql-test/suite/innodb/r/innodb-index.result
286-@@ -877,7 +877,7 @@
287- test.t1 check status OK
288- explain select * from t1 where b like 'adfd%';
289- id select_type table type possible_keys key key_len ref rows Extra
290--1 SIMPLE t1 ALL b NULL NULL NULL 15 Using where
291-+1 SIMPLE t1 range b b 769 NULL 11 Using where
292- drop table t1;
293- set global innodb_file_per_table=on;
294- set global innodb_file_format='Barracuda';
295+--- a/sql/sql_class.h
296++++ b/sql/sql_class.h
297+@@ -556,6 +556,7 @@
298+
299+ double long_query_time_double;
300+
301++ my_bool expand_fast_index_creation;
302+ } SV;
303+
304+
305+--- a/sql/sys_vars.cc
306++++ b/sql/sys_vars.cc
307+@@ -710,6 +710,14 @@
308+ ON_CHECK(event_scheduler_check), ON_UPDATE(event_scheduler_update));
309+ #endif
310+
311++static Sys_var_mybool Sys_expand_fast_index_creation(
312++ "expand_fast_index_creation",
313++ "Enable/disable improvements to InnoDB fast index creation "
314++ "functionality. Has no effect when fast index creation is disabled with "
315++ "the fast-index-creation option",
316++ SESSION_VAR(expand_fast_index_creation), CMD_LINE(OPT_ARG),
317++ DEFAULT(FALSE));
318++
319+ static Sys_var_ulong Sys_expire_logs_days(
320+ "expire_logs_days",
321+ "If non-zero, binary logs will be purged after expire_logs_days "
322+--- a/storage/innobase/handler/ha_innodb.cc
323++++ b/storage/innobase/handler/ha_innodb.cc
324+@@ -989,6 +989,19 @@
325+ return(THDVAR((THD*) thd, flush_log_at_trx_commit));
326+ }
327+
328++/******************************************************************//**
329++Returns true if expand_fast_index_creation is enabled for the current
330++session.
331++@return the value of the server's expand_fast_index_creation variable */
332++extern "C" UNIV_INTERN
333++ibool
334++thd_expand_fast_index_creation(
335++/*================================*/
336++ void* thd)
337++{
338++ return((ibool) (((THD*) thd)->variables.expand_fast_index_creation));
339++}
340++
341+ /********************************************************************//**
342+ Obtain the InnoDB transaction of a MySQL thread.
343+ @return reference to transaction pointer */
344+--- a/storage/innobase/include/ha_prototypes.h
345++++ b/storage/innobase/include/ha_prototypes.h
346+@@ -303,4 +303,15 @@
347+ innobase_get_lower_case_table_names(void);
348+ /*=====================================*/
349+
350++/******************************************************************//**
351++Returns true if innodb_expand_fast_index_creation is enabled for the current
352++session.
353++@return the value of the server's innodb_expand_fast_index_creation variable */
354++
355++ibool
356++thd_expand_fast_index_creation(
357++/*==================*/
358++ void* thd); /*!< in: thread handle (THD*) */
359++
360++
361+ #endif
362+--- /dev/null
363++++ b/mysql-test/suite/sys_vars/r/expand_fast_index_creation_basic.result
364+@@ -0,0 +1,6 @@
365++SELECT @@global.expand_fast_index_creation;
366++@@global.expand_fast_index_creation
367++0
368++SELECT @@local.expand_fast_index_creation;
369++@@local.expand_fast_index_creation
370++0
371+--- /dev/null
372++++ b/mysql-test/suite/sys_vars/t/expand_fast_index_creation_basic.test
373+@@ -0,0 +1,2 @@
374++SELECT @@global.expand_fast_index_creation;
375++SELECT @@local.expand_fast_index_creation;
376+--- a/mysql-test/r/mysqld--help-notwin.result
377++++ b/mysql-test/r/mysqld--help-notwin.result
378+@@ -140,6 +140,10 @@
379+ and DISABLED (keep the event scheduler completely
380+ deactivated, it cannot be activated run-time)
381+ -T, --exit-info[=#] Used for debugging. Use at your own risk.
382++ --expand-fast-index-creation
383++ Enable/disable improvements to InnoDB fast index creation
384++ functionality. Has no effect when fast index creation is
385++ disabled with the fast-index-creation option
386+ --expire-logs-days=#
387+ If non-zero, binary logs will be purged after
388+ expire_logs_days days; possible purges happen at startup
389+@@ -771,6 +775,7 @@
390+ div-precision-increment 4
391+ engine-condition-pushdown TRUE
392+ event-scheduler OFF
393++expand-fast-index-creation FALSE
394+ expire-logs-days 0
395+ external-locking FALSE
396+ flush FALSE
397+--- a/mysql-test/r/mysqld--help-win.result
398++++ b/mysql-test/r/mysqld--help-win.result
399+@@ -140,6 +140,10 @@
400+ and DISABLED (keep the event scheduler completely
401+ deactivated, it cannot be activated run-time)
402+ -T, --exit-info[=#] Used for debugging. Use at your own risk.
403++ --expand-fast-index-creation
404++ Enable/disable improvements to InnoDB fast index creation
405++ functionality. Has no effect when fast index creation is
406++ disabled with the fast-index-creation option
407+ --expire-logs-days=#
408+ If non-zero, binary logs will be purged after
409+ expire_logs_days days; possible purges happen at startup
410+@@ -775,6 +779,7 @@
411+ div-precision-increment 4
412+ engine-condition-pushdown TRUE
413+ event-scheduler OFF
414++expand-fast-index-creation FALSE
415+ expire-logs-days 0
416+ external-locking FALSE
417+ flush FALSE
418
419=== modified file 'patches/mysql-test.diff'
420--- patches/mysql-test.diff 2011-09-25 07:11:59 +0000
421+++ patches/mysql-test.diff 2011-09-30 13:21:33 +0000
422@@ -1341,6 +1341,7 @@
423 +ENGINE_CONDITION_PUSHDOWN
424 +ERROR_COUNT
425 +EVENT_SCHEDULER
426++EXPAND_FAST_INDEX_CREATION
427 +EXPIRE_LOGS_DAYS
428 +EXTERNAL_USER
429 +FAST_INDEX_CREATION
430@@ -1716,6 +1717,7 @@
431 +ENGINE_CONDITION_PUSHDOWN
432 +ERROR_COUNT
433 +EVENT_SCHEDULER
434++EXPAND_FAST_INDEX_CREATION
435 +EXPIRE_LOGS_DAYS
436 +EXTERNAL_USER
437 +FAST_INDEX_CREATION

Subscribers

People subscribed via source and target branches