@@ -23,6 +23,35 @@ static void check_for_reg_data_type_usage(ClusterInfo *cluster);
2323static void get_bin_version (ClusterInfo * cluster );
2424
2525
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+
2655void
2756output_check_banner (bool * live_check )
2857{
@@ -544,7 +573,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
544573#endif
545574
546575 /* 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 ) );
548577
549578 /* delete old cluster's alternate tablespaces */
550579 for (tblnum = 0 ; tblnum < os_info .num_tablespaces ; tblnum ++ )
@@ -561,14 +590,17 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
561590 fprintf (script , "\n" );
562591 /* remove PG_VERSION? */
563592 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 );
566597
567598 for (dbnum = 0 ; dbnum < old_cluster .dbarr .ndbs ; dbnum ++ )
568599 {
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 );
572604 }
573605 }
574606 else
@@ -578,7 +610,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
578610 * or a version-specific subdirectory.
579611 */
580612 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 ));
582615 }
583616
584617 fclose (script );
0 commit comments