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

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 177
Proposed branch: lp:~akopytov/percona-server/bug859078-5.5
Merge into: lp:percona-server/5.5
Diff against target: 251 lines (+123/-15)
1 file modified
patches/innodb_expand_fast_index_creation.patch (+123/-15)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug859078-5.5
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Laurynas Biveinis (community) Approve
Review via email: mp+77272@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
Revision history for this message
Stewart Smith (stewart) :
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-23 20:26:34 +0000
3+++ patches/innodb_expand_fast_index_creation.patch 2011-09-28 03:44:37 +0000
4@@ -55,7 +55,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-@@ -2238,6 +2248,182 @@
9+@@ -2238,6 +2248,189 @@
10 }
11
12 /*
13@@ -91,7 +91,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@@ -131,8 +131,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@@ -151,13 +150,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@@ -238,7 +245,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-@@ -2274,6 +2460,7 @@
60+@@ -2274,6 +2467,7 @@
61 int len;
62 MYSQL_RES *result;
63 MYSQL_ROW row;
64@@ -246,7 +253,7 @@
65 DBUG_ENTER("get_table_structure");
66 DBUG_PRINT("enter", ("db: %s table: %s", db, table));
67
68-@@ -2315,6 +2502,9 @@
69+@@ -2315,6 +2509,9 @@
70 result_table= quote_name(table, table_buff, 1);
71 opt_quoted_table= quote_name(table, table_buff2, 0);
72
73@@ -256,7 +263,7 @@
74 if (opt_order_by_primary)
75 order_by= primary_key_fields(result_table);
76
77-@@ -2478,6 +2668,9 @@
78+@@ -2478,6 +2675,9 @@
79
80 row= mysql_fetch_row(result);
81
82@@ -266,7 +273,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-@@ -3572,6 +3765,27 @@
87+@@ -3572,6 +3772,27 @@
88 goto err;
89 }
90
91@@ -296,7 +303,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@@ -370,14 +377,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@@ -596,6 +604,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/r/innodb.result
190 +++ b/mysql-test/suite/innodb/r/innodb.result
191 @@ -1673,7 +1673,7 @@
192@@ -638,7 +713,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,188 @@
198 +# Embedded server doesn't support external clients
199 +--source include/not_embedded.inc
200 +
201@@ -669,8 +744,8 @@
202 +DROP TABLE t1;
203 +
204 +
205-+# Check that for InnoDB tables secondary and foreign keys are created
206-+# after the data is dumped
207++# Check that for InnoDB tables secondary keys are created after the data is
208++# dumped but foreign ones are left in CREATE TABLE
209 +
210 +CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
211 +INSERT INTO t2 VALUES (0), (1), (2);
212@@ -792,6 +867,39 @@
213 +
214 +DROP TABLE t1, t2, t3, t4;
215 +
216++########################################################################
217++# Bug #859078: --innodb-optimize-keys should ignore foreign keys
218++########################################################################
219++
220++CREATE TABLE t1 (
221++ id INT NOT NULL PRIMARY KEY
222++) ENGINE=InnoDB;
223++
224++CREATE TABLE t2 (
225++ id INT NOT NULL AUTO_INCREMENT,
226++ a INT NOT NULL,
227++ PRIMARY KEY (id),
228++ KEY (a),
229++ FOREIGN KEY (a) REFERENCES t2 (id)
230++) ENGINE=InnoDB;
231++
232++INSERT INTO t1 VALUES (1), (2), (3);
233++INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
234++
235++--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
236++
237++--echo ######################################
238++--cat_file $file
239++--echo ######################################
240++
241++# Check that the resulting dump can be imported back
242++
243++--exec $MYSQL test < $file
244++
245++--remove_file $file
246++
247++DROP TABLE t1, t2;
248++
249 +# Wait till we reached the initial number of concurrent sessions
250 +--source include/wait_until_count_sessions.inc
251 --- a/sql/sql_lex.cc

Subscribers

People subscribed via source and target branches