Merge lp:~sergei.glushchenko/mysql-server/expand_fast_index_creation into lp:mysql-server/5.1

Proposed by Sergei Glushchenko
Status: Needs review
Proposed branch: lp:~sergei.glushchenko/mysql-server/expand_fast_index_creation
Merge into: lp:mysql-server/5.1
Diff against target: 1508 lines (+1160/-2)
20 files modified
client/client_priv.h (+1/-0)
client/mysqldump.c (+223/-0)
mysql-test/r/percona_innodb_expand_fast_index_creation.result (+67/-0)
mysql-test/r/percona_mysqldump_innodb_optimize_keys.result (+367/-0)
mysql-test/suite/innodb_plugin/r/percona_bug_999147.result (+8/-0)
mysql-test/suite/innodb_plugin/t/percona_bug_999147-master.opt (+1/-0)
mysql-test/suite/innodb_plugin/t/percona_bug_999147.test (+29/-0)
mysql-test/t/percona_innodb_expand_fast_index_creation.test (+46/-0)
mysql-test/t/percona_mysqldump_innodb_optimize_keys.test (+187/-0)
sql/mysqld.cc (+9/-1)
sql/set_var.cc (+4/-0)
sql/sql_class.h (+2/-0)
sql/sql_lex.cc (+4/-0)
sql/sql_lex.h (+8/-0)
sql/sql_table.cc (+171/-0)
storage/innodb_plugin/handler/ha_innodb.cc (+15/-0)
storage/innodb_plugin/handler/handler0alter.cc (+2/-0)
storage/innodb_plugin/include/ha_prototypes.h (+11/-0)
storage/innodb_plugin/row/row0merge.c (+4/-0)
storage/innodb_plugin/row/row0mysql.c (+1/-1)
To merge this branch: bzr merge lp:~sergei.glushchenko/mysql-server/expand_fast_index_creation
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+113247@code.launchpad.net

Description of the change

Patch expand_fast_index_creation.patch
Fix for bug #999147.

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Unmerged revisions

3733. By Sergei Glushchenko

port expand_fast_index_creation patch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'client/client_priv.h'
--- client/client_priv.h 2011-07-03 15:47:37 +0000
+++ client/client_priv.h 2012-07-03 16:14:26 +0000
@@ -94,5 +94,6 @@
94 OPT_WRITE_BINLOG, OPT_DUMP_DATE,94 OPT_WRITE_BINLOG, OPT_DUMP_DATE,
95 OPT_FIRST_SLAVE,95 OPT_FIRST_SLAVE,
96 OPT_ALL,96 OPT_ALL,
97 OPT_INNODB_OPTIMIZE_KEYS,
97 OPT_MAX_CLIENT_OPTION98 OPT_MAX_CLIENT_OPTION
98};99};
99100
=== modified file 'client/mysqldump.c'
--- client/mysqldump.c 2012-05-07 11:16:44 +0000
+++ client/mysqldump.c 2012-07-03 16:14:26 +0000
@@ -47,6 +47,7 @@
47#include <m_ctype.h>47#include <m_ctype.h>
48#include <hash.h>48#include <hash.h>
49#include <stdarg.h>49#include <stdarg.h>
50#include <my_list.h>
5051
51#include "client_priv.h"52#include "client_priv.h"
52#include "mysql.h"53#include "mysql.h"
@@ -148,6 +149,8 @@
148#endif149#endif
149static uint opt_protocol= 0;150static uint opt_protocol= 0;
150151
152static my_bool opt_innodb_optimize_keys= FALSE;
153
151/*154/*
152Dynamic_string wrapper functions. In this file use these155Dynamic_string wrapper functions. In this file use these
153wrappers, they will terminate the process if there is156wrappers, they will terminate the process if there is
@@ -193,6 +196,8 @@
193196
194HASH ignore_table;197HASH ignore_table;
195198
199LIST *skipped_keys_list;
200
196static struct my_option my_long_options[] =201static struct my_option my_long_options[] =
197{202{
198 {"all", OPT_ALL, "Deprecated. Use --create-options instead.",203 {"all", OPT_ALL, "Deprecated. Use --create-options instead.",
@@ -339,6 +344,11 @@
339 "be specified with both database and table names, e.g., "344 "be specified with both database and table names, e.g., "
340 "--ignore-table=database.table.",345 "--ignore-table=database.table.",
341 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},346 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
347 {"innodb-optimize-keys", OPT_INNODB_OPTIMIZE_KEYS,
348 "Use InnoDB fast index creation by creating secondary indexes after "
349 "dumping the data.",
350 &opt_innodb_optimize_keys, &opt_innodb_optimize_keys, 0, GET_BOOL, NO_ARG,
351 0, 0, 0, 0, 0, 0},
342 {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",352 {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
343 &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,353 &opt_ignore, &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
344 0, 0},354 0, 0},
@@ -2433,6 +2443,190 @@
2433}2443}
24342444
2435/*2445/*
2446 Parse the specified key definition string and check if the key indexes
2447 any of the columns from ignored_columns.
2448*/
2449static my_bool contains_ignored_column(HASH *ignored_columns, char *keydef)
2450{
2451 char *leftp, *rightp;
2452
2453 if ((leftp = strchr(keydef, '(')) &&
2454 (rightp = strchr(leftp, ')')) &&
2455 rightp > leftp + 3 && /* (`...`) */
2456 leftp[1] == '`' &&
2457 rightp[-1] == '`' &&
2458 my_hash_search(ignored_columns, (uchar *) leftp + 2, rightp - leftp - 3))
2459 return TRUE;
2460
2461 return FALSE;
2462}
2463
2464
2465/*
2466 Remove secondary/foreign key definitions from a given SHOW CREATE TABLE string
2467 and store them into a temporary list to be used later.
2468
2469 SYNOPSIS
2470 skip_secondary_keys()
2471 create_str SHOW CREATE TABLE output
2472 has_pk TRUE, if the table has PRIMARY KEY
2473 (or UNIQUE key on non-nullable columns)
2474
2475
2476 DESCRIPTION
2477
2478 Stores all lines starting with "KEY" or "UNIQUE KEY"
2479 into skipped_keys_list and removes them from the input string.
2480 Ignoring FOREIGN KEYS constraints when creating the table is ok, because
2481 mysqldump sets foreign_key_checks to 0 anyway.
2482*/
2483
2484static void skip_secondary_keys(char *create_str, my_bool has_pk)
2485{
2486 char *ptr, *strend;
2487 char *last_comma = NULL;
2488 HASH ignored_columns;
2489 my_bool pk_processed= FALSE;
2490
2491 if (hash_init(&ignored_columns, charset_info, 16, 0, 0,
2492 (hash_get_key) get_table_key,
2493 (hash_free_key) free_table_ent, 0))
2494 exit(EX_EOM);
2495
2496 strend= create_str + strlen(create_str);
2497
2498 ptr= create_str;
2499 while (*ptr)
2500 {
2501 char *tmp, *orig_ptr, c;
2502 my_bool is_unique= FALSE;
2503
2504 orig_ptr= ptr;
2505 /* Skip leading whitespace */
2506 while (*ptr && my_isspace(charset_info, *ptr))
2507 ptr++;
2508
2509 /* Read the next line */
2510 for (tmp= ptr; *tmp != '\n' && *tmp != '\0'; tmp++);
2511
2512 c= *tmp;
2513 *tmp= '\0'; /* so strstr() only processes the current line */
2514
2515 /* Is it a secondary index definition? */
2516 if (c == '\n' &&
2517 (((is_unique= !strncmp(ptr, "UNIQUE KEY ", sizeof("UNIQUE KEY ")-1)) &&
2518 (pk_processed || !has_pk)) ||
2519 !strncmp(ptr, "KEY ", sizeof("KEY ") - 1)) &&
2520 !contains_ignored_column(&ignored_columns, ptr))
2521 {
2522 char *data, *end= tmp - 1;
2523
2524 /* Remove the trailing comma */
2525 if (*end == ',')
2526 end--;
2527 data= my_strndup(ptr, end - ptr + 1, MYF(MY_FAE));
2528 skipped_keys_list= list_cons(data, skipped_keys_list);
2529
2530 memmove(orig_ptr, tmp + 1, strend - tmp);
2531 ptr= orig_ptr;
2532 strend-= tmp + 1 - ptr;
2533
2534 /* Remove the comma on the previos line */
2535 if (last_comma != NULL)
2536 {
2537 *last_comma= ' ';
2538 }
2539 }
2540 else
2541 {
2542 char *end;
2543
2544 if (last_comma != NULL && *ptr != ')')
2545 {
2546 /*
2547 It's not the last line of CREATE TABLE, so we have skipped a key
2548 definition. We have to restore the last removed comma.
2549 */
2550 *last_comma= ',';
2551 }
2552
2553 if ((has_pk && is_unique && !pk_processed) ||
2554 !strncmp(ptr, "PRIMARY KEY ", sizeof("PRIMARY KEY ") - 1))
2555 pk_processed= TRUE;
2556
2557 if (strstr(ptr, "AUTO_INCREMENT") && *ptr == '`')
2558 {
2559 /*
2560 If a secondary key is defined on this column later,
2561 it cannot be skipped, as CREATE TABLE would fail on import.
2562 */
2563 for (end= ptr + 1; *end != '`' && *end != '\0'; end++);
2564 if (*end == '`' && end > ptr + 1 &&
2565 my_hash_insert(&ignored_columns,
2566 (uchar *) my_strndup(ptr + 1,
2567 end - ptr - 1, MYF(0))))
2568 {
2569 exit(EX_EOM);
2570 }
2571 }
2572
2573 *tmp= c;
2574
2575 if (tmp[-1] == ',')
2576 last_comma= tmp - 1;
2577 ptr= (*tmp == '\0') ? tmp : tmp + 1;
2578 }
2579 }
2580
2581 my_hash_free(&ignored_columns);
2582}
2583
2584/*
2585 Check if the table has a primary key defined either explicitly or
2586 implicitly (i.e. a unique key on non-nullable columns).
2587
2588 SYNOPSIS
2589 my_bool has_primary_key(const char *table_name)
2590
2591 table_name quoted table name
2592
2593 RETURNS TRUE if the table has a primary key
2594
2595 DESCRIPTION
2596*/
2597
2598static my_bool has_primary_key(const char *table_name)
2599{
2600 MYSQL_RES *res= NULL;
2601 MYSQL_ROW row;
2602 char query_buff[QUERY_LENGTH];
2603 my_bool has_pk= TRUE;
2604
2605 my_snprintf(query_buff, sizeof(query_buff),
2606 "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE "
2607 "TABLE_SCHEMA=DATABASE() AND TABLE_NAME='%s' AND "
2608 "COLUMN_KEY='PRI'", table_name);
2609 if (mysql_query(mysql, query_buff) || !(res= mysql_store_result(mysql)) ||
2610 !(row= mysql_fetch_row(res)))
2611 {
2612 fprintf(stderr, "Warning: Couldn't determine if table %s has a "
2613 "primary key (%s). "
2614 "--innodb-optimize-keys may work inefficiently.\n",
2615 table_name, mysql_error(mysql));
2616 goto cleanup;
2617 }
2618
2619 has_pk= atoi(row[0]) > 0;
2620
2621cleanup:
2622 if (res)
2623 mysql_free_result(res);
2624
2625 return has_pk;
2626}
2627
2628
2629/*
2436 get_table_structure -- retrievs database structure, prints out corresponding2630 get_table_structure -- retrievs database structure, prints out corresponding
2437 CREATE statement and fills out insert_pat if the table is the type we will2631 CREATE statement and fills out insert_pat if the table is the type we will
2438 be dumping.2632 be dumping.
@@ -2470,6 +2664,7 @@
2470 my_bool is_log_table;2664 my_bool is_log_table;
2471 MYSQL_RES *result;2665 MYSQL_RES *result;
2472 MYSQL_ROW row;2666 MYSQL_ROW row;
2667 my_bool has_pk= FALSE;
2473 DBUG_ENTER("get_table_structure");2668 DBUG_ENTER("get_table_structure");
2474 DBUG_PRINT("enter", ("db: %s table: %s", db, table));2669 DBUG_PRINT("enter", ("db: %s table: %s", db, table));
24752670
@@ -2511,6 +2706,9 @@
2511 result_table= quote_name(table, table_buff, 1);2706 result_table= quote_name(table, table_buff, 1);
2512 opt_quoted_table= quote_name(table, table_buff2, 0);2707 opt_quoted_table= quote_name(table, table_buff2, 0);
25132708
2709 if (opt_innodb_optimize_keys && !strcmp(table_type, "InnoDB"))
2710 has_pk= has_primary_key(table);
2711
2514 if (opt_order_by_primary)2712 if (opt_order_by_primary)
2515 order_by= primary_key_fields(result_table);2713 order_by= primary_key_fields(result_table);
25162714
@@ -2672,6 +2870,10 @@
2672 is_log_table= general_log_or_slow_log_tables(db, table);2870 is_log_table= general_log_or_slow_log_tables(db, table);
2673 if (is_log_table)2871 if (is_log_table)
2674 row[1]+= 13; /* strlen("CREATE TABLE ")= 13 */2872 row[1]+= 13; /* strlen("CREATE TABLE ")= 13 */
2873
2874 if (opt_innodb_optimize_keys && !strcmp(table_type, "InnoDB"))
2875 skip_secondary_keys(row[1], has_pk);
2876
2675 if (opt_compatible_mode & 3)2877 if (opt_compatible_mode & 3)
2676 {2878 {
2677 fprintf(sql_file,2879 fprintf(sql_file,
@@ -3788,6 +3990,27 @@
3788 goto err;3990 goto err;
3789 }3991 }
37903992
3993 /* Perform delayed secondary index creation for --innodb-optimize-keys */
3994 if (skipped_keys_list)
3995 {
3996 uint keys;
3997 skipped_keys_list= list_reverse(skipped_keys_list);
3998 fprintf(md_result_file, "ALTER TABLE %s ", opt_quoted_table);
3999 for (keys= list_length(skipped_keys_list); keys > 0; keys--)
4000 {
4001 LIST *node= skipped_keys_list;
4002 char *def= node->data;
4003
4004 fprintf(md_result_file, "ADD %s%s", def, (keys > 1) ? ", " : ";\n");
4005
4006 skipped_keys_list= list_delete(skipped_keys_list, node);
4007 my_free(def, MYF(0));
4008 my_free(node, MYF(0));
4009 }
4010
4011 DBUG_ASSERT(skipped_keys_list == NULL);
4012 }
4013
3791 /* Moved enable keys to before unlock per bug 15977 */4014 /* Moved enable keys to before unlock per bug 15977 */
3792 if (opt_disable_keys)4015 if (opt_disable_keys)
3793 {4016 {
37944017
=== added file 'mysql-test/r/percona_innodb_expand_fast_index_creation.result'
--- mysql-test/r/percona_innodb_expand_fast_index_creation.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/percona_innodb_expand_fast_index_creation.result 2012-07-03 16:14:26 +0000
@@ -0,0 +1,67 @@
1SELECT @@expand_fast_index_creation;
2@@expand_fast_index_creation
30
4CREATE TABLE t1(
5id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
6a CHAR(1) NOT NULL,
7b CHAR(36) NOT NULL) ENGINE=InnoDB;
8INSERT INTO t1(a,b) VALUES ('a','b');
9INSERT INTO t1(a,b) SELECT a,b FROM t1;
10INSERT INTO t1(a,b) SELECT a,b FROM t1;
11INSERT INTO t1(a,b) SELECT a,b FROM t1;
12INSERT INTO t1(a,b) SELECT a,b FROM t1;
13ALTER TABLE t1 ADD KEY (a);
14affected rows: 0
15info: Records: 0 Duplicates: 0 Warnings: 0
16EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
17id 1
18select_type SIMPLE
19table t1
20type ALL
21possible_keys a
22key NULL
23key_len NULL
24ref NULL
25rows 16
26Extra
27id 1
28select_type SIMPLE
29table t2
30type ref
31possible_keys a
32key a
33key_len 1
34ref test.t1.a
35rows 1
36Extra Using where
37ALTER TABLE t1 DROP KEY a;
38SET expand_fast_index_creation = 1;
39SELECT @@expand_fast_index_creation;
40@@expand_fast_index_creation
411
42ALTER TABLE t1 ADD KEY (a);
43affected rows: 0
44info: Records: 0 Duplicates: 0 Warnings: 0
45EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
46id 1
47select_type SIMPLE
48table t1
49type ALL
50possible_keys a
51key NULL
52key_len NULL
53ref NULL
54rows 16
55Extra
56id 1
57select_type SIMPLE
58table t2
59type ALL
60possible_keys a
61key NULL
62key_len NULL
63ref NULL
64rows 16
65Extra Using where; Using join buffer
66SET expand_fast_index_creation = 0;
67DROP TABLE t1;
068
=== added file 'mysql-test/r/percona_mysqldump_innodb_optimize_keys.result'
--- mysql-test/r/percona_mysqldump_innodb_optimize_keys.result 1970-01-01 00:00:00 +0000
+++ mysql-test/r/percona_mysqldump_innodb_optimize_keys.result 2012-07-03 16:14:26 +0000
@@ -0,0 +1,367 @@
1#
2# Test the --innodb-optimize-keys option.
3#
4CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, KEY(b)) ENGINE=MyISAM;
5######################################
6
7/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10/*!40101 SET NAMES utf8 */;
11/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12/*!40103 SET TIME_ZONE='+00:00' */;
13/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17DROP TABLE IF EXISTS `t1`;
18/*!40101 SET @saved_cs_client = @@character_set_client */;
19/*!40101 SET character_set_client = utf8 */;
20CREATE TABLE `t1` (
21 `a` int(11) NOT NULL,
22 `b` int(11) DEFAULT NULL,
23 PRIMARY KEY (`a`),
24 KEY `b` (`b`)
25) ENGINE=MyISAM DEFAULT CHARSET=latin1;
26/*!40101 SET character_set_client = @saved_cs_client */;
27
28LOCK TABLES `t1` WRITE;
29/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
30/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
31UNLOCK TABLES;
32/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
33
34/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
35/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
36/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
37/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
38/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
39/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
40/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
41
42######################################
43DROP TABLE t1;
44CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
45INSERT INTO t2 VALUES (0), (1), (2);
46CREATE TABLE t1 (
47id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
48a INT, b VARCHAR(255), c DECIMAL(10,3),
49KEY (b),
50UNIQUE KEY uniq(c,a),
51FOREIGN KEY (a) REFERENCES t2(a) ON DELETE CASCADE
52) ENGINE=InnoDB;
53INSERT INTO t1(a,b,c) VALUES (0, "0", 0.0), (1, "1", 1.1), (2, "2", 2.2);
54######################################
55
56/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
57/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
58/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
59/*!40101 SET NAMES utf8 */;
60/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
61/*!40103 SET TIME_ZONE='+00:00' */;
62/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
63/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
64/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
65/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
66DROP TABLE IF EXISTS `t1`;
67/*!40101 SET @saved_cs_client = @@character_set_client */;
68/*!40101 SET character_set_client = utf8 */;
69CREATE TABLE `t1` (
70 `id` int(11) NOT NULL AUTO_INCREMENT,
71 `a` int(11) DEFAULT NULL,
72 `b` varchar(255) DEFAULT NULL,
73 `c` decimal(10,3) DEFAULT NULL,
74 PRIMARY KEY (`id`),
75 CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t2` (`a`) ON DELETE CASCADE
76) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
77/*!40101 SET character_set_client = @saved_cs_client */;
78
79LOCK TABLES `t1` WRITE;
80/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
81INSERT INTO `t1` VALUES (1,0,'0','0.000'),(2,1,'1','1.100'),(3,2,'2','2.200');
82ALTER TABLE `t1` ADD UNIQUE KEY `uniq` (`c`,`a`), ADD KEY `b` (`b`), ADD KEY `a` (`a`);
83/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
84UNLOCK TABLES;
85DROP TABLE IF EXISTS `t2`;
86/*!40101 SET @saved_cs_client = @@character_set_client */;
87/*!40101 SET character_set_client = utf8 */;
88CREATE TABLE `t2` (
89 `a` int(11) NOT NULL,
90 PRIMARY KEY (`a`)
91) ENGINE=InnoDB DEFAULT CHARSET=latin1;
92/*!40101 SET character_set_client = @saved_cs_client */;
93
94LOCK TABLES `t2` WRITE;
95/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
96INSERT INTO `t2` VALUES (0),(1),(2);
97/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
98UNLOCK TABLES;
99/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
100
101/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
102/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
103/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
104/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
105/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
106/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
107/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
108
109######################################
110DROP TABLE t1, t2;
111CREATE TABLE t1 (
112id INT NOT NULL AUTO_INCREMENT,
113KEY (id)
114) ENGINE=InnoDB;
115CREATE TABLE t2 (
116id INT NOT NULL AUTO_INCREMENT,
117UNIQUE KEY (id)
118) ENGINE=InnoDB;
119INSERT INTO t1 VALUES (), (), ();
120INSERT INTO t2 VALUES (), (), ();
121######################################
122
123/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
124/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
125/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
126/*!40101 SET NAMES utf8 */;
127/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
128/*!40103 SET TIME_ZONE='+00:00' */;
129/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
130/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
131/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
132/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
133DROP TABLE IF EXISTS `t1`;
134/*!40101 SET @saved_cs_client = @@character_set_client */;
135/*!40101 SET character_set_client = utf8 */;
136CREATE TABLE `t1` (
137 `id` int(11) NOT NULL AUTO_INCREMENT,
138 KEY `id` (`id`)
139) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
140/*!40101 SET character_set_client = @saved_cs_client */;
141
142LOCK TABLES `t1` WRITE;
143/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
144INSERT INTO `t1` VALUES (1),(2),(3);
145/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
146UNLOCK TABLES;
147DROP TABLE IF EXISTS `t2`;
148/*!40101 SET @saved_cs_client = @@character_set_client */;
149/*!40101 SET character_set_client = utf8 */;
150CREATE TABLE `t2` (
151 `id` int(11) NOT NULL AUTO_INCREMENT,
152 UNIQUE KEY `id` (`id`)
153) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
154/*!40101 SET character_set_client = @saved_cs_client */;
155
156LOCK TABLES `t2` WRITE;
157/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
158INSERT INTO `t2` VALUES (1),(2),(3);
159/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
160UNLOCK TABLES;
161/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
162
163/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
164/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
165/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
166/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
167/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
168/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
169/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
170
171######################################
172DROP TABLE t1, t2;
173CREATE TABLE t1 (
174a INT NOT NULL,
175UNIQUE KEY (a)) ENGINE=InnoDB;
176CREATE TABLE t2 (
177a INT NOT NULL,
178b INT NOT NULL,
179UNIQUE KEY (a,b)) ENGINE=InnoDB;
180CREATE TABLE t3 (
181a INT,
182b INT,
183UNIQUE KEY (a,b)) ENGINE=InnoDB;
184CREATE TABLE t4 (
185a INT NOT NULL,
186b INT NOT NULL,
187PRIMARY KEY (a,b),
188UNIQUE KEY(b)) ENGINE=InnoDB;
189SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
190TABLE_SCHEMA=DATABASE() AND
191TABLE_NAME='t1' AND
192COLUMN_KEY='PRI';
193COUNT(*)
1941
195SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
196TABLE_SCHEMA=DATABASE() AND
197TABLE_NAME='t2' AND
198COLUMN_KEY='PRI';
199COUNT(*)
2002
201SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
202TABLE_SCHEMA=DATABASE() AND
203TABLE_NAME='t3' AND
204COLUMN_KEY='PRI';
205COUNT(*)
2060
207SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
208TABLE_SCHEMA=DATABASE() AND
209TABLE_NAME='t4' AND
210COLUMN_KEY='PRI';
211COUNT(*)
2122
213INSERT INTO t1 VALUES (1), (2), (3);
214INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
215INSERT INTO t3 SELECT * FROM t2;
216INSERT INTO t4 SELECT * FROM t2;
217######################################
218
219/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
220/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
221/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
222/*!40101 SET NAMES utf8 */;
223/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
224/*!40103 SET TIME_ZONE='+00:00' */;
225/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
226/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
227/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
228/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
229DROP TABLE IF EXISTS `t1`;
230/*!40101 SET @saved_cs_client = @@character_set_client */;
231/*!40101 SET character_set_client = utf8 */;
232CREATE TABLE `t1` (
233 `a` int(11) NOT NULL,
234 UNIQUE KEY `a` (`a`)
235) ENGINE=InnoDB DEFAULT CHARSET=latin1;
236/*!40101 SET character_set_client = @saved_cs_client */;
237
238LOCK TABLES `t1` WRITE;
239/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
240INSERT INTO `t1` VALUES (1),(2),(3);
241/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
242UNLOCK TABLES;
243DROP TABLE IF EXISTS `t2`;
244/*!40101 SET @saved_cs_client = @@character_set_client */;
245/*!40101 SET character_set_client = utf8 */;
246CREATE TABLE `t2` (
247 `a` int(11) NOT NULL,
248 `b` int(11) NOT NULL,
249 UNIQUE KEY `a` (`a`,`b`)
250) ENGINE=InnoDB DEFAULT CHARSET=latin1;
251/*!40101 SET character_set_client = @saved_cs_client */;
252
253LOCK TABLES `t2` WRITE;
254/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
255INSERT INTO `t2` VALUES (1,1),(2,2),(3,3);
256/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
257UNLOCK TABLES;
258DROP TABLE IF EXISTS `t3`;
259/*!40101 SET @saved_cs_client = @@character_set_client */;
260/*!40101 SET character_set_client = utf8 */;
261CREATE TABLE `t3` (
262 `a` int(11) DEFAULT NULL,
263 `b` int(11) DEFAULT NULL
264) ENGINE=InnoDB DEFAULT CHARSET=latin1;
265/*!40101 SET character_set_client = @saved_cs_client */;
266
267LOCK TABLES `t3` WRITE;
268/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
269INSERT INTO `t3` VALUES (1,1),(2,2),(3,3);
270ALTER TABLE `t3` ADD UNIQUE KEY `a` (`a`,`b`);
271/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
272UNLOCK TABLES;
273DROP TABLE IF EXISTS `t4`;
274/*!40101 SET @saved_cs_client = @@character_set_client */;
275/*!40101 SET character_set_client = utf8 */;
276CREATE TABLE `t4` (
277 `a` int(11) NOT NULL,
278 `b` int(11) NOT NULL,
279 PRIMARY KEY (`a`,`b`)
280) ENGINE=InnoDB DEFAULT CHARSET=latin1;
281/*!40101 SET character_set_client = @saved_cs_client */;
282
283LOCK TABLES `t4` WRITE;
284/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
285INSERT INTO `t4` VALUES (1,1),(2,2),(3,3);
286ALTER TABLE `t4` ADD UNIQUE KEY `b` (`b`);
287/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
288UNLOCK TABLES;
289/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
290
291/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
292/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
293/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
294/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
295/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
296/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
297/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
298
299######################################
300DROP TABLE t1, t2, t3, t4;
301CREATE TABLE t1 (
302id INT NOT NULL PRIMARY KEY
303) ENGINE=InnoDB;
304CREATE TABLE t2 (
305id INT NOT NULL AUTO_INCREMENT,
306a INT NOT NULL,
307PRIMARY KEY (id),
308KEY (a),
309FOREIGN KEY (a) REFERENCES t2 (id)
310) ENGINE=InnoDB;
311INSERT INTO t1 VALUES (1), (2), (3);
312INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
313######################################
314
315/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
316/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
317/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
318/*!40101 SET NAMES utf8 */;
319/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
320/*!40103 SET TIME_ZONE='+00:00' */;
321/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
322/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
323/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
324/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
325DROP TABLE IF EXISTS `t1`;
326/*!40101 SET @saved_cs_client = @@character_set_client */;
327/*!40101 SET character_set_client = utf8 */;
328CREATE TABLE `t1` (
329 `id` int(11) NOT NULL,
330 PRIMARY KEY (`id`)
331) ENGINE=InnoDB DEFAULT CHARSET=latin1;
332/*!40101 SET character_set_client = @saved_cs_client */;
333
334LOCK TABLES `t1` WRITE;
335/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
336INSERT INTO `t1` VALUES (1),(2),(3);
337/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
338UNLOCK TABLES;
339DROP TABLE IF EXISTS `t2`;
340/*!40101 SET @saved_cs_client = @@character_set_client */;
341/*!40101 SET character_set_client = utf8 */;
342CREATE TABLE `t2` (
343 `id` int(11) NOT NULL AUTO_INCREMENT,
344 `a` int(11) NOT NULL,
345 PRIMARY KEY (`id`),
346 CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t2` (`id`)
347) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
348/*!40101 SET character_set_client = @saved_cs_client */;
349
350LOCK TABLES `t2` WRITE;
351/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
352INSERT INTO `t2` VALUES (1,1),(2,2),(3,3);
353ALTER TABLE `t2` ADD KEY `a` (`a`);
354/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
355UNLOCK TABLES;
356/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
357
358/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
359/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
360/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
361/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
362/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
363/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
364/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
365
366######################################
367DROP TABLE t1, t2;
0368
=== added file 'mysql-test/suite/innodb_plugin/r/percona_bug_999147.result'
--- mysql-test/suite/innodb_plugin/r/percona_bug_999147.result 1970-01-01 00:00:00 +0000
+++ mysql-test/suite/innodb_plugin/r/percona_bug_999147.result 2012-07-03 16:14:26 +0000
@@ -0,0 +1,8 @@
1DROP TABLE IF EXISTS t1;
2SET SESSION expand_fast_index_creation=ON;
3CREATE TEMPORARY TABLE t1 (a INT, b INT, INDEX(a)) ENGINE=InnoDB;
4SET debug="+d,crash_innodb_add_index_after";
5ALTER TABLE t1 ADD INDEX (b);
6ERROR HY000: Lost connection to MySQL server during query
7SHOW TABLES;
8Tables_in_test
09
=== added file 'mysql-test/suite/innodb_plugin/t/percona_bug_999147-master.opt'
--- mysql-test/suite/innodb_plugin/t/percona_bug_999147-master.opt 1970-01-01 00:00:00 +0000
+++ mysql-test/suite/innodb_plugin/t/percona_bug_999147-master.opt 2012-07-03 16:14:26 +0000
@@ -0,0 +1,1 @@
1--skip-stack-trace --skip-core-file --innodb-file-per-table=1
02
=== added file 'mysql-test/suite/innodb_plugin/t/percona_bug_999147.test'
--- mysql-test/suite/innodb_plugin/t/percona_bug_999147.test 1970-01-01 00:00:00 +0000
+++ mysql-test/suite/innodb_plugin/t/percona_bug_999147.test 2012-07-03 16:14:26 +0000
@@ -0,0 +1,29 @@
1# Test for Percona Server bug 999147 (A crash that leaves behind an
2# InnoDB temporary table with indexes results in an unbootable server)
3# https://bugs.launchpad.net/percona-server/+bug/999147
4
5-- source include/not_embedded.inc
6-- source include/not_valgrind.inc
7-- source include/not_crashrep.inc
8-- source include/have_debug.inc
9-- source include/have_innodb_plugin.inc
10
11--disable_warnings
12DROP TABLE IF EXISTS t1;
13--enable_warnings
14
15SET SESSION expand_fast_index_creation=ON;
16
17CREATE TEMPORARY TABLE t1 (a INT, b INT, INDEX(a)) ENGINE=InnoDB;
18
19--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
20
21SET debug="+d,crash_innodb_add_index_after";
22--error 2013
23ALTER TABLE t1 ADD INDEX (b);
24
25--enable_reconnect
26
27--source include/wait_until_connected_again.inc
28
29SHOW TABLES;
030
=== added file 'mysql-test/t/percona_innodb_expand_fast_index_creation.test'
--- mysql-test/t/percona_innodb_expand_fast_index_creation.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/percona_innodb_expand_fast_index_creation.test 2012-07-03 16:14:26 +0000
@@ -0,0 +1,46 @@
1--source include/have_innodb_plugin.inc
2
3SELECT @@expand_fast_index_creation;
4
5########################################################################
6# Bug #857590: Fast index creation does not update index statistics
7########################################################################
8
9CREATE TABLE t1(
10 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
11 a CHAR(1) NOT NULL,
12 b CHAR(36) NOT NULL) ENGINE=InnoDB;
13
14INSERT INTO t1(a,b) VALUES ('a','b');
15INSERT INTO t1(a,b) SELECT a,b FROM t1;
16INSERT INTO t1(a,b) SELECT a,b FROM t1;
17INSERT INTO t1(a,b) SELECT a,b FROM t1;
18INSERT INTO t1(a,b) SELECT a,b FROM t1;
19
20# Check that fast index creation is used
21--enable_info
22ALTER TABLE t1 ADD KEY (a);
23--disable_info
24
25# The default (wrong) plan due to bogus statistics
26--vertical_results
27EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
28--horizontal_results
29
30ALTER TABLE t1 DROP KEY a;
31
32SET expand_fast_index_creation = 1;
33SELECT @@expand_fast_index_creation;
34
35# Check that stats are updated with the option enabled
36
37--enable_info
38ALTER TABLE t1 ADD KEY (a);
39--disable_info
40--vertical_results
41EXPLAIN SELECT COUNT(*) FROM t1, t1 t2 WHERE t1.a = t2.a AND t1.b = t2.b;
42--horizontal_results
43
44SET expand_fast_index_creation = 0;
45
46DROP TABLE t1;
047
=== added file 'mysql-test/t/percona_mysqldump_innodb_optimize_keys.test'
--- mysql-test/t/percona_mysqldump_innodb_optimize_keys.test 1970-01-01 00:00:00 +0000
+++ mysql-test/t/percona_mysqldump_innodb_optimize_keys.test 2012-07-03 16:14:26 +0000
@@ -0,0 +1,187 @@
1# Embedded server doesn't support external clients
2--source include/not_embedded.inc
3
4# Fast index creation is only available in InnoDB plugin
5--source include/have_innodb_plugin.inc
6
7# Save the initial number of concurrent sessions
8--source include/count_sessions.inc
9
10--echo #
11--echo # Test the --innodb-optimize-keys option.
12--echo #
13
14--let $file=$MYSQLTEST_VARDIR/tmp/t1.sql
15
16# First test that the option has no effect on non-InnoDB tables
17
18CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT, KEY(b)) ENGINE=MyISAM;
19
20--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 >$file
21
22--echo ######################################
23--cat_file $file
24--echo ######################################
25
26--remove_file $file
27
28DROP TABLE t1;
29
30# Check that for InnoDB tables secondary keys are created after the data is
31# dumped but foreign ones are left in CREATE TABLE
32
33CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
34INSERT INTO t2 VALUES (0), (1), (2);
35
36CREATE TABLE t1 (
37 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
38 a INT, b VARCHAR(255), c DECIMAL(10,3),
39 KEY (b),
40 UNIQUE KEY uniq(c,a),
41 FOREIGN KEY (a) REFERENCES t2(a) ON DELETE CASCADE
42) ENGINE=InnoDB;
43
44INSERT INTO t1(a,b,c) VALUES (0, "0", 0.0), (1, "1", 1.1), (2, "2", 2.2);
45
46--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
47
48--echo ######################################
49--cat_file $file
50--echo ######################################
51
52# Check that the resulting dump can be imported back
53
54--exec $MYSQL test < $file
55
56--remove_file $file
57
58DROP TABLE t1, t2;
59
60########################################################################
61# Bug #812179: AUTO_INCREMENT columns must be skipped by the
62# --innodb-optimize-keys optimization in mysqldump
63########################################################################
64
65CREATE TABLE t1 (
66 id INT NOT NULL AUTO_INCREMENT,
67 KEY (id)
68) ENGINE=InnoDB;
69
70CREATE TABLE t2 (
71 id INT NOT NULL AUTO_INCREMENT,
72 UNIQUE KEY (id)
73) ENGINE=InnoDB;
74
75INSERT INTO t1 VALUES (), (), ();
76INSERT INTO t2 VALUES (), (), ();
77
78--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
79
80--echo ######################################
81--cat_file $file
82--echo ######################################
83
84# Check that the resulting dump can be imported back
85
86--exec $MYSQL test < $file
87
88--remove_file $file
89
90DROP TABLE t1, t2;
91
92########################################################################
93# Bug #851674: --innodb-optimize-keys does not work correctly with table
94# without PRIMARY KEY
95########################################################################
96
97CREATE TABLE t1 (
98 a INT NOT NULL,
99 UNIQUE KEY (a)) ENGINE=InnoDB;
100
101CREATE TABLE t2 (
102 a INT NOT NULL,
103 b INT NOT NULL,
104 UNIQUE KEY (a,b)) ENGINE=InnoDB;
105
106CREATE TABLE t3 (
107 a INT,
108 b INT,
109 UNIQUE KEY (a,b)) ENGINE=InnoDB;
110
111CREATE TABLE t4 (
112 a INT NOT NULL,
113 b INT NOT NULL,
114 PRIMARY KEY (a,b),
115 UNIQUE KEY(b)) ENGINE=InnoDB;
116
117SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
118 TABLE_SCHEMA=DATABASE() AND
119 TABLE_NAME='t1' AND
120 COLUMN_KEY='PRI';
121SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
122 TABLE_SCHEMA=DATABASE() AND
123 TABLE_NAME='t2' AND
124 COLUMN_KEY='PRI';
125SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
126 TABLE_SCHEMA=DATABASE() AND
127 TABLE_NAME='t3' AND
128 COLUMN_KEY='PRI';
129SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE
130 TABLE_SCHEMA=DATABASE() AND
131 TABLE_NAME='t4' AND
132 COLUMN_KEY='PRI';
133
134INSERT INTO t1 VALUES (1), (2), (3);
135INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
136INSERT INTO t3 SELECT * FROM t2;
137INSERT INTO t4 SELECT * FROM t2;
138
139--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 t3 t4 >$file
140
141--echo ######################################
142--cat_file $file
143--echo ######################################
144
145# Check that the resulting dump can be imported back
146
147--exec $MYSQL test < $file
148
149--remove_file $file
150
151DROP TABLE t1, t2, t3, t4;
152
153########################################################################
154# Bug #859078: --innodb-optimize-keys should ignore foreign keys
155########################################################################
156
157CREATE TABLE t1 (
158 id INT NOT NULL PRIMARY KEY
159) ENGINE=InnoDB;
160
161CREATE TABLE t2 (
162 id INT NOT NULL AUTO_INCREMENT,
163 a INT NOT NULL,
164 PRIMARY KEY (id),
165 KEY (a),
166 FOREIGN KEY (a) REFERENCES t2 (id)
167) ENGINE=InnoDB;
168
169INSERT INTO t1 VALUES (1), (2), (3);
170INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3);
171
172--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys test t1 t2 >$file
173
174--echo ######################################
175--cat_file $file
176--echo ######################################
177
178# Check that the resulting dump can be imported back
179
180--exec $MYSQL test < $file
181
182--remove_file $file
183
184DROP TABLE t1, t2;
185
186# Wait till we reached the initial number of concurrent sessions
187--source include/wait_until_count_sessions.inc
0188
=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc 2012-03-08 15:16:53 +0000
+++ sql/mysqld.cc 2012-07-03 16:14:26 +0000
@@ -5667,7 +5667,8 @@
5667 OPT_IGNORE_BUILTIN_INNODB,5667 OPT_IGNORE_BUILTIN_INNODB,
5668 OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,5668 OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
5669 OPT_DEFAULT_CHARACTER_SET_OLD,5669 OPT_DEFAULT_CHARACTER_SET_OLD,
5670 OPT_MAX_LONG_DATA_SIZE5670 OPT_MAX_LONG_DATA_SIZE,
5671 OPT_EXPAND_FAST_INDEX_CREATION
5671};5672};
56725673
56735674
@@ -5896,6 +5897,13 @@
5896each time the SQL thread starts.",5897each time the SQL thread starts.",
5897 &opt_init_slave, &opt_init_slave, 0, GET_STR_ALLOC,5898 &opt_init_slave, &opt_init_slave, 0, GET_STR_ALLOC,
5898 REQUIRED_ARG, 0, 0, 0, 0, 0, 0},5899 REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
5900 {"expand-fast-index-creation", OPT_EXPAND_FAST_INDEX_CREATION,
5901 "Enable/disable improvements to the InnoDB fast index creation functionality. "
5902 "Has no effect when fast index creation is disabled with the "
5903 "fast-index-creation option",
5904 &global_system_variables.expand_fast_index_creation,
5905 &max_system_variables.expand_fast_index_creation,
5906 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, NULL},
5899 {"language", 'L',5907 {"language", 'L',
5900 "Client error messages in given language. May be given as a full path.",5908 "Client error messages in given language. May be given as a full path.",
5901 &language_ptr, &language_ptr, 0, GET_STR, REQUIRED_ARG,5909 &language_ptr, &language_ptr, 0, GET_STR, REQUIRED_ARG,
59025910
=== modified file 'sql/set_var.cc'
--- sql/set_var.cc 2011-07-03 15:47:37 +0000
+++ sql/set_var.cc 2012-07-03 16:14:26 +0000
@@ -921,6 +921,10 @@
921 SHOW_LONGLONG,921 SHOW_LONGLONG,
922 get_myisam_mmap_size);922 get_myisam_mmap_size);
923923
924static sys_var_thd_bool
925sys_expand_fast_index_creation(&vars,
926 "expand_fast_index_creation", &SV::expand_fast_index_creation);
927
924928
925bool sys_var::check(THD *thd, set_var *var)929bool sys_var::check(THD *thd, set_var *var)
926{930{
927931
=== modified file 'sql/sql_class.h'
--- sql/sql_class.h 2012-04-20 16:41:20 +0000
+++ sql/sql_class.h 2012-07-03 16:14:26 +0000
@@ -404,6 +404,8 @@
404 DATE_TIME_FORMAT *datetime_format;404 DATE_TIME_FORMAT *datetime_format;
405 DATE_TIME_FORMAT *time_format;405 DATE_TIME_FORMAT *time_format;
406 my_bool sysdate_is_now;406 my_bool sysdate_is_now;
407
408 my_bool expand_fast_index_creation;
407};409};
408410
409411
410412
=== modified file 'sql/sql_lex.cc'
--- sql/sql_lex.cc 2012-04-18 11:14:05 +0000
+++ sql/sql_lex.cc 2012-07-03 16:14:26 +0000
@@ -1498,6 +1498,9 @@
1498 alter_list(rhs.alter_list, mem_root),1498 alter_list(rhs.alter_list, mem_root),
1499 key_list(rhs.key_list, mem_root),1499 key_list(rhs.key_list, mem_root),
1500 create_list(rhs.create_list, mem_root),1500 create_list(rhs.create_list, mem_root),
1501 delayed_key_list(rhs.delayed_key_list, mem_root),
1502 delayed_key_info(rhs.delayed_key_info),
1503 delayed_key_count(rhs.delayed_key_count),
1501 flags(rhs.flags),1504 flags(rhs.flags),
1502 keys_onoff(rhs.keys_onoff),1505 keys_onoff(rhs.keys_onoff),
1503 tablespace_op(rhs.tablespace_op),1506 tablespace_op(rhs.tablespace_op),
@@ -1520,6 +1523,7 @@
1520 list_copy_and_replace_each_value(alter_list, mem_root);1523 list_copy_and_replace_each_value(alter_list, mem_root);
1521 list_copy_and_replace_each_value(key_list, mem_root);1524 list_copy_and_replace_each_value(key_list, mem_root);
1522 list_copy_and_replace_each_value(create_list, mem_root);1525 list_copy_and_replace_each_value(create_list, mem_root);
1526 list_copy_and_replace_each_value(delayed_key_list, mem_root);
1523 /* partition_names are not deeply copied currently */1527 /* partition_names are not deeply copied currently */
1524}1528}
15251529
15261530
=== modified file 'sql/sql_lex.h'
--- sql/sql_lex.h 2012-04-18 11:14:05 +0000
+++ sql/sql_lex.h 2012-07-03 16:14:26 +0000
@@ -911,6 +911,9 @@
911 List<Alter_column> alter_list;911 List<Alter_column> alter_list;
912 List<Key> key_list;912 List<Key> key_list;
913 List<Create_field> create_list;913 List<Create_field> create_list;
914 List<Key> delayed_key_list;
915 KEY *delayed_key_info;
916 uint delayed_key_count;
914 uint flags;917 uint flags;
915 enum enum_enable_or_disable keys_onoff;918 enum enum_enable_or_disable keys_onoff;
916 enum tablespace_op_type tablespace_op;919 enum tablespace_op_type tablespace_op;
@@ -922,6 +925,8 @@
922925
923926
924 Alter_info() :927 Alter_info() :
928 delayed_key_info(NULL),
929 delayed_key_count(0),
925 flags(0),930 flags(0),
926 keys_onoff(LEAVE_AS_IS),931 keys_onoff(LEAVE_AS_IS),
927 tablespace_op(NO_TABLESPACE_OP),932 tablespace_op(NO_TABLESPACE_OP),
@@ -937,6 +942,9 @@
937 alter_list.empty();942 alter_list.empty();
938 key_list.empty();943 key_list.empty();
939 create_list.empty();944 create_list.empty();
945 delayed_key_list.empty();
946 delayed_key_info= NULL;
947 delayed_key_count= 0;
940 flags= 0;948 flags= 0;
941 keys_onoff= LEAVE_AS_IS;949 keys_onoff= LEAVE_AS_IS;
942 tablespace_op= NO_TABLESPACE_OP;950 tablespace_op= NO_TABLESPACE_OP;
943951
=== modified file 'sql/sql_table.cc'
--- sql/sql_table.cc 2012-02-15 16:21:38 +0000
+++ sql/sql_table.cc 2012-07-03 16:14:26 +0000
@@ -3016,6 +3016,14 @@
3016 if (!*key_info_buffer || ! key_part_info)3016 if (!*key_info_buffer || ! key_part_info)
3017 DBUG_RETURN(TRUE); // Out of memory3017 DBUG_RETURN(TRUE); // Out of memory
30183018
3019 List_iterator<Key> delayed_key_iterator(alter_info->delayed_key_list);
3020 alter_info->delayed_key_count= 0;
3021 if (alter_info->delayed_key_list.elements > 0)
3022 {
3023 alter_info->delayed_key_info= (KEY *) sql_calloc(sizeof(KEY) *
3024 (*key_count));
3025 }
3026
3019 key_iterator.rewind();3027 key_iterator.rewind();
3020 key_number=0;3028 key_number=0;
3021 for (; (key=key_iterator++) ; key_number++)3029 for (; (key=key_iterator++) ; key_number++)
@@ -3394,6 +3402,23 @@
3394 my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);3402 my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
3395 DBUG_RETURN(TRUE);3403 DBUG_RETURN(TRUE);
3396 }3404 }
3405
3406 if (alter_info->delayed_key_list.elements > 0)
3407 {
3408 Key *delayed_key;
3409
3410 delayed_key_iterator.rewind();
3411 while ((delayed_key= delayed_key_iterator++))
3412 {
3413 if (delayed_key == key)
3414 {
3415 alter_info->delayed_key_info[alter_info->delayed_key_count++]=
3416 *key_info;
3417 break;
3418 }
3419 }
3420 }
3421
3397 key_info++;3422 key_info++;
3398 }3423 }
3399 if (!unique_key && !primary_key &&3424 if (!unique_key && !primary_key &&
@@ -6099,6 +6124,10 @@
6099 List<Create_field> new_create_list;6124 List<Create_field> new_create_list;
6100 /* New key definitions are added here */6125 /* New key definitions are added here */
6101 List<Key> new_key_list;6126 List<Key> new_key_list;
6127 /* List with secondary keys which should be created after copying the data */
6128 List<Key> delayed_key_list;
6129 /* Foreign key list returned by handler::get_foreign_key_list() */
6130 List<FOREIGN_KEY_INFO> f_key_list;
6102 List_iterator<Alter_drop> drop_it(alter_info->drop_list);6131 List_iterator<Alter_drop> drop_it(alter_info->drop_list);
6103 List_iterator<Create_field> def_it(alter_info->create_list);6132 List_iterator<Create_field> def_it(alter_info->create_list);
6104 List_iterator<Alter_column> alter_it(alter_info->alter_list);6133 List_iterator<Alter_column> alter_it(alter_info->alter_list);
@@ -6111,6 +6140,7 @@
6111 uint used_fields= create_info->used_fields;6140 uint used_fields= create_info->used_fields;
6112 KEY *key_info=table->key_info;6141 KEY *key_info=table->key_info;
6113 bool rc= TRUE;6142 bool rc= TRUE;
6143 bool skip_secondary;
61146144
6115 DBUG_ENTER("mysql_prepare_alter_table");6145 DBUG_ENTER("mysql_prepare_alter_table");
61166146
@@ -6305,8 +6335,26 @@
6305 /*6335 /*
6306 Collect all keys which isn't in drop list. Add only those6336 Collect all keys which isn't in drop list. Add only those
6307 for which some fields exists.6337 for which some fields exists.
6338
6339 We also store secondary keys in delayed_key_list to make use of
6340 the InnoDB fast index creation. The following conditions must be
6341 met:
6342
6343 - fast_index_creation is enabled for the current session
6344 - expand_fast_index_creation is enabled for the current session;
6345 - we are going to create an InnoDB table (this is checked later when the
6346 target engine is known);
6347 - the key most be a non-UNIQUE one;
6348 - there are no foreign keys. This can be optimized later to exclude only
6349 those keys which are a part of foreign key constraints. Currently we
6350 simply disable this optimization for all keys if there are any foreign
6351 key constraints in the table.
6308 */6352 */
63096353
6354 skip_secondary= thd->variables.expand_fast_index_creation &&
6355 !table->file->get_foreign_key_list(thd, &f_key_list) &&
6356 f_key_list.elements == 0;
6357
6310 for (uint i=0 ; i < table->s->keys ; i++,key_info++)6358 for (uint i=0 ; i < table->s->keys ; i++,key_info++)
6311 {6359 {
6312 char *key_name= key_info->name;6360 char *key_name= key_info->name;
@@ -6408,6 +6456,8 @@
6408 test(key_info->flags & HA_GENERATED_KEY),6456 test(key_info->flags & HA_GENERATED_KEY),
6409 key_parts);6457 key_parts);
6410 new_key_list.push_back(key);6458 new_key_list.push_back(key);
6459 if (skip_secondary && key_type == Key::MULTIPLE)
6460 delayed_key_list.push_back(key);
6411 }6461 }
6412 }6462 }
6413 {6463 {
@@ -6415,7 +6465,21 @@
6415 while ((key=key_it++)) // Add new keys6465 while ((key=key_it++)) // Add new keys
6416 {6466 {
6417 if (key->type != Key::FOREIGN_KEY)6467 if (key->type != Key::FOREIGN_KEY)
6468 {
6418 new_key_list.push_back(key);6469 new_key_list.push_back(key);
6470 if (skip_secondary && key->type == Key::MULTIPLE)
6471 delayed_key_list.push_back(key);
6472 }
6473 else if (skip_secondary)
6474 {
6475 /*
6476 We are adding a foreign key so disable the secondary keys
6477 optimization.
6478 */
6479 skip_secondary= FALSE;
6480 delayed_key_list.empty();
6481 }
6482
6419 if (key->name &&6483 if (key->name &&
6420 !my_strcasecmp(system_charset_info,key->name,primary_key_name))6484 !my_strcasecmp(system_charset_info,key->name,primary_key_name))
6421 {6485 {
@@ -6464,12 +6528,100 @@
6464 rc= FALSE;6528 rc= FALSE;
6465 alter_info->create_list.swap(new_create_list);6529 alter_info->create_list.swap(new_create_list);
6466 alter_info->key_list.swap(new_key_list);6530 alter_info->key_list.swap(new_key_list);
6531 alter_info->delayed_key_list.swap(delayed_key_list);
6467err:6532err:
6468 DBUG_RETURN(rc);6533 DBUG_RETURN(rc);
6469}6534}
64706535
64716536
6472/*6537/*
6538 Temporarily remove secondary keys previously stored in
6539 alter_info->delayed_key_info.
6540*/
6541static int
6542remove_secondary_keys(THD *thd, TABLE *table, Alter_info *alter_info)
6543{
6544 uint *key_numbers;
6545 uint key_counter= 0;
6546 uint i;
6547 int error;
6548 DBUG_ENTER("remove_secondary_keys");
6549 DBUG_ASSERT(alter_info->delayed_key_count > 0);
6550
6551 key_numbers= (uint *) thd->alloc(sizeof(uint) *
6552 alter_info->delayed_key_count);
6553 for (i= 0; i < alter_info->delayed_key_count; i++)
6554 {
6555 KEY *key= alter_info->delayed_key_info + i;
6556 uint j;
6557
6558 for (j= 0; j < table->s->keys; j++)
6559 {
6560 if (!strcmp(table->key_info[j].name, key->name))
6561 {
6562 key_numbers[key_counter++]= j;
6563 break;
6564 }
6565 }
6566 }
6567
6568 DBUG_ASSERT(key_counter == alter_info->delayed_key_count);
6569
6570 if ((error= table->file->prepare_drop_index(table, key_numbers,
6571 key_counter)) ||
6572 (error= table->file->final_drop_index(table)))
6573 {
6574 table->file->print_error(error, MYF(0));
6575 }
6576
6577 DBUG_RETURN(error);
6578}
6579
6580/*
6581 Restore secondary keys previously removed in remove_secondary_keys.
6582*/
6583
6584static int
6585restore_secondary_keys(THD *thd, TABLE *table, Alter_info *alter_info)
6586{
6587 uint i;
6588 int error;
6589 DBUG_ENTER("restore_secondary_keys");
6590 DBUG_ASSERT(alter_info->delayed_key_count > 0);
6591
6592 thd_proc_info(thd, "restoring secondary keys");
6593
6594 /* Fix the key parts */
6595 for (i= 0; i < alter_info->delayed_key_count; i++)
6596 {
6597 KEY *key = alter_info->delayed_key_info + i;
6598 KEY_PART_INFO *key_part;
6599 KEY_PART_INFO *part_end;
6600
6601 part_end= key->key_part + key->key_parts;
6602 for (key_part= key->key_part; key_part < part_end; key_part++)
6603 key_part->field= table->field[key_part->fieldnr];
6604 }
6605
6606 if ((error= table->file->add_index(table, alter_info->delayed_key_info,
6607 alter_info->delayed_key_count)))
6608 {
6609 /*
6610 Exchange the key_info for the error message. If we exchange
6611 key number by key name in the message later, we need correct info.
6612 */
6613 KEY *save_key_info= table->key_info;
6614 table->key_info= alter_info->delayed_key_info;
6615 table->file->print_error(error, MYF(0));
6616 table->key_info= save_key_info;
6617
6618 DBUG_RETURN(error);
6619 }
6620
6621 DBUG_RETURN(0);
6622}
6623
6624/*
6473 Alter table6625 Alter table
64746626
6475 SYNOPSIS6627 SYNOPSIS
@@ -7305,15 +7457,34 @@
7305 */7457 */
7306 if (new_table && !(new_table->file->ha_table_flags() & HA_NO_COPY_ON_ALTER))7458 if (new_table && !(new_table->file->ha_table_flags() & HA_NO_COPY_ON_ALTER))
7307 {7459 {
7460 /*
7461 Check if we can temporarily remove secondary indexes from the table
7462 before copying the data and recreate them later to utilize InnoDB fast
7463 index creation.
7464 TODO: is there a better way to check for InnoDB?
7465 */
7466 bool optimize_keys= (alter_info->delayed_key_count > 0) &&
7467 !my_strcasecmp(system_charset_info,
7468 new_table->file->table_type(), "InnoDB");
7308 /* We don't want update TIMESTAMP fields during ALTER TABLE. */7469 /* We don't want update TIMESTAMP fields during ALTER TABLE. */
7309 new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;7470 new_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
7310 new_table->next_number_field=new_table->found_next_number_field;7471 new_table->next_number_field=new_table->found_next_number_field;
7472
7311 thd_proc_info(thd, "copy to tmp table");7473 thd_proc_info(thd, "copy to tmp table");
7474
7475 if (optimize_keys)
7476 {
7477 /* ignore the error */
7478 error= remove_secondary_keys(thd, new_table, alter_info);
7479 }
7480
7312 error= copy_data_between_tables(table, new_table,7481 error= copy_data_between_tables(table, new_table,
7313 alter_info->create_list, ignore,7482 alter_info->create_list, ignore,
7314 order_num, order, &copied, &deleted,7483 order_num, order, &copied, &deleted,
7315 alter_info->keys_onoff,7484 alter_info->keys_onoff,
7316 alter_info->error_if_not_empty);7485 alter_info->error_if_not_empty);
7486 if (!error && optimize_keys)
7487 error= restore_secondary_keys(thd, new_table, alter_info);
7317 }7488 }
7318 else7489 else
7319 {7490 {
73207491
=== modified file 'storage/innodb_plugin/handler/ha_innodb.cc'
--- storage/innodb_plugin/handler/ha_innodb.cc 2012-05-08 05:19:14 +0000
+++ storage/innodb_plugin/handler/ha_innodb.cc 2012-07-03 16:14:26 +0000
@@ -43,6 +43,8 @@
43#pragma implementation // gcc: Class implementation43#pragma implementation // gcc: Class implementation
44#endif44#endif
4545
46#define MYSQL_SERVER
47
46#include <mysql_priv.h>48#include <mysql_priv.h>
4749
48#include <m_ctype.h>50#include <m_ctype.h>
@@ -682,6 +684,19 @@
682}684}
683685
684/******************************************************************//**686/******************************************************************//**
687Returns true if expand_fast_index_creation is enabled for the current
688session.
689@return the value of the server's expand_fast_index_creation variable */
690extern "C"
691ibool
692thd_expand_fast_index_creation(
693/*================================*/
694 void* thd)
695{
696 return((ibool) (((THD*) thd)->variables.expand_fast_index_creation));
697}
698
699/******************************************************************//**
685Returns true if the thread supports XA,700Returns true if the thread supports XA,
686global value of innodb_supports_xa if thd is NULL.701global value of innodb_supports_xa if thd is NULL.
687@return true if thd has XA support */702@return true if thd has XA support */
688703
=== modified file 'storage/innodb_plugin/handler/handler0alter.cc'
--- storage/innodb_plugin/handler/handler0alter.cc 2012-02-28 12:00:00 +0000
+++ storage/innodb_plugin/handler/handler0alter.cc 2012-07-03 16:14:26 +0000
@@ -813,6 +813,8 @@
813 innodb_table, indexed_table,813 innodb_table, indexed_table,
814 index, num_of_idx, table);814 index, num_of_idx, table);
815815
816 DBUG_EXECUTE_IF("crash_innodb_add_index_after", DBUG_SUICIDE(););
817
816error_handling:818error_handling:
817 /* After an error, remove all those index definitions from the819 /* After an error, remove all those index definitions from the
818 dictionary which were defined. */820 dictionary which were defined. */
819821
=== modified file 'storage/innodb_plugin/include/ha_prototypes.h'
--- storage/innodb_plugin/include/ha_prototypes.h 2010-05-14 13:08:15 +0000
+++ storage/innodb_plugin/include/ha_prototypes.h 2012-07-03 16:14:26 +0000
@@ -268,4 +268,15 @@
268 void* thd); /*!< in: thread handle (THD*), or NULL to query268 void* thd); /*!< in: thread handle (THD*), or NULL to query
269 the global innodb_lock_wait_timeout */269 the global innodb_lock_wait_timeout */
270270
271/******************************************************************//**
272Returns true if innodb_expand_fast_index_creation is enabled for the current
273session.
274@return the value of the server's innodb_expand_fast_index_creation variable */
275
276ibool
277thd_expand_fast_index_creation(
278/*==================*/
279 void* thd); /*!< in: thread handle (THD*) */
280
281
271#endif282#endif
272283
=== modified file 'storage/innodb_plugin/row/row0merge.c'
--- storage/innodb_plugin/row/row0merge.c 2012-02-10 03:09:12 +0000
+++ storage/innodb_plugin/row/row0merge.c 2012-07-03 16:14:26 +0000
@@ -56,6 +56,7 @@
56#include "log0log.h"56#include "log0log.h"
57#include "ut0sort.h"57#include "ut0sort.h"
58#include "handler0alter.h"58#include "handler0alter.h"
59#include "ha_prototypes.h"
5960
60#ifdef UNIV_DEBUG61#ifdef UNIV_DEBUG
61/** Set these in order ot enable debug printout. */62/** Set these in order ot enable debug printout. */
@@ -2640,6 +2641,9 @@
2640 }2641 }
2641 }2642 }
26422643
2644 if (trx->mysql_thd && thd_expand_fast_index_creation(trx->mysql_thd))
2645 dict_update_statistics(new_table, FALSE);
2646
2643func_exit:2647func_exit:
2644 close(tmpfd);2648 close(tmpfd);
26452649
26462650
=== modified file 'storage/innodb_plugin/row/row0mysql.c'
--- storage/innodb_plugin/row/row0mysql.c 2012-03-08 15:16:53 +0000
+++ storage/innodb_plugin/row/row0mysql.c 2012-07-03 16:14:26 +0000
@@ -3512,7 +3512,7 @@
3512 btr_pcur_store_position(&pcur, &mtr);3512 btr_pcur_store_position(&pcur, &mtr);
3513 btr_pcur_commit_specify_mtr(&pcur, &mtr);3513 btr_pcur_commit_specify_mtr(&pcur, &mtr);
35143514
3515 table = dict_load_table(table_name);3515 table = dict_table_get_low(table_name);
35163516
3517 if (table) {3517 if (table) {
3518 row_drop_table_for_mysql(table_name, trx, FALSE);3518 row_drop_table_for_mysql(table_name, trx, FALSE);