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

Commitd10ddf4

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 parent9739518 commitd10ddf4

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
@@ -22,6 +22,35 @@ static void check_for_reg_data_type_usage(ClusterInfo *cluster);
2222
staticvoidget_bin_version(ClusterInfo*cluster);
2323

2424

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+
staticchar*fix_path_separator(char*path)
33+
{
34+
#ifdefWIN32
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+
returnresult;
46+
47+
#else
48+
49+
returnpath;
50+
51+
#endif
52+
}
53+
2554
void
2655
output_check_banner(bool*live_check)
2756
{
@@ -453,7 +482,7 @@ create_script_for_old_cluster_deletion(
453482
#endif
454483

455484
/* 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));
457486

458487
/* delete old cluster's alternate tablespaces */
459488
for (tblnum=0;tblnum<os_info.num_tablespaces;tblnum++)
@@ -470,14 +499,17 @@ create_script_for_old_cluster_deletion(
470499
fprintf(script,"\n");
471500
/* remove PG_VERSION? */
472501
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);
475506

476507
for (dbnum=0;dbnum<new_cluster.dbarr.ndbs;dbnum++)
477508
{
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);
481513
}
482514
}
483515
else
@@ -487,7 +519,8 @@ create_script_for_old_cluster_deletion(
487519
* or a version-specific subdirectory.
488520
*/
489521
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));
491524
}
492525

493526
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
#defineSCRIPT_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
#defineSCRIPT_EXT"bat"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp