Merge lp:~akopytov/percona-server/bug851674-5.1 into lp:percona-server/5.1
- bug851674-5.1
- Merge into 5.1
Proposed by
Alexey Kopytov
Status: | Merged |
---|---|
Merged at revision: | 286 |
Proposed branch: | lp:~akopytov/percona-server/bug851674-5.1 |
Merge into: | lp:percona-server/5.1 |
Diff against target: |
372 lines (+269/-8) 1 file modified
patches/innodb_expand_fast_index_creation.patch (+269/-8) |
To merge this branch: | bzr merge lp:~akopytov/percona-server/bug851674-5.1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Review via email: mp+75912@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:
1) Please use "||" in (pk_processed | !has_pk)
2) (Optional) Please assert that the my_snprintf buffer does not overflow.
review:
Approve
Revision history for this message
Alexey Kopytov (akopytov) wrote : | # |
On 22.09.11 15:26, Laurynas Biveinis wrote:
> Review: Approve
>
> LGTM with:
> 1) Please use "||" in (pk_processed | !has_pk)
Fixed, thanks!
> 2) (Optional) Please assert that the my_snprintf buffer does not overflow.
>
It turns out it's not even possible to check for overflows in
my_snprintf(), because unlike regular snprintf(), my_vsnprintf() (which
does the actual work) never returns values equal or greater than 'n'. It
returns the length of the resulting string (without terminating '\0')
which is (n-1) at most.
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-06 11:50:30 +0000 | |||
3 | +++ patches/innodb_expand_fast_index_creation.patch 2011-09-22 11:51:23 +0000 | |||
4 | @@ -54,7 +54,7 @@ | |||
5 | 54 | {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", | 54 | {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", |
6 | 55 | &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, | 55 | &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, |
7 | 56 | 0, 0}, | 56 | 0, 0}, |
9 | 57 | @@ -2246,6 +2256,128 @@ | 57 | @@ -2246,6 +2256,182 @@ |
10 | 58 | } | 58 | } |
11 | 59 | 59 | ||
12 | 60 | /* | 60 | /* |
13 | @@ -83,6 +83,8 @@ | |||
14 | 83 | + SYNOPSIS | 83 | + SYNOPSIS |
15 | 84 | + skip_secondary_keys() | 84 | + skip_secondary_keys() |
16 | 85 | + create_str SHOW CREATE TABLE output | 85 | + create_str SHOW CREATE TABLE output |
17 | 86 | + has_pk TRUE, if the table has PRIMARY KEY | ||
18 | 87 | + (or UNIQUE key on non-nullable columns) | ||
19 | 86 | + | 88 | + |
20 | 87 | + | 89 | + |
21 | 88 | + DESCRIPTION | 90 | + DESCRIPTION |
22 | @@ -93,11 +95,12 @@ | |||
23 | 93 | + mysqldump sets foreign_key_checks to 0 anyway. | 95 | + mysqldump sets foreign_key_checks to 0 anyway. |
24 | 94 | +*/ | 96 | +*/ |
25 | 95 | + | 97 | + |
27 | 96 | +static void skip_secondary_keys(char *create_str) | 98 | +static void skip_secondary_keys(char *create_str, my_bool has_pk) |
28 | 97 | +{ | 99 | +{ |
29 | 98 | + char *ptr, *strend; | 100 | + char *ptr, *strend; |
30 | 99 | + char *last_comma = NULL; | 101 | + char *last_comma = NULL; |
31 | 100 | + HASH ignored_columns; | 102 | + HASH ignored_columns; |
32 | 103 | + my_bool pk_processed= FALSE; | ||
33 | 101 | + | 104 | + |
34 | 102 | + if (hash_init(&ignored_columns, charset_info, 16, 0, 0, | 105 | + if (hash_init(&ignored_columns, charset_info, 16, 0, 0, |
35 | 103 | + (hash_get_key) get_table_key, | 106 | + (hash_get_key) get_table_key, |
36 | @@ -110,6 +113,7 @@ | |||
37 | 110 | + while (*ptr) | 113 | + while (*ptr) |
38 | 111 | + { | 114 | + { |
39 | 112 | + char *tmp, *orig_ptr, c; | 115 | + char *tmp, *orig_ptr, c; |
40 | 116 | + my_bool is_unique; | ||
41 | 113 | + | 117 | + |
42 | 114 | + orig_ptr= ptr; | 118 | + orig_ptr= ptr; |
43 | 115 | + /* Skip leading whitespace */ | 119 | + /* Skip leading whitespace */ |
44 | @@ -124,7 +128,8 @@ | |||
45 | 124 | + | 128 | + |
46 | 125 | + /* Is it a secondary index definition? */ | 129 | + /* Is it a secondary index definition? */ |
47 | 126 | + if (c == '\n' && | 130 | + if (c == '\n' && |
49 | 127 | + (!strncmp(ptr, "UNIQUE KEY ", sizeof("UNIQUE KEY ") - 1) || | 131 | + (((is_unique= !strncmp(ptr, "UNIQUE KEY ", sizeof("UNIQUE KEY ")-1)) && |
50 | 132 | + (pk_processed || !has_pk)) || | ||
51 | 128 | + !strncmp(ptr, "KEY ", sizeof("KEY ") - 1) || | 133 | + !strncmp(ptr, "KEY ", sizeof("KEY ") - 1) || |
52 | 129 | + !strncmp(ptr, "CONSTRAINT ", sizeof("CONSTRAINT ") - 1)) && | 134 | + !strncmp(ptr, "CONSTRAINT ", sizeof("CONSTRAINT ") - 1)) && |
53 | 130 | + !contains_ignored_column(&ignored_columns, ptr)) | 135 | + !contains_ignored_column(&ignored_columns, ptr)) |
54 | @@ -152,6 +157,10 @@ | |||
55 | 152 | + { | 157 | + { |
56 | 153 | + char *end; | 158 | + char *end; |
57 | 154 | + | 159 | + |
58 | 160 | + if ((has_pk && is_unique && !pk_processed) || | ||
59 | 161 | + !strncmp(ptr, "PRIMARY KEY ", sizeof("PRIMARY KEY ") - 1)) | ||
60 | 162 | + pk_processed= TRUE; | ||
61 | 163 | + | ||
62 | 155 | + if (strstr(ptr, "AUTO_INCREMENT") && *ptr == '`') | 164 | + if (strstr(ptr, "AUTO_INCREMENT") && *ptr == '`') |
63 | 156 | + { | 165 | + { |
64 | 157 | + /* | 166 | + /* |
65 | @@ -180,20 +189,83 @@ | |||
66 | 180 | +} | 189 | +} |
67 | 181 | + | 190 | + |
68 | 182 | +/* | 191 | +/* |
69 | 192 | + Check if the table has a primary key defined either explicitly or | ||
70 | 193 | + implicitly (i.e. a unique key on non-nullable columns). | ||
71 | 194 | + | ||
72 | 195 | + SYNOPSIS | ||
73 | 196 | + my_bool has_primary_key(const char *table_name) | ||
74 | 197 | + | ||
75 | 198 | + table_name quoted table name | ||
76 | 199 | + | ||
77 | 200 | + RETURNS TRUE if the table has a primary key | ||
78 | 201 | + | ||
79 | 202 | + DESCRIPTION | ||
80 | 203 | +*/ | ||
81 | 204 | + | ||
82 | 205 | +static my_bool has_primary_key(const char *table_name) | ||
83 | 206 | +{ | ||
84 | 207 | + MYSQL_RES *res= NULL; | ||
85 | 208 | + MYSQL_ROW row; | ||
86 | 209 | + char query_buff[QUERY_LENGTH]; | ||
87 | 210 | + my_bool has_pk= TRUE; | ||
88 | 211 | + | ||
89 | 212 | + my_snprintf(query_buff, sizeof(query_buff), | ||
90 | 213 | + "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE " | ||
91 | 214 | + "TABLE_SCHEMA=DATABASE() AND TABLE_NAME='%s' AND " | ||
92 | 215 | + "COLUMN_KEY='PRI'", table_name); | ||
93 | 216 | + if (mysql_query(mysql, query_buff) || !(res= mysql_store_result(mysql)) || | ||
94 | 217 | + !(row= mysql_fetch_row(res))) | ||
95 | 218 | + { | ||
96 | 219 | + fprintf(stderr, "Warning: Couldn't determine if table %s has a " | ||
97 | 220 | + "primary key (%s). " | ||
98 | 221 | + "--innodb-optimize-keys may work inefficiently.\n", | ||
99 | 222 | + table_name, mysql_error(mysql)); | ||
100 | 223 | + goto cleanup; | ||
101 | 224 | + } | ||
102 | 225 | + | ||
103 | 226 | + has_pk= atoi(row[0]) > 0; | ||
104 | 227 | + | ||
105 | 228 | +cleanup: | ||
106 | 229 | + if (res) | ||
107 | 230 | + mysql_free_result(res); | ||
108 | 231 | + | ||
109 | 232 | + return has_pk; | ||
110 | 233 | +} | ||
111 | 234 | + | ||
112 | 235 | + | ||
113 | 236 | +/* | ||
114 | 183 | get_table_structure -- retrievs database structure, prints out corresponding | 237 | get_table_structure -- retrievs database structure, prints out corresponding |
115 | 184 | CREATE statement and fills out insert_pat if the table is the type we will | 238 | CREATE statement and fills out insert_pat if the table is the type we will |
116 | 185 | be dumping. | 239 | be dumping. |
118 | 186 | @@ -2486,6 +2618,9 @@ | 240 | @@ -2282,6 +2468,7 @@ |
119 | 241 | int len; | ||
120 | 242 | MYSQL_RES *result; | ||
121 | 243 | MYSQL_ROW row; | ||
122 | 244 | + my_bool has_pk; | ||
123 | 245 | DBUG_ENTER("get_table_structure"); | ||
124 | 246 | DBUG_PRINT("enter", ("db: %s table: %s", db, table)); | ||
125 | 247 | |||
126 | 248 | @@ -2323,6 +2510,9 @@ | ||
127 | 249 | result_table= quote_name(table, table_buff, 1); | ||
128 | 250 | opt_quoted_table= quote_name(table, table_buff2, 0); | ||
129 | 251 | |||
130 | 252 | + if (opt_innodb_optimize_keys && !strcmp(table_type, "InnoDB")) | ||
131 | 253 | + has_pk= has_primary_key(table); | ||
132 | 254 | + | ||
133 | 255 | if (opt_order_by_primary) | ||
134 | 256 | order_by= primary_key_fields(result_table); | ||
135 | 257 | |||
136 | 258 | @@ -2486,6 +2676,9 @@ | ||
137 | 187 | 259 | ||
138 | 188 | row= mysql_fetch_row(result); | 260 | row= mysql_fetch_row(result); |
139 | 189 | 261 | ||
140 | 190 | + if (opt_innodb_optimize_keys && !strcmp(table_type, "InnoDB")) | 262 | + if (opt_innodb_optimize_keys && !strcmp(table_type, "InnoDB")) |
142 | 191 | + skip_secondary_keys(row[1]); | 263 | + skip_secondary_keys(row[1], has_pk); |
143 | 192 | + | 264 | + |
144 | 193 | fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" : | 265 | fprintf(sql_file, (opt_compatible_mode & 3) ? "%s;\n" : |
145 | 194 | "/*!40101 SET @saved_cs_client = @@character_set_client */;\n" | 266 | "/*!40101 SET @saved_cs_client = @@character_set_client */;\n" |
146 | 195 | "/*!40101 SET character_set_client = utf8 */;\n" | 267 | "/*!40101 SET character_set_client = utf8 */;\n" |
148 | 196 | @@ -3578,6 +3713,27 @@ | 268 | @@ -3578,6 +3771,27 @@ |
149 | 197 | goto err; | 269 | goto err; |
150 | 198 | } | 270 | } |
151 | 199 | 271 | ||
152 | @@ -223,7 +295,7 @@ | |||
153 | 223 | { | 295 | { |
154 | 224 | --- /dev/null | 296 | --- /dev/null |
155 | 225 | +++ b/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result | 297 | +++ b/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result |
157 | 226 | @@ -0,0 +1,171 @@ | 298 | @@ -0,0 +1,299 @@ |
158 | 227 | +# | 299 | +# |
159 | 228 | +# Test the --innodb-optimize-keys option. | 300 | +# Test the --innodb-optimize-keys option. |
160 | 229 | +# | 301 | +# |
161 | @@ -395,6 +467,134 @@ | |||
162 | 395 | + | 467 | + |
163 | 396 | +###################################### | 468 | +###################################### |
164 | 397 | +DROP TABLE t1, t2; | 469 | +DROP TABLE t1, t2; |
165 | 470 | +CREATE TABLE t1 ( | ||
166 | 471 | +a INT NOT NULL, | ||
167 | 472 | +UNIQUE KEY (a)) ENGINE=InnoDB; | ||
168 | 473 | +CREATE TABLE t2 ( | ||
169 | 474 | +a INT NOT NULL, | ||
170 | 475 | +b INT NOT NULL, | ||
171 | 476 | +UNIQUE KEY (a,b)) ENGINE=InnoDB; | ||
172 | 477 | +CREATE TABLE t3 ( | ||
173 | 478 | +a INT, | ||
174 | 479 | +b INT, | ||
175 | 480 | +UNIQUE KEY (a,b)) ENGINE=InnoDB; | ||
176 | 481 | +CREATE TABLE t4 ( | ||
177 | 482 | +a INT NOT NULL, | ||
178 | 483 | +b INT NOT NULL, | ||
179 | 484 | +PRIMARY KEY (a,b), | ||
180 | 485 | +UNIQUE KEY(b)) ENGINE=InnoDB; | ||
181 | 486 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
182 | 487 | +TABLE_SCHEMA=DATABASE() AND | ||
183 | 488 | +TABLE_NAME='t1' AND | ||
184 | 489 | +COLUMN_KEY='PRI'; | ||
185 | 490 | +COUNT(*) | ||
186 | 491 | +1 | ||
187 | 492 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
188 | 493 | +TABLE_SCHEMA=DATABASE() AND | ||
189 | 494 | +TABLE_NAME='t2' AND | ||
190 | 495 | +COLUMN_KEY='PRI'; | ||
191 | 496 | +COUNT(*) | ||
192 | 497 | +2 | ||
193 | 498 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
194 | 499 | +TABLE_SCHEMA=DATABASE() AND | ||
195 | 500 | +TABLE_NAME='t3' AND | ||
196 | 501 | +COLUMN_KEY='PRI'; | ||
197 | 502 | +COUNT(*) | ||
198 | 503 | +0 | ||
199 | 504 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
200 | 505 | +TABLE_SCHEMA=DATABASE() AND | ||
201 | 506 | +TABLE_NAME='t4' AND | ||
202 | 507 | +COLUMN_KEY='PRI'; | ||
203 | 508 | +COUNT(*) | ||
204 | 509 | +2 | ||
205 | 510 | +INSERT INTO t1 VALUES (1), (2), (3); | ||
206 | 511 | +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); | ||
207 | 512 | +INSERT INTO t3 SELECT * FROM t2; | ||
208 | 513 | +INSERT INTO t4 SELECT * FROM t2; | ||
209 | 514 | +###################################### | ||
210 | 515 | + | ||
211 | 516 | +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
212 | 517 | +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
213 | 518 | +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
214 | 519 | +/*!40101 SET NAMES utf8 */; | ||
215 | 520 | +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
216 | 521 | +/*!40103 SET TIME_ZONE='+00:00' */; | ||
217 | 522 | +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
218 | 523 | +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
219 | 524 | +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
220 | 525 | +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
221 | 526 | +DROP TABLE IF EXISTS `t1`; | ||
222 | 527 | +/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
223 | 528 | +/*!40101 SET character_set_client = utf8 */; | ||
224 | 529 | +CREATE TABLE `t1` ( | ||
225 | 530 | + `a` int(11) NOT NULL, | ||
226 | 531 | + UNIQUE KEY `a` (`a`) | ||
227 | 532 | +) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
228 | 533 | +/*!40101 SET character_set_client = @saved_cs_client */; | ||
229 | 534 | + | ||
230 | 535 | +LOCK TABLES `t1` WRITE; | ||
231 | 536 | +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; | ||
232 | 537 | +INSERT INTO `t1` VALUES (1),(2),(3); | ||
233 | 538 | +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; | ||
234 | 539 | +UNLOCK TABLES; | ||
235 | 540 | +DROP TABLE IF EXISTS `t2`; | ||
236 | 541 | +/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
237 | 542 | +/*!40101 SET character_set_client = utf8 */; | ||
238 | 543 | +CREATE TABLE `t2` ( | ||
239 | 544 | + `a` int(11) NOT NULL, | ||
240 | 545 | + `b` int(11) NOT NULL, | ||
241 | 546 | + UNIQUE KEY `a` (`a`,`b`) | ||
242 | 547 | +) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
243 | 548 | +/*!40101 SET character_set_client = @saved_cs_client */; | ||
244 | 549 | + | ||
245 | 550 | +LOCK TABLES `t2` WRITE; | ||
246 | 551 | +/*!40000 ALTER TABLE `t2` DISABLE KEYS */; | ||
247 | 552 | +INSERT INTO `t2` VALUES (1,1),(2,2),(3,3); | ||
248 | 553 | +/*!40000 ALTER TABLE `t2` ENABLE KEYS */; | ||
249 | 554 | +UNLOCK TABLES; | ||
250 | 555 | +DROP TABLE IF EXISTS `t3`; | ||
251 | 556 | +/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
252 | 557 | +/*!40101 SET character_set_client = utf8 */; | ||
253 | 558 | +CREATE TABLE `t3` ( | ||
254 | 559 | + `a` int(11) DEFAULT NULL, | ||
255 | 560 | + `b` int(11) DEFAULT NULL | ||
256 | 561 | +) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
257 | 562 | +/*!40101 SET character_set_client = @saved_cs_client */; | ||
258 | 563 | + | ||
259 | 564 | +LOCK TABLES `t3` WRITE; | ||
260 | 565 | +/*!40000 ALTER TABLE `t3` DISABLE KEYS */; | ||
261 | 566 | +INSERT INTO `t3` VALUES (1,1),(2,2),(3,3); | ||
262 | 567 | +ALTER TABLE `t3` ADD UNIQUE KEY `a` (`a`,`b`); | ||
263 | 568 | +/*!40000 ALTER TABLE `t3` ENABLE KEYS */; | ||
264 | 569 | +UNLOCK TABLES; | ||
265 | 570 | +DROP TABLE IF EXISTS `t4`; | ||
266 | 571 | +/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
267 | 572 | +/*!40101 SET character_set_client = utf8 */; | ||
268 | 573 | +CREATE TABLE `t4` ( | ||
269 | 574 | + `a` int(11) NOT NULL, | ||
270 | 575 | + `b` int(11) NOT NULL, | ||
271 | 576 | + PRIMARY KEY (`a`,`b`) | ||
272 | 577 | +) ENGINE=InnoDB DEFAULT CHARSET=latin1; | ||
273 | 578 | +/*!40101 SET character_set_client = @saved_cs_client */; | ||
274 | 579 | + | ||
275 | 580 | +LOCK TABLES `t4` WRITE; | ||
276 | 581 | +/*!40000 ALTER TABLE `t4` DISABLE KEYS */; | ||
277 | 582 | +INSERT INTO `t4` VALUES (1,1),(2,2),(3,3); | ||
278 | 583 | +ALTER TABLE `t4` ADD UNIQUE KEY `b` (`b`); | ||
279 | 584 | +/*!40000 ALTER TABLE `t4` ENABLE KEYS */; | ||
280 | 585 | +UNLOCK TABLES; | ||
281 | 586 | +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
282 | 587 | + | ||
283 | 588 | +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
284 | 589 | +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
285 | 590 | +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
286 | 591 | +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
287 | 592 | +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
288 | 593 | +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
289 | 594 | +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
290 | 595 | + | ||
291 | 596 | +###################################### | ||
292 | 597 | +DROP TABLE t1, t2, t3, t4; | ||
293 | 398 | --- a/mysql-test/suite/innodb_plugin/r/innodb.result | 598 | --- a/mysql-test/suite/innodb_plugin/r/innodb.result |
294 | 399 | +++ b/mysql-test/suite/innodb_plugin/r/innodb.result | 599 | +++ b/mysql-test/suite/innodb_plugin/r/innodb.result |
295 | 400 | @@ -1679,7 +1679,7 @@ | 600 | @@ -1679,7 +1679,7 @@ |
296 | @@ -437,7 +637,7 @@ | |||
297 | 437 | # Save the original values of some variables in order to be able to | 637 | # Save the original values of some variables in order to be able to |
298 | 438 | --- /dev/null | 638 | --- /dev/null |
299 | 439 | +++ b/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test | 639 | +++ b/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test |
301 | 440 | @@ -0,0 +1,94 @@ | 640 | @@ -0,0 +1,155 @@ |
302 | 441 | +# Embedded server doesn't support external clients | 641 | +# Embedded server doesn't support external clients |
303 | 442 | +--source include/not_embedded.inc | 642 | +--source include/not_embedded.inc |
304 | 443 | + | 643 | + |
305 | @@ -530,6 +730,67 @@ | |||
306 | 530 | + | 730 | + |
307 | 531 | +DROP TABLE t1, t2; | 731 | +DROP TABLE t1, t2; |
308 | 532 | + | 732 | + |
309 | 733 | +######################################################################## | ||
310 | 734 | +# Bug #851674: --innodb-optimize-keys does not work correctly with table | ||
311 | 735 | +# without PRIMARY KEY | ||
312 | 736 | +######################################################################## | ||
313 | 737 | + | ||
314 | 738 | +CREATE TABLE t1 ( | ||
315 | 739 | + a INT NOT NULL, | ||
316 | 740 | + UNIQUE KEY (a)) ENGINE=InnoDB; | ||
317 | 741 | + | ||
318 | 742 | +CREATE TABLE t2 ( | ||
319 | 743 | + a INT NOT NULL, | ||
320 | 744 | + b INT NOT NULL, | ||
321 | 745 | + UNIQUE KEY (a,b)) ENGINE=InnoDB; | ||
322 | 746 | + | ||
323 | 747 | +CREATE TABLE t3 ( | ||
324 | 748 | + a INT, | ||
325 | 749 | + b INT, | ||
326 | 750 | + UNIQUE KEY (a,b)) ENGINE=InnoDB; | ||
327 | 751 | + | ||
328 | 752 | +CREATE TABLE t4 ( | ||
329 | 753 | + a INT NOT NULL, | ||
330 | 754 | + b INT NOT NULL, | ||
331 | 755 | + PRIMARY KEY (a,b), | ||
332 | 756 | + UNIQUE KEY(b)) ENGINE=InnoDB; | ||
333 | 757 | + | ||
334 | 758 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
335 | 759 | + TABLE_SCHEMA=DATABASE() AND | ||
336 | 760 | + TABLE_NAME='t1' AND | ||
337 | 761 | + COLUMN_KEY='PRI'; | ||
338 | 762 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
339 | 763 | + TABLE_SCHEMA=DATABASE() AND | ||
340 | 764 | + TABLE_NAME='t2' AND | ||
341 | 765 | + COLUMN_KEY='PRI'; | ||
342 | 766 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
343 | 767 | + TABLE_SCHEMA=DATABASE() AND | ||
344 | 768 | + TABLE_NAME='t3' AND | ||
345 | 769 | + COLUMN_KEY='PRI'; | ||
346 | 770 | +SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE | ||
347 | 771 | + TABLE_SCHEMA=DATABASE() AND | ||
348 | 772 | + TABLE_NAME='t4' AND | ||
349 | 773 | + COLUMN_KEY='PRI'; | ||
350 | 774 | + | ||
351 | 775 | +INSERT INTO t1 VALUES (1), (2), (3); | ||
352 | 776 | +INSERT INTO t2 VALUES (1,1), (2,2), (3,3); | ||
353 | 777 | +INSERT INTO t3 SELECT * FROM t2; | ||
354 | 778 | +INSERT INTO t4 SELECT * FROM t2; | ||
355 | 779 | + | ||
356 | 780 | +--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 t3 t4 >$file | ||
357 | 781 | + | ||
358 | 782 | +--echo ###################################### | ||
359 | 783 | +--cat_file $file | ||
360 | 784 | +--echo ###################################### | ||
361 | 785 | + | ||
362 | 786 | +# Check that the resulting dump can be imported back | ||
363 | 787 | + | ||
364 | 788 | +--exec $MYSQL test < $file | ||
365 | 789 | + | ||
366 | 790 | +--remove_file $file | ||
367 | 791 | + | ||
368 | 792 | +DROP TABLE t1, t2, t3, t4; | ||
369 | 793 | + | ||
370 | 533 | +# Wait till we reached the initial number of concurrent sessions | 794 | +# Wait till we reached the initial number of concurrent sessions |
371 | 534 | +--source include/wait_until_count_sessions.inc | 795 | +--source include/wait_until_count_sessions.inc |
372 | 535 | --- a/sql/sql_lex.cc | 796 | --- a/sql/sql_lex.cc |
http:// jenkins. percona. com/view/ Percona% 20Server% 205.1/job/ percona- server- 5.1-param/ 140/ is unavailable because build #139 has been stuck for 3 days.