@@ -19,6 +19,35 @@ static void check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
19
19
static void check_for_reg_data_type_usage (migratorContext * ctx , Cluster whichCluster );
20
20
21
21
22
+ /*
23
+ * fix_path_separator
24
+ * For non-Windows, just return the argument.
25
+ * For Windows convert any forward slash to a backslash
26
+ * such as is suitable for arguments to builtin commands
27
+ * like RMDIR and DEL.
28
+ */
29
+ static char * fix_path_separator (char * path )
30
+ {
31
+ #ifdef WIN32
32
+
33
+ char * result ;
34
+ char * c ;
35
+
36
+ result = pg_strdup (path );
37
+
38
+ for (c = result ; * c != '\0' ; c ++ )
39
+ if (* c == '/' )
40
+ * c = '\\' ;
41
+
42
+ return result ;
43
+
44
+ #else
45
+
46
+ return path ;
47
+
48
+ #endif
49
+ }
50
+
22
51
void
23
52
output_check_banner (migratorContext * ctx , bool * live_check )
24
53
{
@@ -402,7 +431,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
402
431
#endif
403
432
404
433
/* delete old cluster's default tablespace */
405
- fprintf (script , RMDIR_CMD " %s\n" , ctx -> old .pgdata );
434
+ fprintf (script , RMDIR_CMD " %s\n" , fix_path_separator ( ctx -> old .pgdata ) );
406
435
407
436
/* delete old cluster's alternate tablespaces */
408
437
for (tblnum = 0 ; tblnum < ctx -> num_tablespaces ; tblnum ++ )
@@ -419,14 +448,17 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
419
448
fprintf (script , "\n" );
420
449
/* remove PG_VERSION? */
421
450
if (GET_MAJOR_VERSION (ctx -> old .major_version ) <= 804 )
422
- fprintf (script , RM_CMD " %s%s/PG_VERSION\n" ,
423
- ctx -> tablespaces [tblnum ], ctx -> old .tablespace_suffix );
451
+ fprintf (script , RM_CMD " %s%s%cPG_VERSION\n" ,
452
+ fix_path_separator (ctx -> tablespaces [tblnum ]),
453
+ fix_path_separator (ctx -> old .tablespace_suffix ),
454
+ PATH_SEPARATOR );
424
455
425
456
for (dbnum = 0 ; dbnum < ctx -> new .dbarr .ndbs ; dbnum ++ )
426
457
{
427
- fprintf (script , RMDIR_CMD " %s%s/%d\n" ,
428
- ctx -> tablespaces [tblnum ], ctx -> old .tablespace_suffix ,
429
- ctx -> old .dbarr .dbs [dbnum ].db_oid );
458
+ fprintf (script , RMDIR_CMD " %s%s%c%d\n" ,
459
+ fix_path_separator (ctx -> tablespaces [tblnum ]),
460
+ fix_path_separator (ctx -> old .tablespace_suffix ),
461
+ PATH_SEPARATOR , ctx -> old .dbarr .dbs [dbnum ].db_oid );
430
462
}
431
463
}
432
464
else
@@ -436,7 +468,8 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
436
468
* or a version-specific subdirectory.
437
469
*/
438
470
fprintf (script , RMDIR_CMD " %s%s\n" ,
439
- ctx -> tablespaces [tblnum ], ctx -> old .tablespace_suffix );
471
+ fix_path_separator (ctx -> tablespaces [tblnum ]),
472
+ fix_path_separator (ctx -> old .tablespace_suffix ));
440
473
}
441
474
442
475
fclose (script );
0 commit comments