Merge lp:~sergei.glushchenko/percona-xtrabackup/xb20-partial into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 492
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/xb20-partial
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 1000 lines (+586/-252)
9 files modified
innobackupex (+25/-10)
src/xtrabackup.c (+219/-242)
test/inc/ib_part.sh (+92/-0)
test/t/ib_part_databases.sh (+39/-0)
test/t/ib_part_include.sh (+47/-0)
test/t/ib_part_include_stream.sh (+39/-0)
test/t/ib_part_tf_innodb.sh (+46/-0)
test/t/ib_part_tf_innodb_stream.sh (+40/-0)
test/t/ib_part_tf_myisam.sh (+39/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/xb20-partial
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Laurynas Biveinis Pending
Review via email: mp+138712@code.launchpad.net

This proposal supersedes a proposal from 2012-11-24.

Description of the change

Bug 711166
Partitioned tables are not correctly handled by the --databases, --include,
--tables-file options of innobackupex, and by the --tables and
--tables-file options of xtrabackup.
Solution is to remove partition suffix (#P#...) before doing filtering.
Testcases cover variants of using filtering options with MyISAM and
InnoDB tables (to test both innobackupex and xtrabackup) with either stream
mode turned on and turned off.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/308/

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

It looks like 2.1 code is proposed for merge to 2.0.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

Sergei,

  - definition of XB_HASH_SEARCH duplicates an already existing
    definition in xtrabackup.c

  - please change "Copying %s is skipped" to "Skipping %s" to make it
    consistent with 2.1

  - check_if_skip_table() should have a comment (as in 2.1)

  - xtrabackup uses InnoDB-style assignments "var = value;", not
    MySQL-style ones "var= value;"

  - why do we want to unconditionally filter out tables without the
    "database" part? I know that code should be never reached with the
    current and valid directory structure, but I would rather _not_
    skip such paths (i.e. return FALSE):

> + if (dbname == NULL) {
> + return(TRUE);
> + }

  - same question with this code. I.e. if we can't parse the name,
    let's keep it, rather than skip it.

+ if (dbname_len < 1) {
+ return(TRUE);
+ }

  - the following code should be looking for '#P#' rather than
    '#P'. please also add a comment explaining what that code does.

  - xb_regexec() should be used instead of regexec()

  - would xb_table_filters_init() / xb_table_filter_free() be better
    names for xb_tables_init() / xb_tables_free()?

review: Needs Fixing
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

Alexey,

I've fixed all issues.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Sergei,

Thanks! Approved, but let's fix the 2.1 branch before changing the status to Approved, so this revision does not make it to 2.0 trunk before the 2.1 MP is approved and merged.

review: Approve
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Failures were caused by changed check_if_skip_table behavior in case of database part of table name is empty. This change force xtrabackup --stats to include also SYS_FOREIGN and SYS_FOREIGN_COLS in it's report.
Tests been fixed simply by changing check COUNT==5 to COUNT==7 both for 2.0 and 2.1 patch.
Jenkins runs:
http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/312/
http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/123/

Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex'
2--- innobackupex 2013-01-02 04:20:08 +0000
3+++ innobackupex 2013-01-02 15:54:21 +0000
4@@ -1127,11 +1127,9 @@
5 if($option_include) {
6 my $table_name;
7
8- $table_name = substr($file, rindex($file, '/'));
9- $table_name = substr($table_name, 1, rindex($table_name, '.') - 1);
10- $table_name = $subdir . "." . $table_name;
11+ $table_name = get_table_name($file);
12
13- if (!($table_name =~ /$option_include/)) {
14+ if (!("$subdir.$table_name" =~ /$option_include/)) {
15 print STDERR "'$file' is skipped.\n";
16 next;
17 }
18@@ -2151,7 +2149,8 @@
19 next unless check_if_required($database, $file);
20
21 if($option_include) {
22- if (!("$database.$file" =~ /$option_include/)) {
23+ my $table_name = get_table_name($file);
24+ if (!("$database.$table_name" =~ /$option_include/)) {
25 print STDERR "$database.$file is skipped because it does not match $option_include.\n";
26 next;
27 }
28@@ -2481,6 +2480,26 @@
29 return ${$group_hash_ref}{$option_name};
30 }
31
32+# get_table_name subroutine returns table name of specified file.
33+# Parameters:
34+# $_[0] table path
35+# Return value:
36+# 1 table name
37+#
38+sub get_table_name {
39+ my $table_path = shift;
40+ my $filename;
41+ my $table;
42+
43+ # get the last component in the table pathname
44+ $filename = (reverse(split(/\//, $table_path)))[0];
45+ # get name of the table by removing file suffix
46+ $table = (split(/\./, $filename))[0];
47+ # and partition suffix
48+ $table = (split('#P#', $table))[0];
49+
50+ return $table;
51+}
52
53 # check_if_required subroutine returns 1 if the specified database and
54 # table needs to be backed up.
55@@ -2494,7 +2513,6 @@
56 my ( $db, $table_path ) = @_;
57 my $db_count = scalar keys %databases_list;
58 my $tbl_count = scalar keys %table_list;
59- my $filename;
60 my $table;
61
62 if ( $db_count == 0 && $tbl_count == 0 ) {
63@@ -2504,10 +2522,7 @@
64 }
65 else {
66 if ( $table_path ) {
67- # get the last component in the table pathname
68- $filename = (reverse(split(/\//, $table_path)))[0];
69- # get name of the table by removing file suffix
70- $table = (split(/\./, $filename))[0];
71+ $table = get_table_name($table_path);
72 }
73 }
74
75
76=== modified file 'src/xtrabackup.c'
77--- src/xtrabackup.c 2012-11-21 13:46:50 +0000
78+++ src/xtrabackup.c 2013-01-02 15:54:21 +0000
79@@ -657,6 +657,15 @@
80
81 #endif /* INNODB_VERSION_SHORT */
82
83+#ifdef INNODB_VERSION_SHORT
84+#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
85+ HASH_SEARCH(NAME, TABLE, FOLD, xtrabackup_tables_t*, DATA, ASSERTION, \
86+ TEST)
87+#else
88+#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
89+ HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)
90+#endif
91+
92 typedef struct {
93 ulint page_size;
94 ulint zip_size;
95@@ -2863,6 +2872,78 @@
96 return(TRUE);
97 }
98
99+/************************************************************************
100+Checks if a table specified as a path should be skipped from backup
101+based on the --tables or --tables-file options.
102+
103+@return TRUE if the table should be skipped. */
104+static my_bool
105+check_if_skip_table(const char *path, const char *suffix)
106+{
107+ char buf[FN_REFLEN];
108+ const char *dbname, *tbname;
109+ const char *ptr;
110+ char *eptr;
111+ int dbname_len;
112+
113+ if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) {
114+ return(FALSE);
115+ }
116+
117+ dbname = NULL;
118+ tbname = path;
119+ while ((ptr = strstr(tbname, SRV_PATH_SEPARATOR_STR)) != NULL) {
120+ dbname = tbname;
121+ tbname = ptr + 1;
122+ }
123+
124+ if (dbname == NULL) {
125+ return(FALSE);
126+ }
127+
128+ strncpy(buf, dbname, FN_REFLEN);
129+ buf[FN_REFLEN - 1] = 0;
130+ buf[tbname - 1 - dbname] = '.';
131+
132+ dbname_len = strlen(dbname) - strlen(suffix);
133+ if (dbname_len < 1) {
134+ return(FALSE);
135+ }
136+ buf[dbname_len - 1] = 0;
137+
138+ if ((eptr = strstr(buf, "#P#")) != NULL) {
139+ *eptr = 0;
140+ }
141+
142+ if (xtrabackup_tables) {
143+ int regres = REG_NOMATCH;
144+ int i;
145+ for (i = 0; i < tables_regex_num; i++) {
146+ regres = xb_regexec(&tables_regex[i], buf, 1,
147+ tables_regmatch, 0);
148+ if (regres != REG_NOMATCH) {
149+ break;
150+ }
151+ }
152+ if (regres == REG_NOMATCH) {
153+ return(TRUE);
154+ }
155+ }
156+
157+ if (xtrabackup_tables_file) {
158+ xtrabackup_tables_t* table;
159+
160+ XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(buf),
161+ table, ut_ad(table->name),
162+ !strcmp(table->name, buf));
163+ if (!table) {
164+ return(TRUE);
165+ }
166+ }
167+
168+ return(FALSE);
169+}
170+
171 /***********************************************************************
172 Read meta info for an incremental delta.
173 @return TRUE on success, FALSE on failure. */
174@@ -2961,15 +3042,6 @@
175 }
176 }
177
178-#ifdef INNODB_VERSION_SHORT
179-#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
180- HASH_SEARCH(NAME, TABLE, FOLD, xtrabackup_tables_t*, DATA, ASSERTION, \
181- TEST)
182-#else
183-#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
184- HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)
185-#endif
186-
187 #ifndef XTRADB_BASED
188 #define trx_sys_sys_space(id) (id == 0)
189 #endif
190@@ -3141,91 +3213,12 @@
191 info.zip_size = 0;
192 info.space_id = 0;
193
194- if (xtrabackup_tables && (!trx_sys_sys_space(node->space->id)))
195- { /* must backup id==0 */
196- char *p;
197- int p_len, regres = REG_NOMATCH;
198- char *next, *prev;
199- char tmp;
200- int i;
201-
202- p = node->name;
203- prev = NULL;
204- while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
205- {
206- prev = p;
207- p = next + 1;
208- }
209- p_len = strlen(p) - strlen(".ibd");
210-
211- if (p_len < 1) {
212- /* unknown situation: skip filtering */
213- goto skip_filter;
214- }
215-
216- /* TODO: Fix this lazy implementation... */
217- tmp = p[p_len];
218- p[p_len] = 0;
219- *(p - 1) = '.';
220-
221- for (i = 0; i < tables_regex_num; i++) {
222- regres = xb_regexec(&tables_regex[i], prev, 1,
223- tables_regmatch, 0);
224- if (regres != REG_NOMATCH)
225- break;
226- }
227-
228- p[p_len] = tmp;
229- *(p - 1) = SRV_PATH_SEPARATOR;
230-
231- if ( regres == REG_NOMATCH ) {
232- msg("[%02u] Skipping %s\n",
233- thread_n, node->name);
234- return(FALSE);
235- }
236- }
237-
238- if (xtrabackup_tables_file && (!trx_sys_sys_space(node->space->id)))
239- { /* must backup id==0 */
240- xtrabackup_tables_t* table;
241- char *p;
242- int p_len;
243- char *next, *prev;
244- char tmp;
245-
246- p = node->name;
247- prev = NULL;
248- while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
249- {
250- prev = p;
251- p = next + 1;
252- }
253- p_len = strlen(p) - strlen(".ibd");
254-
255- if (p_len < 1) {
256- /* unknown situation: skip filtering */
257- goto skip_filter;
258- }
259-
260- /* TODO: Fix this lazy implementation... */
261- tmp = p[p_len];
262- p[p_len] = 0;
263-
264- XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(prev),
265- table,
266- ut_ad(table->name),
267- !strcmp(table->name, prev));
268-
269- p[p_len] = tmp;
270-
271- if (!table) {
272- msg("[%02u] Skipping %s\n",
273- thread_n, node->name);
274- return(FALSE);
275- }
276- }
277-
278-skip_filter:
279+ if ((!trx_sys_sys_space(node->space->id))
280+ && check_if_skip_table(node->name, "ibd")) {
281+ printf("[%02u] Skipping %s.\n",
282+ thread_n, node->name);
283+ return(FALSE);
284+ }
285
286 if (trx_sys_sys_space(node->space->id))
287 {
288@@ -4245,6 +4238,128 @@
289 return(FALSE);
290 }
291
292+/************************************************************************
293+Inittialize table filters for partial backup. */
294+static
295+void
296+xb_filters_init()
297+/*=============*/
298+{
299+ if (xtrabackup_tables) {
300+ /* init regexp */
301+ char *p, *next;
302+ int i;
303+ char errbuf[100];
304+
305+ tables_regex_num = 1;
306+
307+ p = xtrabackup_tables;
308+ while ((p = strchr(p, ',')) != NULL) {
309+ p++;
310+ tables_regex_num++;
311+ }
312+
313+ tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
314+
315+ p = xtrabackup_tables;
316+ for (i=0; i < tables_regex_num; i++) {
317+ next = strchr(p, ',');
318+ ut_a(next || i == tables_regex_num - 1);
319+
320+ next++;
321+ if (i != tables_regex_num - 1)
322+ *(next - 1) = '\0';
323+
324+ xb_regerror(xb_regcomp(&tables_regex[i], p,
325+ REG_EXTENDED),
326+ &tables_regex[i], errbuf, sizeof(errbuf));
327+ msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
328+
329+ if (i != tables_regex_num - 1)
330+ *(next - 1) = ',';
331+ p = next;
332+ }
333+ }
334+
335+ if (xtrabackup_tables_file) {
336+ char name_buf[NAME_LEN*2+2];
337+ FILE *fp;
338+
339+ name_buf[NAME_LEN*2+1] = '\0';
340+
341+ /* init tables_hash */
342+ tables_hash = hash_create(1000);
343+
344+ /* read and store the filenames */
345+ fp = fopen(xtrabackup_tables_file,"r");
346+ if (!fp) {
347+ msg("xtrabackup: cannot open %s\n",
348+ xtrabackup_tables_file);
349+ exit(EXIT_FAILURE);
350+ }
351+ for (;;) {
352+ xtrabackup_tables_t* table;
353+ char* p = name_buf;
354+
355+ if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
356+ break;
357+ }
358+
359+ p = strchr(name_buf, '\n');
360+ if (p)
361+ {
362+ *p = '\0';
363+ }
364+
365+ table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
366+ memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
367+ table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
368+ strcpy(table->name, name_buf);
369+
370+ HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
371+ ut_fold_string(table->name), table);
372+
373+ msg("xtrabackup: table '%s' is registered to the "
374+ "list.\n", table->name);
375+ }
376+ }
377+}
378+
379+
380+/************************************************************************
381+Destroy table filters for partial backup. */
382+static
383+void
384+xb_filters_free()
385+/*=============*/
386+{
387+
388+ if (xtrabackup_tables_file) {
389+ ulint i;
390+
391+ /* free the hash elements */
392+ for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
393+ xtrabackup_tables_t* table;
394+
395+ table = HASH_GET_FIRST(tables_hash, i);
396+
397+ while (table) {
398+ xtrabackup_tables_t* prev_table = table;
399+
400+ table = HASH_GET_NEXT(name_hash, prev_table);
401+
402+ HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
403+ ut_fold_string(prev_table->name), prev_table);
404+ free(prev_table);
405+ }
406+ }
407+
408+ /* free tables_hash */
409+ hash_table_free(tables_hash);
410+ }
411+
412+}
413+
414 static void
415 xtrabackup_backup_func(void)
416 {
417@@ -4363,6 +4478,8 @@
418 os_sync_mutex = NULL;
419 srv_general_init();
420
421+ xb_filters_init();
422+
423 {
424 ibool log_file_created;
425 ibool log_created = FALSE;
426@@ -4795,6 +4912,8 @@
427 #endif
428
429 xb_data_files_close();
430+
431+ xb_filters_free();
432 }
433
434 /* ================= stats ================= */
435@@ -5125,6 +5244,8 @@
436 if(innodb_init())
437 exit(EXIT_FAILURE);
438
439+ xb_filters_init();
440+
441 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");
442
443 /* gather stats */
444@@ -5202,45 +5323,8 @@
445 table = dict_table_get_low(table_name);
446 mem_free(table_name);
447
448-
449- if (xtrabackup_tables) {
450- char *p;
451- int regres = REG_NOMATCH;
452- int i;
453-
454- p = strstr(table->name, SRV_PATH_SEPARATOR_STR);
455-
456- if (p)
457- *p = '.';
458-
459- for (i = 0; i < tables_regex_num; i++) {
460- regres = xb_regexec(&tables_regex[i],
461- table->name, 1,
462- tables_regmatch, 0);
463- if (regres != REG_NOMATCH)
464- break;
465- }
466-
467- if (p)
468- *p = SRV_PATH_SEPARATOR;
469-
470- if ( regres == REG_NOMATCH )
471- goto skip;
472- }
473-
474- if (xtrabackup_tables_file) {
475- xtrabackup_tables_t* xtable;
476-
477- XB_HASH_SEARCH(name_hash, tables_hash,
478- ut_fold_string(table->name),
479- xtable,
480- ut_ad(xtable->name),
481- !strcmp(xtable->name, table->name));
482-
483- if (!xtable)
484- goto skip;
485- }
486-
487+ if (table && check_if_skip_table(table->name, ""))
488+ goto skip;
489
490 if (table == NULL) {
491 fputs("InnoDB: Failed to load table ", stderr);
492@@ -5341,6 +5425,8 @@
493 end:
494 putc('\n', stdout);
495
496+ xb_filters_free();
497+
498 /* shutdown InnoDB */
499 if(innodb_end())
500 exit(EXIT_FAILURE);
501@@ -6915,91 +7001,6 @@
502 my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL);
503 xtrabackup_target_dir= xtrabackup_real_target_dir;
504
505- if (xtrabackup_tables) {
506- /* init regexp */
507- char *p, *next;
508- int i;
509- char errbuf[100];
510-
511- tables_regex_num = 1;
512-
513- p = xtrabackup_tables;
514- while ((p = strchr(p, ',')) != NULL) {
515- p++;
516- tables_regex_num++;
517- }
518-
519- tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
520-
521- p = xtrabackup_tables;
522- for (i=0; i < tables_regex_num; i++) {
523- next = strchr(p, ',');
524- ut_a(next || i == tables_regex_num - 1);
525-
526- next++;
527- if (i != tables_regex_num - 1)
528- *(next - 1) = '\0';
529-
530- xb_regerror(xb_regcomp(&tables_regex[i], p,
531- REG_EXTENDED),
532- &tables_regex[i], errbuf, sizeof(errbuf));
533- msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
534-
535- if (i != tables_regex_num - 1)
536- *(next - 1) = ',';
537- p = next;
538- }
539- }
540-
541- if (xtrabackup_tables_file) {
542- char name_buf[NAME_LEN*2+2];
543- FILE *fp;
544-
545- name_buf[NAME_LEN*2+1] = '\0';
546-
547- /* init tables_hash */
548- tables_hash = hash_create(1000);
549-
550- /* read and store the filenames */
551- fp = fopen(xtrabackup_tables_file,"r");
552- if (!fp) {
553- msg("xtrabackup: cannot open %s\n",
554- xtrabackup_tables_file);
555- exit(EXIT_FAILURE);
556- }
557- for (;;) {
558- xtrabackup_tables_t* table;
559- char* p = name_buf;
560-
561- if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
562- break;
563- }
564-
565- while (*p != '\0') {
566- if (*p == '.') {
567- *p = '/';
568- }
569- p++;
570- }
571- p = strchr(name_buf, '\n');
572- if (p)
573- {
574- *p = '\0';
575- }
576-
577- table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
578- memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
579- table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
580- strcpy(table->name, name_buf);
581-
582- HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
583- ut_fold_string(table->name), table);
584-
585- msg("xtrabackup: table '%s' is registered to the "
586- "list.\n", table->name);
587- }
588- }
589-
590 #ifdef XTRADB_BASED
591 /* temporary setting of enough size */
592 srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;
593@@ -7195,30 +7196,6 @@
594 ut_free(tables_regex);
595 }
596
597- if (xtrabackup_tables_file) {
598- ulint i;
599-
600- /* free the hash elements */
601- for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
602- xtrabackup_tables_t* table;
603-
604- table = HASH_GET_FIRST(tables_hash, i);
605-
606- while (table) {
607- xtrabackup_tables_t* prev_table = table;
608-
609- table = HASH_GET_NEXT(name_hash, prev_table);
610-
611- HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
612- ut_fold_string(prev_table->name), prev_table);
613- free(prev_table);
614- }
615- }
616-
617- /* free tables_hash */
618- hash_table_free(tables_hash);
619- }
620-
621 xb_regex_end();
622
623 exit(EXIT_SUCCESS);
624
625=== added file 'test/inc/ib_part.sh'
626--- test/inc/ib_part.sh 1970-01-01 00:00:00 +0000
627+++ test/inc/ib_part.sh 2013-01-02 15:54:21 +0000
628@@ -0,0 +1,92 @@
629+
630+
631+function check_partitioning()
632+{
633+ $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'"
634+}
635+
636+function require_partitioning()
637+{
638+ PARTITION_CHECK=`check_partitioning`
639+
640+ if [ -z "$PARTITION_CHECK" ]; then
641+ echo "Requires Partitioning." > $SKIPPED_REASON
642+ exit $SKIPPED_EXIT_CODE
643+ fi
644+}
645+
646+function ib_part_schema()
647+{
648+ topdir=$1
649+ engine=$2
650+
651+ cat <<EOF
652+CREATE TABLE test (
653+ a int(11) DEFAULT NULL
654+) ENGINE=$engine DEFAULT CHARSET=latin1
655+PARTITION BY RANGE (a)
656+(PARTITION p0 VALUES LESS THAN (100) ENGINE = $engine,
657+ PARTITION P1 VALUES LESS THAN (200) ENGINE = $engine,
658+ PARTITION p2 VALUES LESS THAN (300)
659+ DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
660+ ENGINE = $engine,
661+ PARTITION p3 VALUES LESS THAN (400)
662+ DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
663+ ENGINE = $engine,
664+ PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = $engine);
665+EOF
666+}
667+
668+function ib_part_data()
669+{
670+ echo 'INSERT INTO test VALUES (1), (101), (201), (301), (401);';
671+}
672+
673+function ib_part_init()
674+{
675+ topdir=$1
676+ engine=$2
677+
678+ if [ -d $topdir/ext ] ; then
679+ rm -rf $topdir/ext
680+ fi
681+ mkdir -p $topdir/ext
682+
683+ ib_part_schema $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
684+ ib_part_data $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
685+}
686+
687+function ib_part_restore()
688+{
689+ topdir=$1
690+ mysql_datadir=$2
691+
692+ # Remove database
693+ rm -rf $mysql_datadir/test/*
694+ rm -rf $topdir/ext/*
695+ vlog "Original database removed"
696+
697+ # Restore database from backup
698+ cp -rv $topdir/backup/test/* $mysql_datadir/test
699+ vlog "database restored from backup"
700+
701+}
702+
703+function ib_part_assert_checksum()
704+{
705+ checksum_a=$1
706+
707+ vlog "Checking checksums"
708+ checksum_b=`checksum_table test test`
709+
710+ vlog "Checksums are $checksum_a and $checksum_b"
711+
712+ if [ "$checksum_a" != "$checksum_b" ]
713+ then
714+ vlog "Checksums are not equal"
715+ exit -1
716+ fi
717+
718+ vlog "Checksums are OK"
719+
720+}
721
722=== added file 'test/t/ib_part_databases.sh'
723--- test/t/ib_part_databases.sh 1970-01-01 00:00:00 +0000
724+++ test/t/ib_part_databases.sh 2013-01-02 15:54:21 +0000
725@@ -0,0 +1,39 @@
726+########################################################################
727+# Bug #711166: Partitioned tables are not correctly handled by the
728+# --databases and --tables-file options of innobackupex,
729+# and by the --tables option of xtrabackup.
730+# Testcase covers using --databases option with MyISAM
731+# database
732+########################################################################
733+
734+. inc/common.sh
735+. inc/ib_part.sh
736+
737+start_server
738+
739+require_partitioning
740+
741+# Create MyISAM partitioned table with some partitions in
742+# different location
743+ib_part_init $topdir MyISAM
744+
745+# Saving the checksum of original table
746+checksum_a=`checksum_table test test`
747+
748+# Take a backup
749+cat >$topdir/databases_file <<EOF
750+test.test
751+EOF
752+innobackupex --no-timestamp --databases=$topdir/databases_file $topdir/backup
753+innobackupex --apply-log $topdir/backup
754+vlog "Backup taken"
755+
756+stop_server
757+
758+# Restore partial backup
759+ib_part_restore $topdir $mysql_datadir
760+
761+start_server
762+
763+# compare checksum
764+ib_part_assert_checksum $checksum_a
765
766=== added file 'test/t/ib_part_include.sh'
767--- test/t/ib_part_include.sh 1970-01-01 00:00:00 +0000
768+++ test/t/ib_part_include.sh 2013-01-02 15:54:21 +0000
769@@ -0,0 +1,47 @@
770+########################################################################
771+# Bug #711166: Partitioned tables are not correctly handled by the
772+# --databases and --tables-file options of innobackupex,
773+# and by the --tables option of xtrabackup.
774+# Testcase covers using --include option with InnoDB
775+# database
776+########################################################################
777+
778+. inc/common.sh
779+. inc/ib_part.sh
780+
781+start_server --innodb_file_per_table
782+
783+require_partitioning
784+
785+# Create InnoDB partitioned table
786+ib_part_init $topdir InnoDB
787+
788+# Saving the checksum of original table
789+checksum_a=`checksum_table test test`
790+
791+# Take a backup
792+# Only backup of test.test table will be taken
793+cat >$topdir/tables <<EOF
794+test.test
795+EOF
796+innobackupex --no-timestamp --include='test.test$' $topdir/backup
797+innobackupex --apply-log $topdir/backup
798+vlog "Backup taken"
799+
800+# also test xtrabackup --stats work with --tables-file
801+COUNT=`xtrabackup --stats --tables='test.test$' --datadir=$topdir/backup \
802+ | grep table: | awk '{print $2}' | sort -u | wc -l`
803+
804+if [ $COUNT != 7 ] ; then
805+ vlog "xtrabackup --stats does not work"
806+ exit -1
807+fi
808+
809+stop_server
810+
811+# Restore partial backup
812+ib_part_restore $topdir $mysql_datadir
813+
814+start_server
815+
816+ib_part_assert_checksum $checksum_a
817
818=== added file 'test/t/ib_part_include_stream.sh'
819--- test/t/ib_part_include_stream.sh 1970-01-01 00:00:00 +0000
820+++ test/t/ib_part_include_stream.sh 2013-01-02 15:54:21 +0000
821@@ -0,0 +1,39 @@
822+########################################################################
823+# Bug #711166: Partitioned tables are not correctly handled by the
824+# --databases and --tables-file options of innobackupex,
825+# and by the --tables option of xtrabackup.
826+# Testcase covers using --include option with InnoDB
827+# database and --stream mode
828+########################################################################
829+
830+. inc/common.sh
831+. inc/ib_part.sh
832+
833+start_server --innodb_file_per_table
834+
835+require_partitioning
836+
837+# Create MyISAM partitioned table
838+ib_part_init $topdir MyISAM
839+
840+# Saving the checksum of original table
841+checksum_a=`checksum_table test test`
842+
843+# Take a backup
844+mkdir -p $topdir/backup
845+innobackupex --stream=tar --include='test.test$' $topdir/backup > $topdir/backup/backup.tar
846+$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
847+$TAR cvhf $topdir/backup/backup11.tar $mysql_datadir/test/*
848+
849+innobackupex --apply-log $topdir/backup
850+
851+vlog "Backup taken"
852+
853+stop_server
854+
855+# Restore partial backup
856+ib_part_restore $topdir $mysql_datadir
857+
858+start_server
859+
860+ib_part_assert_checksum $checksum_a
861
862=== added file 'test/t/ib_part_tf_innodb.sh'
863--- test/t/ib_part_tf_innodb.sh 1970-01-01 00:00:00 +0000
864+++ test/t/ib_part_tf_innodb.sh 2013-01-02 15:54:21 +0000
865@@ -0,0 +1,46 @@
866+########################################################################
867+# Bug #711166: Partitioned tables are not correctly handled by the
868+# --databases and --tables-file options of innobackupex,
869+# and by the --tables option of xtrabackup.
870+# Testcase covers using --tables-file option with InnoDB
871+# database
872+########################################################################
873+
874+. inc/common.sh
875+. inc/ib_part.sh
876+
877+start_server --innodb_file_per_table
878+
879+require_partitioning
880+
881+# Create InnoDB partitioned table
882+ib_part_init $topdir InnoDB
883+
884+# Saving the checksum of original table
885+checksum_a=`checksum_table test test`
886+
887+# Take a backup
888+# Only backup of test.test table will be taken
889+cat >$topdir/tables <<EOF
890+test.test
891+EOF
892+innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
893+innobackupex --apply-log $topdir/backup
894+vlog "Backup taken"
895+
896+COUNT=`xtrabackup --stats --tables-file=$topdir/tables --datadir=$topdir/backup \
897+ | grep table: | awk '{print $2}' | sort -u | wc -l`
898+echo "COUNT = $COUNT"
899+if [ $COUNT != 7 ] ; then
900+ vlog "xtrabackup --stats does not work"
901+ exit -1
902+fi
903+
904+stop_server
905+
906+# Restore partial backup
907+ib_part_restore $topdir $mysql_datadir
908+
909+start_server
910+
911+ib_part_assert_checksum $checksum_a
912
913=== added file 'test/t/ib_part_tf_innodb_stream.sh'
914--- test/t/ib_part_tf_innodb_stream.sh 1970-01-01 00:00:00 +0000
915+++ test/t/ib_part_tf_innodb_stream.sh 2013-01-02 15:54:21 +0000
916@@ -0,0 +1,40 @@
917+########################################################################
918+# Bug #711166: Partitioned tables are not correctly handled by the
919+# --databases and --tables-file options of innobackupex,
920+# and by the --tables option of xtrabackup.
921+# Testcase covers using --tables-file option with InnoDB
922+# database and --stream mode
923+########################################################################
924+
925+. inc/common.sh
926+. inc/ib_part.sh
927+
928+start_server --innodb_file_per_table
929+
930+require_partitioning
931+
932+# Create InnoDB partitioned table
933+ib_part_init $topdir InnoDB
934+
935+# Saving the checksum of original table
936+checksum_a=`checksum_table test test`
937+
938+# Take a backup
939+# Only backup of test.test table will be taken
940+cat >$topdir/tables <<EOF
941+test.test
942+EOF
943+mkdir -p $topdir/backup
944+innobackupex --stream=tar --no-timestamp --tables-file=$topdir/tables $topdir/backup > $topdir/backup/backup.tar
945+$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
946+innobackupex --apply-log $topdir/backup
947+vlog "Backup taken"
948+
949+stop_server
950+
951+# Restore partial backup
952+ib_part_restore $topdir $mysql_datadir
953+
954+start_server
955+
956+ib_part_assert_checksum $checksum_a
957
958=== added file 'test/t/ib_part_tf_myisam.sh'
959--- test/t/ib_part_tf_myisam.sh 1970-01-01 00:00:00 +0000
960+++ test/t/ib_part_tf_myisam.sh 2013-01-02 15:54:21 +0000
961@@ -0,0 +1,39 @@
962+########################################################################
963+# Bug #711166: Partitioned tables are not correctly handled by the
964+# --databases and --tables-file options of innobackupex,
965+# and by the --tables option of xtrabackup.
966+# Testcase covers using --tables-file option with MyISAM
967+# database
968+########################################################################
969+
970+. inc/common.sh
971+. inc/ib_part.sh
972+
973+start_server
974+
975+require_partitioning
976+
977+# Create MyISAM partitioned table with some partitions in
978+# different location
979+ib_part_init $topdir MyISAM
980+
981+# Saving the checksum of original table
982+checksum_a=`checksum_table test test`
983+
984+# Take a backup
985+# Only backup of test.test table will be taken
986+cat >$topdir/tables <<EOF
987+test.test
988+EOF
989+innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
990+innobackupex --apply-log $topdir/backup
991+vlog "Backup taken"
992+
993+stop_server
994+
995+# Restore partial backup
996+ib_part_restore $topdir $mysql_datadir
997+
998+start_server
999+
1000+ib_part_assert_checksum $checksum_a

Subscribers

People subscribed via source and target branches