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

Proposed by Sergei Glushchenko
Status: Superseded
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) Needs Fixing
Laurynas Biveinis Pending
Review via email: mp+136015@code.launchpad.net

This proposal supersedes a proposal from 2012-08-27.

This proposal has been superseded by a proposal from 2012-12-07.

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 :

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 :

Alexey,

I've fixed all issues.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'innobackupex'
--- innobackupex 2012-11-29 23:32:59 +0000
+++ innobackupex 2012-12-07 10:36:21 +0000
@@ -1127,11 +1127,9 @@
1127 if($option_include) {1127 if($option_include) {
1128 my $table_name;1128 my $table_name;
11291129
1130 $table_name = substr($file, rindex($file, '/'));1130 $table_name = get_table_name($file);
1131 $table_name = substr($table_name, 1, rindex($table_name, '.') - 1);
1132 $table_name = $subdir . "." . $table_name;
11331131
1134 if (!($table_name =~ /$option_include/)) {1132 if (!("$subdir.$table_name" =~ /$option_include/)) {
1135 print STDERR "'$file' is skipped.\n";1133 print STDERR "'$file' is skipped.\n";
1136 next;1134 next;
1137 }1135 }
@@ -2152,7 +2150,8 @@
2152 next unless check_if_required($database, $file);2150 next unless check_if_required($database, $file);
21532151
2154 if($option_include) {2152 if($option_include) {
2155 if (!("$database.$file" =~ /$option_include/)) {2153 my $table_name = get_table_name($file);
2154 if (!("$database.$table_name" =~ /$option_include/)) {
2156 print STDERR "$database.$file is skipped because it does not match $option_include.\n";2155 print STDERR "$database.$file is skipped because it does not match $option_include.\n";
2157 next;2156 next;
2158 }2157 }
@@ -2482,6 +2481,26 @@
2482 return ${$group_hash_ref}{$option_name};2481 return ${$group_hash_ref}{$option_name};
2483}2482}
24842483
2484# get_table_name subroutine returns table name of specified file.
2485# Parameters:
2486# $_[0] table path
2487# Return value:
2488# 1 table name
2489#
2490sub get_table_name {
2491 my $table_path = shift;
2492 my $filename;
2493 my $table;
2494
2495 # get the last component in the table pathname
2496 $filename = (reverse(split(/\//, $table_path)))[0];
2497 # get name of the table by removing file suffix
2498 $table = (split(/\./, $filename))[0];
2499 # and partition suffix
2500 $table = (split('#P#', $table))[0];
2501
2502 return $table;
2503}
24852504
2486# check_if_required subroutine returns 1 if the specified database and2505# check_if_required subroutine returns 1 if the specified database and
2487# table needs to be backed up.2506# table needs to be backed up.
@@ -2495,7 +2514,6 @@
2495 my ( $db, $table_path ) = @_;2514 my ( $db, $table_path ) = @_;
2496 my $db_count = scalar keys %databases_list;2515 my $db_count = scalar keys %databases_list;
2497 my $tbl_count = scalar keys %table_list;2516 my $tbl_count = scalar keys %table_list;
2498 my $filename;
2499 my $table;2517 my $table;
25002518
2501 if ( $db_count == 0 && $tbl_count == 0 ) {2519 if ( $db_count == 0 && $tbl_count == 0 ) {
@@ -2505,10 +2523,7 @@
2505 }2523 }
2506 else {2524 else {
2507 if ( $table_path ) {2525 if ( $table_path ) {
2508 # get the last component in the table pathname 2526 $table = get_table_name($table_path);
2509 $filename = (reverse(split(/\//, $table_path)))[0];
2510 # get name of the table by removing file suffix
2511 $table = (split(/\./, $filename))[0];
2512 }2527 }
2513 }2528 }
25142529
25152530
=== modified file 'src/xtrabackup.c'
--- src/xtrabackup.c 2012-11-21 13:46:50 +0000
+++ src/xtrabackup.c 2012-12-07 10:36:21 +0000
@@ -657,6 +657,15 @@
657657
658#endif /* INNODB_VERSION_SHORT */658#endif /* INNODB_VERSION_SHORT */
659659
660#ifdef INNODB_VERSION_SHORT
661#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
662 HASH_SEARCH(NAME, TABLE, FOLD, xtrabackup_tables_t*, DATA, ASSERTION, \
663 TEST)
664#else
665#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
666 HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)
667#endif
668
660typedef struct {669typedef struct {
661 ulint page_size;670 ulint page_size;
662 ulint zip_size;671 ulint zip_size;
@@ -2863,6 +2872,78 @@
2863 return(TRUE);2872 return(TRUE);
2864}2873}
28652874
2875/************************************************************************
2876Checks if a table specified as a path should be skipped from backup
2877based on the --tables or --tables-file options.
2878
2879@return TRUE if the table should be skipped. */
2880static my_bool
2881check_if_skip_table(const char *path, const char *suffix)
2882{
2883 char buf[FN_REFLEN];
2884 const char *dbname, *tbname;
2885 const char *ptr;
2886 char *eptr;
2887 int dbname_len;
2888
2889 if (xtrabackup_tables == NULL && xtrabackup_tables_file == NULL) {
2890 return(FALSE);
2891 }
2892
2893 dbname = NULL;
2894 tbname = path;
2895 while ((ptr = strstr(tbname, SRV_PATH_SEPARATOR_STR)) != NULL) {
2896 dbname = tbname;
2897 tbname = ptr + 1;
2898 }
2899
2900 if (dbname == NULL) {
2901 return(FALSE);
2902 }
2903
2904 strncpy(buf, dbname, FN_REFLEN);
2905 buf[FN_REFLEN - 1] = 0;
2906 buf[tbname - 1 - dbname] = '.';
2907
2908 dbname_len = strlen(dbname) - strlen(suffix);
2909 if (dbname_len < 1) {
2910 return(FALSE);
2911 }
2912 buf[dbname_len - 1] = 0;
2913
2914 if ((eptr = strstr(buf, "#P#")) != NULL) {
2915 *eptr = 0;
2916 }
2917
2918 if (xtrabackup_tables) {
2919 int regres = REG_NOMATCH;
2920 int i;
2921 for (i = 0; i < tables_regex_num; i++) {
2922 regres = xb_regexec(&tables_regex[i], buf, 1,
2923 tables_regmatch, 0);
2924 if (regres != REG_NOMATCH) {
2925 break;
2926 }
2927 }
2928 if (regres == REG_NOMATCH) {
2929 return(TRUE);
2930 }
2931 }
2932
2933 if (xtrabackup_tables_file) {
2934 xtrabackup_tables_t* table;
2935
2936 XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(buf),
2937 table, ut_ad(table->name),
2938 !strcmp(table->name, buf));
2939 if (!table) {
2940 return(TRUE);
2941 }
2942 }
2943
2944 return(FALSE);
2945}
2946
2866/***********************************************************************2947/***********************************************************************
2867Read meta info for an incremental delta.2948Read meta info for an incremental delta.
2868@return TRUE on success, FALSE on failure. */2949@return TRUE on success, FALSE on failure. */
@@ -2961,15 +3042,6 @@
2961 }3042 }
2962}3043}
29633044
2964#ifdef INNODB_VERSION_SHORT
2965#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
2966 HASH_SEARCH(NAME, TABLE, FOLD, xtrabackup_tables_t*, DATA, ASSERTION, \
2967 TEST)
2968#else
2969#define XB_HASH_SEARCH(NAME, TABLE, FOLD, DATA, ASSERTION, TEST) \
2970 HASH_SEARCH(NAME, TABLE, FOLD, DATA, TEST)
2971#endif
2972
2973#ifndef XTRADB_BASED3045#ifndef XTRADB_BASED
2974#define trx_sys_sys_space(id) (id == 0)3046#define trx_sys_sys_space(id) (id == 0)
2975#endif3047#endif
@@ -3141,91 +3213,12 @@
3141 info.zip_size = 0;3213 info.zip_size = 0;
3142 info.space_id = 0;3214 info.space_id = 0;
31433215
3144 if (xtrabackup_tables && (!trx_sys_sys_space(node->space->id)))3216 if ((!trx_sys_sys_space(node->space->id))
3145 { /* must backup id==0 */3217 && check_if_skip_table(node->name, "ibd")) {
3146 char *p;3218 printf("[%02u] Skipping %s.\n",
3147 int p_len, regres = REG_NOMATCH;3219 thread_n, node->name);
3148 char *next, *prev;3220 return(FALSE);
3149 char tmp;3221 }
3150 int i;
3151
3152 p = node->name;
3153 prev = NULL;
3154 while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
3155 {
3156 prev = p;
3157 p = next + 1;
3158 }
3159 p_len = strlen(p) - strlen(".ibd");
3160
3161 if (p_len < 1) {
3162 /* unknown situation: skip filtering */
3163 goto skip_filter;
3164 }
3165
3166 /* TODO: Fix this lazy implementation... */
3167 tmp = p[p_len];
3168 p[p_len] = 0;
3169 *(p - 1) = '.';
3170
3171 for (i = 0; i < tables_regex_num; i++) {
3172 regres = xb_regexec(&tables_regex[i], prev, 1,
3173 tables_regmatch, 0);
3174 if (regres != REG_NOMATCH)
3175 break;
3176 }
3177
3178 p[p_len] = tmp;
3179 *(p - 1) = SRV_PATH_SEPARATOR;
3180
3181 if ( regres == REG_NOMATCH ) {
3182 msg("[%02u] Skipping %s\n",
3183 thread_n, node->name);
3184 return(FALSE);
3185 }
3186 }
3187
3188 if (xtrabackup_tables_file && (!trx_sys_sys_space(node->space->id)))
3189 { /* must backup id==0 */
3190 xtrabackup_tables_t* table;
3191 char *p;
3192 int p_len;
3193 char *next, *prev;
3194 char tmp;
3195
3196 p = node->name;
3197 prev = NULL;
3198 while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL)
3199 {
3200 prev = p;
3201 p = next + 1;
3202 }
3203 p_len = strlen(p) - strlen(".ibd");
3204
3205 if (p_len < 1) {
3206 /* unknown situation: skip filtering */
3207 goto skip_filter;
3208 }
3209
3210 /* TODO: Fix this lazy implementation... */
3211 tmp = p[p_len];
3212 p[p_len] = 0;
3213
3214 XB_HASH_SEARCH(name_hash, tables_hash, ut_fold_string(prev),
3215 table,
3216 ut_ad(table->name),
3217 !strcmp(table->name, prev));
3218
3219 p[p_len] = tmp;
3220
3221 if (!table) {
3222 msg("[%02u] Skipping %s\n",
3223 thread_n, node->name);
3224 return(FALSE);
3225 }
3226 }
3227
3228skip_filter:
32293222
3230 if (trx_sys_sys_space(node->space->id))3223 if (trx_sys_sys_space(node->space->id))
3231 {3224 {
@@ -4245,6 +4238,128 @@
4245 return(FALSE);4238 return(FALSE);
4246}4239}
42474240
4241/************************************************************************
4242Inittialize table filters for partial backup. */
4243static
4244void
4245xb_filters_init()
4246/*=============*/
4247{
4248 if (xtrabackup_tables) {
4249 /* init regexp */
4250 char *p, *next;
4251 int i;
4252 char errbuf[100];
4253
4254 tables_regex_num = 1;
4255
4256 p = xtrabackup_tables;
4257 while ((p = strchr(p, ',')) != NULL) {
4258 p++;
4259 tables_regex_num++;
4260 }
4261
4262 tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
4263
4264 p = xtrabackup_tables;
4265 for (i=0; i < tables_regex_num; i++) {
4266 next = strchr(p, ',');
4267 ut_a(next || i == tables_regex_num - 1);
4268
4269 next++;
4270 if (i != tables_regex_num - 1)
4271 *(next - 1) = '\0';
4272
4273 xb_regerror(xb_regcomp(&tables_regex[i], p,
4274 REG_EXTENDED),
4275 &tables_regex[i], errbuf, sizeof(errbuf));
4276 msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
4277
4278 if (i != tables_regex_num - 1)
4279 *(next - 1) = ',';
4280 p = next;
4281 }
4282 }
4283
4284 if (xtrabackup_tables_file) {
4285 char name_buf[NAME_LEN*2+2];
4286 FILE *fp;
4287
4288 name_buf[NAME_LEN*2+1] = '\0';
4289
4290 /* init tables_hash */
4291 tables_hash = hash_create(1000);
4292
4293 /* read and store the filenames */
4294 fp = fopen(xtrabackup_tables_file,"r");
4295 if (!fp) {
4296 msg("xtrabackup: cannot open %s\n",
4297 xtrabackup_tables_file);
4298 exit(EXIT_FAILURE);
4299 }
4300 for (;;) {
4301 xtrabackup_tables_t* table;
4302 char* p = name_buf;
4303
4304 if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
4305 break;
4306 }
4307
4308 p = strchr(name_buf, '\n');
4309 if (p)
4310 {
4311 *p = '\0';
4312 }
4313
4314 table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
4315 memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
4316 table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
4317 strcpy(table->name, name_buf);
4318
4319 HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
4320 ut_fold_string(table->name), table);
4321
4322 msg("xtrabackup: table '%s' is registered to the "
4323 "list.\n", table->name);
4324 }
4325 }
4326}
4327
4328
4329/************************************************************************
4330Destroy table filters for partial backup. */
4331static
4332void
4333xb_filters_free()
4334/*=============*/
4335{
4336
4337 if (xtrabackup_tables_file) {
4338 ulint i;
4339
4340 /* free the hash elements */
4341 for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
4342 xtrabackup_tables_t* table;
4343
4344 table = HASH_GET_FIRST(tables_hash, i);
4345
4346 while (table) {
4347 xtrabackup_tables_t* prev_table = table;
4348
4349 table = HASH_GET_NEXT(name_hash, prev_table);
4350
4351 HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
4352 ut_fold_string(prev_table->name), prev_table);
4353 free(prev_table);
4354 }
4355 }
4356
4357 /* free tables_hash */
4358 hash_table_free(tables_hash);
4359 }
4360
4361}
4362
4248static void4363static void
4249xtrabackup_backup_func(void)4364xtrabackup_backup_func(void)
4250{4365{
@@ -4363,6 +4478,8 @@
4363 os_sync_mutex = NULL;4478 os_sync_mutex = NULL;
4364 srv_general_init();4479 srv_general_init();
43654480
4481 xb_filters_init();
4482
4366 {4483 {
4367 ibool log_file_created;4484 ibool log_file_created;
4368 ibool log_created = FALSE;4485 ibool log_created = FALSE;
@@ -4795,6 +4912,8 @@
4795#endif4912#endif
47964913
4797 xb_data_files_close();4914 xb_data_files_close();
4915
4916 xb_filters_free();
4798}4917}
47994918
4800/* ================= stats ================= */4919/* ================= stats ================= */
@@ -5125,6 +5244,8 @@
5125 if(innodb_init())5244 if(innodb_init())
5126 exit(EXIT_FAILURE);5245 exit(EXIT_FAILURE);
51275246
5247 xb_filters_init();
5248
5128 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");5249 fprintf(stdout, "\n\n<INDEX STATISTICS>\n");
51295250
5130 /* gather stats */5251 /* gather stats */
@@ -5202,45 +5323,8 @@
5202 table = dict_table_get_low(table_name);5323 table = dict_table_get_low(table_name);
5203 mem_free(table_name);5324 mem_free(table_name);
52045325
52055326 if (table && check_if_skip_table(table->name, ""))
5206 if (xtrabackup_tables) {5327 goto skip;
5207 char *p;
5208 int regres = REG_NOMATCH;
5209 int i;
5210
5211 p = strstr(table->name, SRV_PATH_SEPARATOR_STR);
5212
5213 if (p)
5214 *p = '.';
5215
5216 for (i = 0; i < tables_regex_num; i++) {
5217 regres = xb_regexec(&tables_regex[i],
5218 table->name, 1,
5219 tables_regmatch, 0);
5220 if (regres != REG_NOMATCH)
5221 break;
5222 }
5223
5224 if (p)
5225 *p = SRV_PATH_SEPARATOR;
5226
5227 if ( regres == REG_NOMATCH )
5228 goto skip;
5229 }
5230
5231 if (xtrabackup_tables_file) {
5232 xtrabackup_tables_t* xtable;
5233
5234 XB_HASH_SEARCH(name_hash, tables_hash,
5235 ut_fold_string(table->name),
5236 xtable,
5237 ut_ad(xtable->name),
5238 !strcmp(xtable->name, table->name));
5239
5240 if (!xtable)
5241 goto skip;
5242 }
5243
52445328
5245 if (table == NULL) {5329 if (table == NULL) {
5246 fputs("InnoDB: Failed to load table ", stderr);5330 fputs("InnoDB: Failed to load table ", stderr);
@@ -5341,6 +5425,8 @@
5341end:5425end:
5342 putc('\n', stdout);5426 putc('\n', stdout);
53435427
5428 xb_filters_free();
5429
5344 /* shutdown InnoDB */5430 /* shutdown InnoDB */
5345 if(innodb_end())5431 if(innodb_end())
5346 exit(EXIT_FAILURE);5432 exit(EXIT_FAILURE);
@@ -6915,91 +7001,6 @@
6915 my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL);7001 my_load_path(xtrabackup_real_target_dir, xtrabackup_target_dir, NULL);
6916 xtrabackup_target_dir= xtrabackup_real_target_dir;7002 xtrabackup_target_dir= xtrabackup_real_target_dir;
69177003
6918 if (xtrabackup_tables) {
6919 /* init regexp */
6920 char *p, *next;
6921 int i;
6922 char errbuf[100];
6923
6924 tables_regex_num = 1;
6925
6926 p = xtrabackup_tables;
6927 while ((p = strchr(p, ',')) != NULL) {
6928 p++;
6929 tables_regex_num++;
6930 }
6931
6932 tables_regex = ut_malloc(sizeof(xb_regex_t) * tables_regex_num);
6933
6934 p = xtrabackup_tables;
6935 for (i=0; i < tables_regex_num; i++) {
6936 next = strchr(p, ',');
6937 ut_a(next || i == tables_regex_num - 1);
6938
6939 next++;
6940 if (i != tables_regex_num - 1)
6941 *(next - 1) = '\0';
6942
6943 xb_regerror(xb_regcomp(&tables_regex[i], p,
6944 REG_EXTENDED),
6945 &tables_regex[i], errbuf, sizeof(errbuf));
6946 msg("xtrabackup: tables regcomp(%s): %s\n", p, errbuf);
6947
6948 if (i != tables_regex_num - 1)
6949 *(next - 1) = ',';
6950 p = next;
6951 }
6952 }
6953
6954 if (xtrabackup_tables_file) {
6955 char name_buf[NAME_LEN*2+2];
6956 FILE *fp;
6957
6958 name_buf[NAME_LEN*2+1] = '\0';
6959
6960 /* init tables_hash */
6961 tables_hash = hash_create(1000);
6962
6963 /* read and store the filenames */
6964 fp = fopen(xtrabackup_tables_file,"r");
6965 if (!fp) {
6966 msg("xtrabackup: cannot open %s\n",
6967 xtrabackup_tables_file);
6968 exit(EXIT_FAILURE);
6969 }
6970 for (;;) {
6971 xtrabackup_tables_t* table;
6972 char* p = name_buf;
6973
6974 if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) {
6975 break;
6976 }
6977
6978 while (*p != '\0') {
6979 if (*p == '.') {
6980 *p = '/';
6981 }
6982 p++;
6983 }
6984 p = strchr(name_buf, '\n');
6985 if (p)
6986 {
6987 *p = '\0';
6988 }
6989
6990 table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
6991 memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1);
6992 table->name = ((char*)table) + sizeof(xtrabackup_tables_t);
6993 strcpy(table->name, name_buf);
6994
6995 HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash,
6996 ut_fold_string(table->name), table);
6997
6998 msg("xtrabackup: table '%s' is registered to the "
6999 "list.\n", table->name);
7000 }
7001 }
7002
7003#ifdef XTRADB_BASED7004#ifdef XTRADB_BASED
7004 /* temporary setting of enough size */7005 /* temporary setting of enough size */
7005 srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;7006 srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;
@@ -7195,30 +7196,6 @@
7195 ut_free(tables_regex);7196 ut_free(tables_regex);
7196 }7197 }
71977198
7198 if (xtrabackup_tables_file) {
7199 ulint i;
7200
7201 /* free the hash elements */
7202 for (i = 0; i < hash_get_n_cells(tables_hash); i++) {
7203 xtrabackup_tables_t* table;
7204
7205 table = HASH_GET_FIRST(tables_hash, i);
7206
7207 while (table) {
7208 xtrabackup_tables_t* prev_table = table;
7209
7210 table = HASH_GET_NEXT(name_hash, prev_table);
7211
7212 HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash,
7213 ut_fold_string(prev_table->name), prev_table);
7214 free(prev_table);
7215 }
7216 }
7217
7218 /* free tables_hash */
7219 hash_table_free(tables_hash);
7220 }
7221
7222 xb_regex_end();7199 xb_regex_end();
72237200
7224 exit(EXIT_SUCCESS);7201 exit(EXIT_SUCCESS);
72257202
=== added file 'test/inc/ib_part.sh'
--- test/inc/ib_part.sh 1970-01-01 00:00:00 +0000
+++ test/inc/ib_part.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,92 @@
1
2
3function check_partitioning()
4{
5 $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'"
6}
7
8function require_partitioning()
9{
10 PARTITION_CHECK=`check_partitioning`
11
12 if [ -z "$PARTITION_CHECK" ]; then
13 echo "Requires Partitioning." > $SKIPPED_REASON
14 exit $SKIPPED_EXIT_CODE
15 fi
16}
17
18function ib_part_schema()
19{
20 topdir=$1
21 engine=$2
22
23 cat <<EOF
24CREATE TABLE test (
25 a int(11) DEFAULT NULL
26) ENGINE=$engine DEFAULT CHARSET=latin1
27PARTITION BY RANGE (a)
28(PARTITION p0 VALUES LESS THAN (100) ENGINE = $engine,
29 PARTITION P1 VALUES LESS THAN (200) ENGINE = $engine,
30 PARTITION p2 VALUES LESS THAN (300)
31 DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
32 ENGINE = $engine,
33 PARTITION p3 VALUES LESS THAN (400)
34 DATA DIRECTORY = '$topdir/ext' INDEX DIRECTORY = '$topdir/ext'
35 ENGINE = $engine,
36 PARTITION p4 VALUES LESS THAN MAXVALUE ENGINE = $engine);
37EOF
38}
39
40function ib_part_data()
41{
42 echo 'INSERT INTO test VALUES (1), (101), (201), (301), (401);';
43}
44
45function ib_part_init()
46{
47 topdir=$1
48 engine=$2
49
50 if [ -d $topdir/ext ] ; then
51 rm -rf $topdir/ext
52 fi
53 mkdir -p $topdir/ext
54
55 ib_part_schema $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
56 ib_part_data $topdir $engine | run_cmd $MYSQL $MYSQL_ARGS test
57}
58
59function ib_part_restore()
60{
61 topdir=$1
62 mysql_datadir=$2
63
64 # Remove database
65 rm -rf $mysql_datadir/test/*
66 rm -rf $topdir/ext/*
67 vlog "Original database removed"
68
69 # Restore database from backup
70 cp -rv $topdir/backup/test/* $mysql_datadir/test
71 vlog "database restored from backup"
72
73}
74
75function ib_part_assert_checksum()
76{
77 checksum_a=$1
78
79 vlog "Checking checksums"
80 checksum_b=`checksum_table test test`
81
82 vlog "Checksums are $checksum_a and $checksum_b"
83
84 if [ "$checksum_a" != "$checksum_b" ]
85 then
86 vlog "Checksums are not equal"
87 exit -1
88 fi
89
90 vlog "Checksums are OK"
91
92}
093
=== added file 'test/t/ib_part_databases.sh'
--- test/t/ib_part_databases.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_databases.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --databases option with MyISAM
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server
13
14require_partitioning
15
16# Create MyISAM partitioned table with some partitions in
17# different location
18ib_part_init $topdir MyISAM
19
20# Saving the checksum of original table
21checksum_a=`checksum_table test test`
22
23# Take a backup
24cat >$topdir/databases_file <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --databases=$topdir/databases_file $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31stop_server
32
33# Restore partial backup
34ib_part_restore $topdir $mysql_datadir
35
36start_server
37
38# compare checksum
39ib_part_assert_checksum $checksum_a
040
=== added file 'test/t/ib_part_include.sh'
--- test/t/ib_part_include.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_include.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,47 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --include option with InnoDB
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --include='test.test$' $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31# also test xtrabackup --stats work with --tables-file
32COUNT=`xtrabackup --stats --tables='test.test$' --datadir=$topdir/backup 2>&1 \
33 | grep table: | awk '{print $2}' | sort -u | wc -l`
34
35if [ $COUNT != 5 ] ; then
36 vlog "xtrabackup --stats does not work"
37 exit -1
38fi
39
40stop_server
41
42# Restore partial backup
43ib_part_restore $topdir $mysql_datadir
44
45start_server
46
47ib_part_assert_checksum $checksum_a
048
=== added file 'test/t/ib_part_include_stream.sh'
--- test/t/ib_part_include_stream.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_include_stream.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --include option with InnoDB
6# database and --stream mode
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create MyISAM partitioned table
17ib_part_init $topdir MyISAM
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23mkdir -p $topdir/backup
24innobackupex --stream=tar --include='test.test$' $topdir/backup > $topdir/backup/backup.tar
25$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
26$TAR cvhf $topdir/backup/backup11.tar $mysql_datadir/test/*
27
28innobackupex --apply-log $topdir/backup
29
30vlog "Backup taken"
31
32stop_server
33
34# Restore partial backup
35ib_part_restore $topdir $mysql_datadir
36
37start_server
38
39ib_part_assert_checksum $checksum_a
040
=== added file 'test/t/ib_part_tf_innodb.sh'
--- test/t/ib_part_tf_innodb.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_innodb.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,46 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with InnoDB
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
28innobackupex --apply-log $topdir/backup
29vlog "Backup taken"
30
31COUNT=`xtrabackup --stats --tables-file=$topdir/tables --datadir=$topdir/backup 2>&1 \
32 | grep table: | awk '{print $2}' | sort -u | wc -l`
33
34if [ $COUNT != 5 ] ; then
35 vlog "xtrabackup --stats does not work"
36 exit -1
37fi
38
39stop_server
40
41# Restore partial backup
42ib_part_restore $topdir $mysql_datadir
43
44start_server
45
46ib_part_assert_checksum $checksum_a
047
=== added file 'test/t/ib_part_tf_innodb_stream.sh'
--- test/t/ib_part_tf_innodb_stream.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_innodb_stream.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,40 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with InnoDB
6# database and --stream mode
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server --innodb_file_per_table
13
14require_partitioning
15
16# Create InnoDB partitioned table
17ib_part_init $topdir InnoDB
18
19# Saving the checksum of original table
20checksum_a=`checksum_table test test`
21
22# Take a backup
23# Only backup of test.test table will be taken
24cat >$topdir/tables <<EOF
25test.test
26EOF
27mkdir -p $topdir/backup
28innobackupex --stream=tar --no-timestamp --tables-file=$topdir/tables $topdir/backup > $topdir/backup/backup.tar
29$TAR ixvf $topdir/backup/backup.tar -C $topdir/backup
30innobackupex --apply-log $topdir/backup
31vlog "Backup taken"
32
33stop_server
34
35# Restore partial backup
36ib_part_restore $topdir $mysql_datadir
37
38start_server
39
40ib_part_assert_checksum $checksum_a
041
=== added file 'test/t/ib_part_tf_myisam.sh'
--- test/t/ib_part_tf_myisam.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_part_tf_myisam.sh 2012-12-07 10:36:21 +0000
@@ -0,0 +1,39 @@
1########################################################################
2# Bug #711166: Partitioned tables are not correctly handled by the
3# --databases and --tables-file options of innobackupex,
4# and by the --tables option of xtrabackup.
5# Testcase covers using --tables-file option with MyISAM
6# database
7########################################################################
8
9. inc/common.sh
10. inc/ib_part.sh
11
12start_server
13
14require_partitioning
15
16# Create MyISAM partitioned table with some partitions in
17# different location
18ib_part_init $topdir MyISAM
19
20# Saving the checksum of original table
21checksum_a=`checksum_table test test`
22
23# Take a backup
24# Only backup of test.test table will be taken
25cat >$topdir/tables <<EOF
26test.test
27EOF
28innobackupex --no-timestamp --tables-file=$topdir/tables $topdir/backup
29innobackupex --apply-log $topdir/backup
30vlog "Backup taken"
31
32stop_server
33
34# Restore partial backup
35ib_part_restore $topdir $mysql_datadir
36
37start_server
38
39ib_part_assert_checksum $checksum_a

Subscribers

People subscribed via source and target branches