@@ -936,6 +936,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
936936 int tblnum ;
937937 char old_cluster_pgdata [MAXPGPATH ],
938938 new_cluster_pgdata [MAXPGPATH ];
939+ char * old_tblspc_suffix ;
939940
940941 * deletion_script_file_name = psprintf ("%sdelete_old_cluster.%s" ,
941942 SCRIPT_PREFIX , SCRIPT_EXT );
@@ -1000,39 +1001,13 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
10001001 fix_path_separator (old_cluster .pgdata ), PATH_QUOTE );
10011002
10021003 /* delete old cluster's alternate tablespaces */
1004+ old_tblspc_suffix = pg_strdup (old_cluster .tablespace_suffix );
1005+ fix_path_separator (old_tblspc_suffix );
10031006 for (tblnum = 0 ; tblnum < os_info .num_old_tablespaces ; tblnum ++ )
1004- {
1005- /*
1006- * Do the old cluster's per-database directories share a directory
1007- * with a new version-specific tablespace?
1008- */
1009- if (strlen (old_cluster .tablespace_suffix ) == 0 )
1010- {
1011- /* delete per-database directories */
1012- int dbnum ;
1013-
1014- fprintf (script , "\n" );
1015-
1016- for (dbnum = 0 ; dbnum < old_cluster .dbarr .ndbs ; dbnum ++ )
1017- fprintf (script , RMDIR_CMD " %c%s%c%u%c\n" , PATH_QUOTE ,
1018- fix_path_separator (os_info .old_tablespaces [tblnum ]),
1019- PATH_SEPARATOR , old_cluster .dbarr .dbs [dbnum ].db_oid ,
1020- PATH_QUOTE );
1021- }
1022- else
1023- {
1024- char * suffix_path = pg_strdup (old_cluster .tablespace_suffix );
1025-
1026- /*
1027- * Simply delete the tablespace directory, which might be ".old"
1028- * or a version-specific subdirectory.
1029- */
1030- fprintf (script , RMDIR_CMD " %c%s%s%c\n" , PATH_QUOTE ,
1031- fix_path_separator (os_info .old_tablespaces [tblnum ]),
1032- fix_path_separator (suffix_path ), PATH_QUOTE );
1033- pfree (suffix_path );
1034- }
1035- }
1007+ fprintf (script , RMDIR_CMD " %c%s%s%c\n" , PATH_QUOTE ,
1008+ fix_path_separator (os_info .old_tablespaces [tblnum ]),
1009+ old_tblspc_suffix , PATH_QUOTE );
1010+ pfree (old_tblspc_suffix );
10361011
10371012 fclose (script );
10381013
0 commit comments