Merge lp:~akopytov/percona-server/bug859078-5.1 into lp:percona-server/5.1

Proposed by Alexey Kopytov
Status: Merged
Merge reported by: Alexey Kopytov
Merged at revision: not available
Proposed branch: lp:~akopytov/percona-server/bug859078-5.1
Merge into: lp:percona-server/5.1
Diff against target: 252 lines (+123/-16)
1 file modified
patches/innodb_expand_fast_index_creation.patch (+123/-16)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug859078-5.1
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+77270@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

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-09-24 18:49:30 +0000
3+++ patches/innodb_expand_fast_index_creation.patch 2011-09-28 03:42:24 +0000
4@@ -54,7 +54,7 @@
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-@@ -2246,6 +2256,182 @@
9+@@ -2246,6 +2256,189 @@
10 }
11
12 /*
13@@ -89,7 +89,7 @@
14 +
15 + DESCRIPTION
16 +
17-+ Stores all lines starting with "KEY" or "UNIQUE KEY" or "CONSTRAINT"
18++ Stores all lines starting with "KEY" or "UNIQUE KEY"
19 + into skipped_keys_list and removes them from the input string.
20 + Ignoring FOREIGN KEYS constraints when creating the table is ok, because
21 + mysqldump sets foreign_key_checks to 0 anyway.
22@@ -130,8 +130,7 @@
23 + if (c == '\n' &&
24 + (((is_unique= !strncmp(ptr, "UNIQUE KEY ", sizeof("UNIQUE KEY ")-1)) &&
25 + (pk_processed || !has_pk)) ||
26-+ !strncmp(ptr, "KEY ", sizeof("KEY ") - 1) ||
27-+ !strncmp(ptr, "CONSTRAINT ", sizeof("CONSTRAINT ") - 1)) &&
28++ !strncmp(ptr, "KEY ", sizeof("KEY ") - 1)) &&
29 + !contains_ignored_column(&ignored_columns, ptr))
30 + {
31 + char *data, *end= tmp - 1;
32@@ -150,13 +149,21 @@
33 + if (last_comma != NULL)
34 + {
35 + *last_comma= ' ';
36-+ last_comma = NULL;
37 + }
38 + }
39 + else
40 + {
41 + char *end;
42 +
43++ if (last_comma != NULL && *ptr != ')')
44++ {
45++ /*
46++ It's not the last line of CREATE TABLE, so we have skipped a key
47++ definition. We have to restore the last removed comma.
48++ */
49++ *last_comma= ',';
50++ }
51++
52 + if ((has_pk && is_unique && !pk_processed) ||
53 + !strncmp(ptr, "PRIMARY KEY ", sizeof("PRIMARY KEY ") - 1))
54 + pk_processed= TRUE;
55@@ -237,7 +244,7 @@
56 get_table_structure -- retrievs database structure, prints out corresponding
57 CREATE statement and fills out insert_pat if the table is the type we will
58 be dumping.
59-@@ -2282,6 +2468,7 @@
60+@@ -2282,6 +2475,7 @@
61 int len;
62 MYSQL_RES *result;
63 MYSQL_ROW row;
64@@ -245,7 +252,7 @@
65 DBUG_ENTER("get_table_structure");
66 DBUG_PRINT("enter", ("db: %s table: %s", db, table));
67
68-@@ -2323,6 +2510,9 @@
69+@@ -2323,6 +2517,9 @@
70 result_table= quote_name(table, table_buff, 1);
71 opt_quoted_table= quote_name(table, table_buff2, 0);
72
73@@ -255,7 +262,7 @@
74 if (opt_order_by_primary)
75 order_by= primary_key_fields(result_table);
76
77-@@ -2486,6 +2676,9 @@
78+@@ -2486,6 +2683,9 @@
79
80 row= mysql_fetch_row(result);
81
82@@ -265,7 +272,7 @@
83 fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" :
84 "/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
85 "/*!40101 SET character_set_client = utf8 */;\n"
86-@@ -3578,6 +3771,27 @@
87+@@ -3578,6 +3778,27 @@
88 goto err;
89 }
90
91@@ -295,7 +302,7 @@
92 {
93 --- /dev/null
94 +++ b/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result
95-@@ -0,0 +1,299 @@
96+@@ -0,0 +1,367 @@
97 +#
98 +# Test the --innodb-optimize-keys option.
99 +#
100@@ -369,14 +376,15 @@
101 + `a` int(11) DEFAULT NULL,
102 + `b` varchar(255) DEFAULT NULL,
103 + `c` decimal(10,3) DEFAULT NULL,
104-+ PRIMARY KEY (`id`)
105++ PRIMARY KEY (`id`),
106++ CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t2` (`a`) ON DELETE CASCADE
107 +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
108 +/*!40101 SET character_set_client = @saved_cs_client */;
109 +
110 +LOCK TABLES `t1` WRITE;
111 +/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
112 +INSERT INTO `t1` VALUES (1,0,'0','0.000'),(2,1,'1','1.100'),(3,2,'2','2.200');
113-+ALTER TABLE `t1` ADD UNIQUE KEY `uniq` (`c`,`a`), ADD KEY `b` (`b`), ADD KEY `a` (`a`), ADD CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t2` (`a`) ON DELETE CASCADE;
114++ALTER TABLE `t1` ADD UNIQUE KEY `uniq` (`c`,`a`), ADD KEY `b` (`b`), ADD KEY `a` (`a`);
115 +/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
116 +UNLOCK TABLES;
117 +DROP TABLE IF EXISTS `t2`;
118@@ -595,6 +603,73 @@
119 +
120 +######################################
121 +DROP TABLE t1, t2, t3, t4;
122++CREATE TABLE t1 (
123++id INT NOT NULL PRIMARY KEY
124++) ENGINE=InnoDB;
125++CREATE TABLE t2 (
126++id INT NOT NULL AUTO_INCREMENT,
127++a INT NOT NULL,
128++PRIMARY KEY (id),
129++KEY (a),
130++FOREIGN KEY (a) REFERENCES t2 (id)
131++) ENGINE=InnoDB;
132++INSERT INTO t1 VALUES (1), (2), (3);
133++INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
134++######################################
135++
136++/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
137++/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
138++/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
139++/*!40101 SET NAMES utf8 */;
140++/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
141++/*!40103 SET TIME_ZONE='+00:00' */;
142++/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
143++/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
144++/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
145++/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
146++DROP TABLE IF EXISTS `t1`;
147++/*!40101 SET @saved_cs_client = @@character_set_client */;
148++/*!40101 SET character_set_client = utf8 */;
149++CREATE TABLE `t1` (
150++ `id` int(11) NOT NULL,
151++ PRIMARY KEY (`id`)
152++) ENGINE=InnoDB DEFAULT CHARSET=latin1;
153++/*!40101 SET character_set_client = @saved_cs_client */;
154++
155++LOCK TABLES `t1` WRITE;
156++/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
157++INSERT INTO `t1` VALUES (1),(2),(3);
158++/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
159++UNLOCK TABLES;
160++DROP TABLE IF EXISTS `t2`;
161++/*!40101 SET @saved_cs_client = @@character_set_client */;
162++/*!40101 SET character_set_client = utf8 */;
163++CREATE TABLE `t2` (
164++ `id` int(11) NOT NULL AUTO_INCREMENT,
165++ `a` int(11) NOT NULL,
166++ PRIMARY KEY (`id`),
167++ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t2` (`id`)
168++) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
169++/*!40101 SET character_set_client = @saved_cs_client */;
170++
171++LOCK TABLES `t2` WRITE;
172++/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
173++INSERT INTO `t2` VALUES (1,1),(2,2),(3,3);
174++ALTER TABLE `t2` ADD KEY `a` (`a`);
175++/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
176++UNLOCK TABLES;
177++/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
178++
179++/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
180++/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
181++/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
182++/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
183++/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
184++/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
185++/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
186++
187++######################################
188++DROP TABLE t1, t2;
189 --- a/mysql-test/suite/innodb_plugin/r/innodb.result
190 +++ b/mysql-test/suite/innodb_plugin/r/innodb.result
191 @@ -1679,7 +1679,7 @@
192@@ -645,7 +720,7 @@
193 # Save the original values of some variables in order to be able to
194 --- /dev/null
195 +++ b/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test
196-@@ -0,0 +1,155 @@
197+@@ -0,0 +1,187 @@
198 +# Embedded server doesn't support external clients
199 +--source include/not_embedded.inc
200 +
201@@ -675,9 +750,8 @@
202 +
203 +DROP TABLE t1;
204 +
205-+
206-+# Check that for InnoDB tables secondary and foreign keys are created
207-+# after the data is dumped
208++# Check that for InnoDB tables secondary keys are created after the data is
209++# dumped but foreign ones are left in CREATE TABLE
210 +
211 +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
212 +INSERT INTO t2 VALUES (0), (1), (2);
213@@ -799,6 +873,39 @@
214 +
215 +DROP TABLE t1, t2, t3, t4;
216 +
217++########################################################################
218++# Bug #859078: --innodb-optimize-keys should ignore foreign keys
219++########################################################################
220++
221++CREATE TABLE t1 (
222++ id INT NOT NULL PRIMARY KEY
223++) ENGINE=InnoDB;
224++
225++CREATE TABLE t2 (
226++ id INT NOT NULL AUTO_INCREMENT,
227++ a INT NOT NULL,
228++ PRIMARY KEY (id),
229++ KEY (a),
230++ FOREIGN KEY (a) REFERENCES t2 (id)
231++) ENGINE=InnoDB;
232++
233++INSERT INTO t1 VALUES (1), (2), (3);
234++INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
235++
236++--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
237++
238++--echo ######################################
239++--cat_file $file
240++--echo ######################################
241++
242++# Check that the resulting dump can be imported back
243++
244++--exec $MYSQL test < $file
245++
246++--remove_file $file
247++
248++DROP TABLE t1, t2;
249++
250 +# Wait till we reached the initial number of concurrent sessions
251 +--source include/wait_until_count_sessions.inc
252 --- a/sql/sql_lex.cc

Subscribers

People subscribed via source and target branches