@@ -23,6 +23,35 @@ static void check_for_reg_data_type_usage(ClusterInfo *cluster);
23
23
static void get_bin_version (ClusterInfo * cluster );
24
24
25
25
26
+ /*
27
+ * fix_path_separator
28
+ * For non-Windows, just return the argument.
29
+ * For Windows convert any forward slash to a backslash
30
+ * such as is suitable for arguments to builtin commands
31
+ * like RMDIR and DEL.
32
+ */
33
+ static char * fix_path_separator (char * path )
34
+ {
35
+ #ifdef WIN32
36
+
37
+ char * result ;
38
+ char * c ;
39
+
40
+ result = pg_strdup (path );
41
+
42
+ for (c = result ; * c != '\0' ; c ++ )
43
+ if (* c == '/' )
44
+ * c = '\\' ;
45
+
46
+ return result ;
47
+
48
+ #else
49
+
50
+ return path ;
51
+
52
+ #endif
53
+ }
54
+
26
55
void
27
56
output_check_banner (bool * live_check )
28
57
{
@@ -544,7 +573,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
544
573
#endif
545
574
546
575
/* delete old cluster's default tablespace */
547
- fprintf (script , RMDIR_CMD " %s\n" , old_cluster .pgdata );
576
+ fprintf (script , RMDIR_CMD " %s\n" , fix_path_separator ( old_cluster .pgdata ) );
548
577
549
578
/* delete old cluster's alternate tablespaces */
550
579
for (tblnum = 0 ; tblnum < os_info .num_tablespaces ; tblnum ++ )
@@ -561,14 +590,17 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
561
590
fprintf (script , "\n" );
562
591
/* remove PG_VERSION? */
563
592
if (GET_MAJOR_VERSION (old_cluster .major_version ) <= 804 )
564
- fprintf (script , RM_CMD " %s%s/PG_VERSION\n" ,
565
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix );
593
+ fprintf (script , RM_CMD " %s%s%cPG_VERSION\n" ,
594
+ fix_path_separator (os_info .tablespaces [tblnum ]),
595
+ fix_path_separator (old_cluster .tablespace_suffix ),
596
+ PATH_SEPARATOR );
566
597
567
598
for (dbnum = 0 ; dbnum < old_cluster .dbarr .ndbs ; dbnum ++ )
568
599
{
569
- fprintf (script , RMDIR_CMD " %s%s/%d\n" ,
570
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix ,
571
- old_cluster .dbarr .dbs [dbnum ].db_oid );
600
+ fprintf (script , RMDIR_CMD " %s%s%c%d\n" ,
601
+ fix_path_separator (os_info .tablespaces [tblnum ]),
602
+ fix_path_separator (old_cluster .tablespace_suffix ),
603
+ PATH_SEPARATOR , old_cluster .dbarr .dbs [dbnum ].db_oid );
572
604
}
573
605
}
574
606
else
@@ -578,7 +610,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
578
610
* or a version-specific subdirectory.
579
611
*/
580
612
fprintf (script , RMDIR_CMD " %s%s\n" ,
581
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix );
613
+ fix_path_separator (os_info .tablespaces [tblnum ]),
614
+ fix_path_separator (old_cluster .tablespace_suffix ));
582
615
}
583
616
584
617
fclose (script );
0 commit comments