Skip to content

Commit 4ae178f

Browse files
committed
pg_upgrade: quote directory names in delete_old_cluster script
This allows the delete script to properly function when special characters appear in directory paths, e.g. spaces. Backpatch through 9.0
1 parent 85dac37 commit 4ae178f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/pg_upgrade/check.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
432432
#endif
433433

434434
/* delete old cluster's default tablespace */
435-
fprintf(script, RMDIR_CMD " %s\n", fix_path_separator(ctx, ctx->old.pgdata));
435+
fprintf(script, RMDIR_CMD " \"%s\"\n", fix_path_separator(ctx, ctx->old.pgdata));
436436

437437
/* delete old cluster's alternate tablespaces */
438438
for (tblnum = 0; tblnum < ctx->num_tablespaces; tblnum++)
@@ -456,7 +456,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
456456

457457
for (dbnum = 0; dbnum < ctx->new.dbarr.ndbs; dbnum++)
458458
{
459-
fprintf(script, RMDIR_CMD " %s%s%c%d\n",
459+
fprintf(script, RMDIR_CMD " \"%s%s%c%d\"\n",
460460
fix_path_separator(ctx, ctx->tablespaces[tblnum]),
461461
fix_path_separator(ctx, ctx->old.tablespace_suffix),
462462
PATH_SEPARATOR, ctx->old.dbarr.dbs[dbnum].db_oid);
@@ -468,7 +468,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
468468
* Simply delete the tablespace directory, which might be ".old"
469469
* or a version-specific subdirectory.
470470
*/
471-
fprintf(script, RMDIR_CMD " %s%s\n",
471+
fprintf(script, RMDIR_CMD " \"%s%s\"\n",
472472
fix_path_separator(ctx, ctx->tablespaces[tblnum]),
473473
fix_path_separator(ctx, ctx->old.tablespace_suffix));
474474
}

0 commit comments

Comments
 (0)