@@ -22,6 +22,35 @@ static void check_for_reg_data_type_usage(ClusterInfo *cluster);
22
22
static void get_bin_version (ClusterInfo * cluster );
23
23
24
24
25
+ /*
26
+ * fix_path_separator
27
+ * For non-Windows, just return the argument.
28
+ * For Windows convert any forward slash to a backslash
29
+ * such as is suitable for arguments to builtin commands
30
+ * like RMDIR and DEL.
31
+ */
32
+ static char * fix_path_separator (char * path )
33
+ {
34
+ #ifdef WIN32
35
+
36
+ char * result ;
37
+ char * c ;
38
+
39
+ result = pg_strdup (path );
40
+
41
+ for (c = result ; * c != '\0' ; c ++ )
42
+ if (* c == '/' )
43
+ * c = '\\' ;
44
+
45
+ return result ;
46
+
47
+ #else
48
+
49
+ return path ;
50
+
51
+ #endif
52
+ }
53
+
25
54
void
26
55
output_check_banner (bool * live_check )
27
56
{
@@ -453,7 +482,7 @@ create_script_for_old_cluster_deletion(
453
482
#endif
454
483
455
484
/* delete old cluster's default tablespace */
456
- fprintf (script , RMDIR_CMD " %s\n" , old_cluster .pgdata );
485
+ fprintf (script , RMDIR_CMD " %s\n" , fix_path_separator ( old_cluster .pgdata ) );
457
486
458
487
/* delete old cluster's alternate tablespaces */
459
488
for (tblnum = 0 ; tblnum < os_info .num_tablespaces ; tblnum ++ )
@@ -470,14 +499,17 @@ create_script_for_old_cluster_deletion(
470
499
fprintf (script , "\n" );
471
500
/* remove PG_VERSION? */
472
501
if (GET_MAJOR_VERSION (old_cluster .major_version ) <= 804 )
473
- fprintf (script , RM_CMD " %s%s/PG_VERSION\n" ,
474
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix );
502
+ fprintf (script , RM_CMD " %s%s%cPG_VERSION\n" ,
503
+ fix_path_separator (os_info .tablespaces [tblnum ]),
504
+ fix_path_separator (old_cluster .tablespace_suffix ),
505
+ PATH_SEPARATOR );
475
506
476
507
for (dbnum = 0 ; dbnum < new_cluster .dbarr .ndbs ; dbnum ++ )
477
508
{
478
- fprintf (script , RMDIR_CMD " %s%s/%d\n" ,
479
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix ,
480
- old_cluster .dbarr .dbs [dbnum ].db_oid );
509
+ fprintf (script , RMDIR_CMD " %s%s%c%d\n" ,
510
+ fix_path_separator (os_info .tablespaces [tblnum ]),
511
+ fix_path_separator (old_cluster .tablespace_suffix ),
512
+ PATH_SEPARATOR , old_cluster .dbarr .dbs [dbnum ].db_oid );
481
513
}
482
514
}
483
515
else
@@ -487,7 +519,8 @@ create_script_for_old_cluster_deletion(
487
519
* or a version-specific subdirectory.
488
520
*/
489
521
fprintf (script , RMDIR_CMD " %s%s\n" ,
490
- os_info .tablespaces [tblnum ], old_cluster .tablespace_suffix );
522
+ fix_path_separator (os_info .tablespaces [tblnum ]),
523
+ fix_path_separator (old_cluster .tablespace_suffix ));
491
524
}
492
525
493
526
fclose (script );
0 commit comments