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

Proposed by Alexey Kopytov
Status: Merged
Merged at revision: 159
Proposed branch: lp:~akopytov/percona-server/bug812179-5.5
Merge into: lp:percona-server/5.5
Diff against target: 250 lines (+153/-8)
1 file modified
patches/innodb_expand_fast_index_creation.patch (+153/-8)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug812179-5.5
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+74778@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

LGTM. I'd write *(leftp+1), *(rightp-1) instead of leftp[1], rightp[-1] for consistency.

review: Approve

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-08-09 20:52:20 +0000
3+++ patches/innodb_expand_fast_index_creation.patch 2011-09-09 13:14:25 +0000
4@@ -55,10 +55,30 @@
5 {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
6 &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
7 0, 0},
8-@@ -2238,6 +2248,77 @@
9+@@ -2238,6 +2248,128 @@
10 }
11
12 /*
13++ Parse the specified key definition string and check if the key indexes
14++ any of the columns from ignored_columns.
15++*/
16++static my_bool contains_ignored_column(HASH *ignored_columns, char *keydef)
17++{
18++ char *leftp, *rightp;
19++
20++ if ((leftp = strchr(keydef, '(')) &&
21++ (rightp = strchr(leftp, ')')) &&
22++ rightp > leftp + 3 && /* (`...`) */
23++ leftp[1] == '`' &&
24++ rightp[-1] == '`' &&
25++ my_hash_search(ignored_columns, (uchar *) leftp + 2, rightp - leftp - 3))
26++ return TRUE;
27++
28++ return FALSE;
29++}
30++
31++
32++/*
33 + Remove secondary/foreign key definitions from a given SHOW CREATE TABLE string
34 + and store them into a temporary list to be used later.
35 +
36@@ -79,13 +99,18 @@
37 +{
38 + char *ptr, *strend;
39 + char *last_comma = NULL;
40++ HASH ignored_columns;
41++
42++ if (my_hash_init(&ignored_columns, charset_info, 16, 0, 0,
43++ (my_hash_get_key) get_table_key, my_free, 0))
44++ exit(EX_EOM);
45 +
46 + strend= create_str + strlen(create_str);
47 +
48 + ptr= create_str;
49 + while (*ptr)
50 + {
51-+ char *tmp, *orig_ptr;
52++ char *tmp, *orig_ptr, c;
53 +
54 + orig_ptr= ptr;
55 + /* Skip leading whitespace */
56@@ -95,11 +120,15 @@
57 + /* Read the next line */
58 + for (tmp= ptr; *tmp != '\n' && *tmp != '\0'; tmp++);
59 +
60++ c= *tmp;
61++ *tmp= '\0'; /* so strstr() only processes the current line */
62++
63 + /* Is it a secondary index definition? */
64-+ if (*tmp == '\n' &&
65++ if (c == '\n' &&
66 + (!strncmp(ptr, "UNIQUE KEY ", sizeof("UNIQUE KEY ") - 1) ||
67 + !strncmp(ptr, "KEY ", sizeof("KEY ") - 1) ||
68-+ !strncmp(ptr, "CONSTRAINT ", sizeof("CONSTRAINT ") - 1)))
69++ !strncmp(ptr, "CONSTRAINT ", sizeof("CONSTRAINT ") - 1)) &&
70++ !contains_ignored_column(&ignored_columns, ptr))
71 + {
72 + char *data, *end= tmp - 1;
73 +
74@@ -122,18 +151,40 @@
75 + }
76 + else
77 + {
78++ char *end;
79++
80++ if (strstr(ptr, "AUTO_INCREMENT") && *ptr == '`')
81++ {
82++ /*
83++ If a secondary key is defined on this column later,
84++ it cannot be skipped, as CREATE TABLE would fail on import.
85++ */
86++ for (end= ptr + 1; *end != '`' && *end != '\0'; end++);
87++ if (*end == '`' && end > ptr + 1 &&
88++ my_hash_insert(&ignored_columns,
89++ (uchar *) my_strndup(ptr + 1,
90++ end - ptr - 1, MYF(0))))
91++ {
92++ exit(EX_EOM);
93++ }
94++ }
95++
96++ *tmp= c;
97++
98 + if (tmp[-1] == ',')
99 + last_comma= tmp - 1;
100 + ptr= (*tmp == '\0') ? tmp : tmp + 1;
101 + }
102 + }
103++
104++ my_hash_free(&ignored_columns);
105 +}
106 +
107 +/*
108 get_table_structure -- retrievs database structure, prints out corresponding
109 CREATE statement and fills out insert_pat if the table is the type we will
110 be dumping.
111-@@ -2478,6 +2559,9 @@
112+@@ -2478,6 +2610,9 @@
113
114 row= mysql_fetch_row(result);
115
116@@ -143,7 +194,7 @@
117 fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
118 "/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
119 "/*!40101 SET character_set_client = utf8 */;\n"
120-@@ -3572,6 +3656,27 @@
121+@@ -3572,6 +3707,27 @@
122 goto err;
123 }
124
125@@ -173,7 +224,7 @@
126 {
127 --- /dev/null
128 +++ b/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result
129-@@ -0,0 +1,109 @@
130+@@ -0,0 +1,171 @@
131 +#
132 +# Test the --innodb-optimize-keys option.
133 +#
134@@ -283,6 +334,68 @@
135 +
136 +######################################
137 +DROP TABLE t1, t2;
138++CREATE TABLE t1 (
139++id INT NOT NULL AUTO_INCREMENT,
140++KEY (id)
141++) ENGINE=InnoDB;
142++CREATE TABLE t2 (
143++id INT NOT NULL AUTO_INCREMENT,
144++UNIQUE KEY (id)
145++) ENGINE=InnoDB;
146++INSERT INTO t1 VALUES (), (), ();
147++INSERT INTO t2 VALUES (), (), ();
148++######################################
149++
150++/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
151++/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
152++/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
153++/*!40101 SET NAMES utf8 */;
154++/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
155++/*!40103 SET TIME_ZONE='+00:00' */;
156++/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
157++/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
158++/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
159++/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
160++DROP TABLE IF EXISTS `t1`;
161++/*!40101 SET @saved_cs_client = @@character_set_client */;
162++/*!40101 SET character_set_client = utf8 */;
163++CREATE TABLE `t1` (
164++ `id` int(11) NOT NULL AUTO_INCREMENT,
165++ KEY `id` (`id`)
166++) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
167++/*!40101 SET character_set_client = @saved_cs_client */;
168++
169++LOCK TABLES `t1` WRITE;
170++/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
171++INSERT INTO `t1` VALUES (1),(2),(3);
172++/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
173++UNLOCK TABLES;
174++DROP TABLE IF EXISTS `t2`;
175++/*!40101 SET @saved_cs_client = @@character_set_client */;
176++/*!40101 SET character_set_client = utf8 */;
177++CREATE TABLE `t2` (
178++ `id` int(11) NOT NULL AUTO_INCREMENT,
179++ UNIQUE KEY `id` (`id`)
180++) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
181++/*!40101 SET character_set_client = @saved_cs_client */;
182++
183++LOCK TABLES `t2` WRITE;
184++/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
185++INSERT INTO `t2` VALUES (1),(2),(3);
186++/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
187++UNLOCK TABLES;
188++/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
189++
190++/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
191++/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
192++/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
193++/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
194++/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
195++/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
196++/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
197++
198++######################################
199++DROP TABLE t1, t2;
200 --- a/mysql-test/suite/innodb/r/innodb.result
201 +++ b/mysql-test/suite/innodb/r/innodb.result
202 @@ -1673,7 +1673,7 @@
203@@ -325,7 +438,7 @@
204 # Save the original values of some variables in order to be able to
205 --- /dev/null
206 +++ b/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test
207-@@ -0,0 +1,62 @@
208+@@ -0,0 +1,94 @@
209 +# Embedded server doesn't support external clients
210 +--source include/not_embedded.inc
211 +
212@@ -386,6 +499,38 @@
213 +
214 +DROP TABLE t1, t2;
215 +
216++########################################################################
217++# Bug #812179: AUTO_INCREMENT columns must be skipped by the
218++# --innodb-optimize-keys optimization in mysqldump
219++########################################################################
220++
221++CREATE TABLE t1 (
222++ id INT NOT NULL AUTO_INCREMENT,
223++ KEY (id)
224++) ENGINE=InnoDB;
225++
226++CREATE TABLE t2 (
227++ id INT NOT NULL AUTO_INCREMENT,
228++ UNIQUE KEY (id)
229++) ENGINE=InnoDB;
230++
231++INSERT INTO t1 VALUES (), (), ();
232++INSERT INTO t2 VALUES (), (), ();
233++
234++--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
235++
236++--echo ######################################
237++--cat_file $file
238++--echo ######################################
239++
240++# Check that the resulting dump can be imported back
241++
242++--exec $MYSQL test < $file
243++
244++--remove_file $file
245++
246++DROP TABLE t1, t2;
247++
248 +# Wait till we reached the initial number of concurrent sessions
249 +--source include/wait_until_count_sessions.inc
250 --- a/sql/sql_lex.cc

Subscribers

People subscribed via source and target branches