@@ -30,8 +30,6 @@ typedef struct TablespaceListCell
30
30
struct TablespaceListCell * next ;
31
31
char old_dir [MAXPGPATH ];
32
32
char new_dir [MAXPGPATH ];
33
- bool checked ; /* If this mapping was checked during
34
- restore */
35
33
} TablespaceListCell ;
36
34
37
35
typedef struct TablespaceList
@@ -508,10 +506,10 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
508
506
dir_create_dir (to_path , DIR_PERMISSION );
509
507
}
510
508
511
- parray_walk (links , pgBackupFree );
509
+ parray_walk (links , pgFileFree );
512
510
parray_free (links );
513
511
514
- parray_walk (dirs , pgBackupFree );
512
+ parray_walk (dirs , pgFileFree );
515
513
parray_free (dirs );
516
514
}
517
515
@@ -529,6 +527,7 @@ check_tablespace_mapping(pgBackup *backup)
529
527
parray * links ;
530
528
size_t i ;
531
529
TablespaceListCell * cell ;
530
+ pgFile * tmp_file = pgut_new (pgFile );
532
531
533
532
links = parray_new ();
534
533
@@ -537,7 +536,18 @@ check_tablespace_mapping(pgBackup *backup)
537
536
538
537
elog (LOG , "check tablespace directories..." );
539
538
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 */
541
551
for (i = 0 ; i < parray_num (links ); i ++ )
542
552
{
543
553
pgFile * link = (pgFile * ) parray_get (links , i );
@@ -548,7 +558,6 @@ check_tablespace_mapping(pgBackup *backup)
548
558
if (strcmp (link -> linked , cell -> old_dir ) == 0 )
549
559
{
550
560
linked_path = cell -> new_dir ;
551
- cell -> checked = true;
552
561
break ;
553
562
}
554
563
@@ -561,16 +570,8 @@ check_tablespace_mapping(pgBackup *backup)
561
570
linked_path );
562
571
}
563
572
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 );
574
575
parray_free (links );
575
576
}
576
577
@@ -1049,8 +1050,6 @@ opt_tablespace_map(pgut_option *opt, const char *arg)
1049
1050
elog (ERROR , "new directory is not an absolute path in tablespace mapping: %s\n" ,
1050
1051
cell -> new_dir );
1051
1052
1052
- cell -> checked = false;
1053
-
1054
1053
if (tablespace_dirs .tail )
1055
1054
tablespace_dirs .tail -> next = cell ;
1056
1055
else
0 commit comments