Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4397c51

Browse files
committed
Use correct path separator for Windows builtin commands.
pg_upgrade produces a platform-specific script to remove the olddirectory, but on Windows it has not been making sure that thepaths it writes as arguments for rmdir and del use the backslashpath separator, which will cause these scripts to fail.The fix is backpatched to Release 9.0.
1 parent1da2a61 commit4397c51

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ static void check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
1919
staticvoidcheck_for_reg_data_type_usage(migratorContext*ctx,ClusterwhichCluster);
2020

2121

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+
staticchar*fix_path_separator(char*path)
30+
{
31+
#ifdefWIN32
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+
returnresult;
43+
44+
#else
45+
46+
returnpath;
47+
48+
#endif
49+
}
50+
2251
void
2352
output_check_banner(migratorContext*ctx,bool*live_check)
2453
{
@@ -402,7 +431,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
402431
#endif
403432

404433
/* 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));
406435

407436
/* delete old cluster's alternate tablespaces */
408437
for (tblnum=0;tblnum<ctx->num_tablespaces;tblnum++)
@@ -419,14 +448,17 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
419448
fprintf(script,"\n");
420449
/* remove PG_VERSION? */
421450
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);
424455

425456
for (dbnum=0;dbnum<ctx->new.dbarr.ndbs;dbnum++)
426457
{
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);
430462
}
431463
}
432464
else
@@ -436,7 +468,8 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
436468
* or a version-specific subdirectory.
437469
*/
438470
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));
440473
}
441474

442475
fclose(script);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#definepg_copy_filecopy_file
3939
#definepg_mv_filerename
4040
#definepg_link_filelink
41+
#definePATH_SEPARATOR '/'
4142
#defineRM_CMD"rm -f"
4243
#defineRMDIR_CMD"rm -rf"
4344
#defineSHELL_EXT"sh"
@@ -46,6 +47,7 @@
4647
#definepg_mv_filepgrename
4748
#definepg_link_filewin32_pghardlink
4849
#definesleep(x)Sleep(x * 1000)
50+
#definePATH_SEPARATOR '\\'
4951
#defineRM_CMD"DEL /q"
5052
#defineRMDIR_CMD"RMDIR /s/q"
5153
#defineSHELL_EXT"bat"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp