@@ -30,8 +30,6 @@ typedef struct TablespaceListCell
3030struct TablespaceListCell * next ;
3131char old_dir [MAXPGPATH ];
3232char new_dir [MAXPGPATH ];
33- bool checked ;/* If this mapping was checked during
34- restore */
3533}TablespaceListCell ;
3634
3735typedef struct TablespaceList
@@ -508,10 +506,10 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
508506dir_create_dir (to_path ,DIR_PERMISSION );
509507}
510508
511- parray_walk (links ,pgBackupFree );
509+ parray_walk (links ,pgFileFree );
512510parray_free (links );
513511
514- parray_walk (dirs ,pgBackupFree );
512+ parray_walk (dirs ,pgFileFree );
515513parray_free (dirs );
516514}
517515
@@ -529,6 +527,7 @@ check_tablespace_mapping(pgBackup *backup)
529527parray * links ;
530528size_t i ;
531529TablespaceListCell * cell ;
530+ pgFile * tmp_file = pgut_new (pgFile );
532531
533532links = parray_new ();
534533
@@ -537,7 +536,18 @@ check_tablespace_mapping(pgBackup *backup)
537536
538537elog (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 */
541551for (i = 0 ;i < parray_num (links );i ++ )
542552{
543553pgFile * link = (pgFile * )parray_get (links ,i );
@@ -548,7 +558,6 @@ check_tablespace_mapping(pgBackup *backup)
548558if (strcmp (link -> linked ,cell -> old_dir )== 0 )
549559{
550560linked_path = cell -> new_dir ;
551- cell -> checked = true;
552561break ;
553562}
554563
@@ -561,16 +570,8 @@ check_tablespace_mapping(pgBackup *backup)
561570linked_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 );
574575parray_free (links );
575576}
576577
@@ -1049,8 +1050,6 @@ opt_tablespace_map(pgut_option *opt, const char *arg)
10491050elog (ERROR ,"new directory is not an absolute path in tablespace mapping: %s\n" ,
10501051cell -> new_dir );
10511052
1052- cell -> checked = false;
1053-
10541053if (tablespace_dirs .tail )
10551054tablespace_dirs .tail -> next = cell ;
10561055else