Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit957de55

Browse files
author
Artur Zakirov
committed
Check that OLDDIR has an entry in links first
1 parent9ace401 commit957de55

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

‎dir.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ pgFileComparePathDesc(const void *f1, const void *f2)
206206
return-pgFileComparePath(f1,f2);
207207
}
208208

209+
/* Compare two pgFile with their linked directory path. */
210+
int
211+
pgFileCompareLinked(constvoid*f1,constvoid*f2)
212+
{
213+
pgFile*f1p=*(pgFile**)f1;
214+
pgFile*f2p=*(pgFile**)f2;
215+
216+
returnstrcmp(f1p->linked,f2p->linked);
217+
}
218+
209219
/* Compare two pgFile with their size */
210220
int
211221
pgFileCompareSize(constvoid*f1,constvoid*f2)

‎pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ extern void pgFileFree(void *file);
330330
externpg_crc32pgFileGetCRC(pgFile*file);
331331
externintpgFileComparePath(constvoid*f1,constvoid*f2);
332332
externintpgFileComparePathDesc(constvoid*f1,constvoid*f2);
333+
externintpgFileCompareLinked(constvoid*f1,constvoid*f2);
333334
externintpgFileCompareSize(constvoid*f1,constvoid*f2);
334335
externintpgFileCompareMtime(constvoid*f1,constvoid*f2);
335336
externintpgFileCompareMtimeDesc(constvoid*f1,constvoid*f2);

‎restore.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ typedef struct TablespaceListCell
3030
structTablespaceListCell*next;
3131
charold_dir[MAXPGPATH];
3232
charnew_dir[MAXPGPATH];
33-
boolchecked;/* If this mapping was checked during
34-
restore */
3533
}TablespaceListCell;
3634

3735
typedefstructTablespaceList
@@ -508,10 +506,10 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
508506
dir_create_dir(to_path,DIR_PERMISSION);
509507
}
510508

511-
parray_walk(links,pgBackupFree);
509+
parray_walk(links,pgFileFree);
512510
parray_free(links);
513511

514-
parray_walk(dirs,pgBackupFree);
512+
parray_walk(dirs,pgFileFree);
515513
parray_free(dirs);
516514
}
517515

@@ -529,6 +527,7 @@ check_tablespace_mapping(pgBackup *backup)
529527
parray*links;
530528
size_ti;
531529
TablespaceListCell*cell;
530+
pgFile*tmp_file=pgut_new(pgFile);
532531

533532
links=parray_new();
534533

@@ -537,7 +536,18 @@ check_tablespace_mapping(pgBackup *backup)
537536

538537
elog(LOG,"check tablespace directories...");
539538

540-
/* 1 - all linked directories should be empty */
539+
/* 1 - OLDDIR should has an entry in links */
540+
for (cell=tablespace_dirs.head;cell;cell=cell->next)
541+
{
542+
tmp_file->linked=cell->old_dir;
543+
544+
if (parray_bsearch(links,tmp_file,pgFileCompareLinked)==NULL)
545+
elog(ERROR,"--tablespace-mapping option's old directory "
546+
"has not an entry in tablespace_map file: \"%s\"",
547+
cell->old_dir);
548+
}
549+
550+
/* 2 - all linked directories should be empty */
541551
for (i=0;i<parray_num(links);i++)
542552
{
543553
pgFile*link= (pgFile*)parray_get(links,i);
@@ -548,7 +558,6 @@ check_tablespace_mapping(pgBackup *backup)
548558
if (strcmp(link->linked,cell->old_dir)==0)
549559
{
550560
linked_path=cell->new_dir;
551-
cell->checked= true;
552561
break;
553562
}
554563

@@ -561,16 +570,8 @@ check_tablespace_mapping(pgBackup *backup)
561570
linked_path);
562571
}
563572

564-
/* 2 - OLDDIR should has an entry in links */
565-
for (cell=tablespace_dirs.head;cell;cell=cell->next)
566-
{
567-
if (!cell->checked)
568-
elog(ERROR,"--tablespace-mapping option's old directory "
569-
"has not an entry in tablespace_map file: \"%s\"",
570-
cell->old_dir);
571-
}
572-
573-
parray_walk(links,pgBackupFree);
573+
free(tmp_file);
574+
parray_walk(links,pgFileFree);
574575
parray_free(links);
575576
}
576577

@@ -1049,8 +1050,6 @@ opt_tablespace_map(pgut_option *opt, const char *arg)
10491050
elog(ERROR,"new directory is not an absolute path in tablespace mapping: %s\n",
10501051
cell->new_dir);
10511052

1052-
cell->checked= false;
1053-
10541053
if (tablespace_dirs.tail)
10551054
tablespace_dirs.tail->next=cell;
10561055
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp