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

Proposed by Alexey Kopytov
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: 537
Merged at revision: 544
Proposed branch: lp:~akopytov/percona-server/bug989253-5.1
Merge into: lp:percona-server/5.1
Diff against target: 170 lines (+95/-23)
3 files modified
Percona-Server/client/mysqldump.c (+38/-23)
Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result (+36/-0)
Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test (+21/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug989253-5.1
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Review via email: mp+154590@code.launchpad.net

Description of the change

    Bug #989253: mysqldump --innodb-optimize-keys --no-data results in no
                 keys

    Fixed mysqldump so that --innodb-optimize-keys dump delayed secondary
    indexes even if --no-data is used.

http://jenkins.percona.com/view/PS%205.1/job/percona-server-5.1-param/529/

To post a comment you must log in.

Approve

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/client/mysqldump.c'
2--- Percona-Server/client/mysqldump.c 2013-01-18 03:33:06 +0000
3+++ Percona-Server/client/mysqldump.c 2013-03-21 05:18:29 +0000
4@@ -3612,6 +3612,38 @@
5
6
7 /*
8+ Dump delayed secondary index definitions when --innodb-optimize-keys is used.
9+*/
10+
11+static void dump_skipped_keys(const char *table)
12+{
13+ uint keys;
14+
15+ verbose_msg("-- Dumping delayed secondary index definitions for table %s\n",
16+ table);
17+
18+ if (!skipped_keys_list)
19+ return;
20+
21+ skipped_keys_list= list_reverse(skipped_keys_list);
22+ fprintf(md_result_file, "ALTER TABLE %s ", table);
23+ for (keys= list_length(skipped_keys_list); keys > 0; keys--)
24+ {
25+ LIST *node= skipped_keys_list;
26+ char *def= node->data;
27+
28+ fprintf(md_result_file, "ADD %s%s", def, (keys > 1) ? ", " : ";\n");
29+
30+ skipped_keys_list= list_delete(skipped_keys_list, node);
31+ my_free(def, MYF(0));
32+ my_free(node, MYF(0));
33+ }
34+
35+ DBUG_ASSERT(skipped_keys_list == NULL);
36+}
37+
38+
39+/*
40
41 SYNOPSIS
42 dump_table()
43@@ -3654,9 +3686,14 @@
44 if (strcmp(table_type, "VIEW") == 0)
45 DBUG_VOID_RETURN;
46
47+ result_table= quote_name(table,table_buff, 1);
48+ opt_quoted_table= quote_name(table, table_buff2, 0);
49+
50 /* Check --no-data flag */
51 if (opt_no_data)
52 {
53+ dump_skipped_keys(opt_quoted_table);
54+
55 verbose_msg("-- Skipping dump data for table '%s', --no-data was used\n",
56 table);
57 DBUG_VOID_RETURN;
58@@ -3695,9 +3732,6 @@
59 DBUG_VOID_RETURN;
60 }
61
62- result_table= quote_name(table,table_buff, 1);
63- opt_quoted_table= quote_name(table, table_buff2, 0);
64-
65 verbose_msg("-- Sending SELECT query...\n");
66
67 init_dynamic_string_checked(&query_string, "", 1024, 1024);
68@@ -4096,26 +4130,7 @@
69 goto err;
70 }
71
72- /* Perform delayed secondary index creation for --innodb-optimize-keys */
73- if (skipped_keys_list)
74- {
75- uint keys;
76- skipped_keys_list= list_reverse(skipped_keys_list);
77- fprintf(md_result_file, "ALTER TABLE %s ", opt_quoted_table);
78- for (keys= list_length(skipped_keys_list); keys > 0; keys--)
79- {
80- LIST *node= skipped_keys_list;
81- char *def= node->data;
82-
83- fprintf(md_result_file, "ADD %s%s", def, (keys > 1) ? ", " : ";\n");
84-
85- skipped_keys_list= list_delete(skipped_keys_list, node);
86- my_free(def, MYF(0));
87- my_free(node, MYF(0));
88- }
89-
90- DBUG_ASSERT(skipped_keys_list == NULL);
91- }
92+ dump_skipped_keys(opt_quoted_table);
93
94 /* Moved enable keys to before unlock per bug 15977 */
95 if (opt_disable_keys)
96
97=== modified file 'Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result'
98--- Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result 2012-11-20 07:24:27 +0000
99+++ Percona-Server/mysql-test/r/percona_mysqldump_innodb_optimize_keys.result 2013-03-21 05:18:29 +0000
100@@ -439,3 +439,39 @@
101
102 ######################################
103 DROP TABLE t1, t2;
104+CREATE TABLE t1 (id INT PRIMARY KEY, c INT, KEY(c)) ENGINE=InnoDB;
105+INSERT INTO t1 VALUES (1, 1234);
106+######################################
107+
108+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
109+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
110+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
111+/*!40101 SET NAMES utf8 */;
112+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
113+/*!40103 SET TIME_ZONE='+00:00' */;
114+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
115+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
116+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
117+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
118+DROP TABLE IF EXISTS `t1`;
119+/*!40101 SET @saved_cs_client = @@character_set_client */;
120+/*!40101 SET character_set_client = utf8 */;
121+CREATE TABLE `t1` (
122+ `id` int(11) NOT NULL,
123+ `c` int(11) DEFAULT NULL,
124+ PRIMARY KEY (`id`)
125+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
126+/*!40101 SET character_set_client = @saved_cs_client */;
127+ALTER TABLE `t1` ADD KEY `c` (`c`);
128+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
129+
130+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
131+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
132+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
133+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
134+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
135+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
136+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
137+
138+######################################
139+DROP TABLE t1;
140
141=== modified file 'Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test'
142--- Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test 2012-11-20 07:24:27 +0000
143+++ Percona-Server/mysql-test/t/percona_mysqldump_innodb_optimize_keys.test 2013-03-21 05:18:29 +0000
144@@ -223,5 +223,26 @@
145
146 DROP TABLE t1, t2;
147
148+############################################################################
149+# Bug #989253: mysqldump --innodb-optimize-keys --no-data results in no keys
150+############################################################################
151+
152+CREATE TABLE t1 (id INT PRIMARY KEY, c INT, KEY(c)) ENGINE=InnoDB;
153+INSERT INTO t1 VALUES (1, 1234);
154+
155+--exec $MYSQL_DUMP --skip-comments --innodb-optimize-keys --no-data test t1 >$file
156+
157+--echo ######################################
158+--cat_file $file
159+--echo ######################################
160+
161+# Check that the resulting dump can be imported back
162+
163+--exec $MYSQL test < $file
164+
165+--remove_file $file
166+
167+DROP TABLE t1;
168+
169 # Wait till we reached the initial number of concurrent sessions
170 --source include/wait_until_count_sessions.inc

Subscribers

People subscribed via source and target branches