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

Commit504aeea

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 parent2a2352e commit504aeea

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

2525

26+
/*
27+
* fix_path_separator
28+
* For non-Windows, just return the argument.
29+
* For Windows convert any forward slash to a backslash
30+
* such as is suitable for arguments to builtin commands
31+
* like RMDIR and DEL.
32+
*/
33+
staticchar*fix_path_separator(char*path)
34+
{
35+
#ifdefWIN32
36+
37+
char*result;
38+
char*c;
39+
40+
result=pg_strdup(path);
41+
42+
for (c=result;*c!='\0';c++)
43+
if (*c=='/')
44+
*c='\\';
45+
46+
returnresult;
47+
48+
#else
49+
50+
returnpath;
51+
52+
#endif
53+
}
54+
2655
void
2756
output_check_banner(bool*live_check)
2857
{
@@ -544,7 +573,7 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
544573
#endif
545574

546575
/* delete old cluster's default tablespace */
547-
fprintf(script,RMDIR_CMD" %s\n",old_cluster.pgdata);
576+
fprintf(script,RMDIR_CMD" %s\n",fix_path_separator(old_cluster.pgdata));
548577

549578
/* delete old cluster's alternate tablespaces */
550579
for (tblnum=0;tblnum<os_info.num_tablespaces;tblnum++)
@@ -561,14 +590,17 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
561590
fprintf(script,"\n");
562591
/* remove PG_VERSION? */
563592
if (GET_MAJOR_VERSION(old_cluster.major_version) <=804)
564-
fprintf(script,RM_CMD" %s%s/PG_VERSION\n",
565-
os_info.tablespaces[tblnum],old_cluster.tablespace_suffix);
593+
fprintf(script,RM_CMD" %s%s%cPG_VERSION\n",
594+
fix_path_separator(os_info.tablespaces[tblnum]),
595+
fix_path_separator(old_cluster.tablespace_suffix),
596+
PATH_SEPARATOR);
566597

567598
for (dbnum=0;dbnum<old_cluster.dbarr.ndbs;dbnum++)
568599
{
569-
fprintf(script,RMDIR_CMD" %s%s/%d\n",
570-
os_info.tablespaces[tblnum],old_cluster.tablespace_suffix,
571-
old_cluster.dbarr.dbs[dbnum].db_oid);
600+
fprintf(script,RMDIR_CMD" %s%s%c%d\n",
601+
fix_path_separator(os_info.tablespaces[tblnum]),
602+
fix_path_separator(old_cluster.tablespace_suffix),
603+
PATH_SEPARATOR,old_cluster.dbarr.dbs[dbnum].db_oid);
572604
}
573605
}
574606
else
@@ -578,7 +610,8 @@ create_script_for_old_cluster_deletion(char **deletion_script_file_name)
578610
* or a version-specific subdirectory.
579611
*/
580612
fprintf(script,RMDIR_CMD" %s%s\n",
581-
os_info.tablespaces[tblnum],old_cluster.tablespace_suffix);
613+
fix_path_separator(os_info.tablespaces[tblnum]),
614+
fix_path_separator(old_cluster.tablespace_suffix));
582615
}
583616

584617
fclose(script);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern char *output_files[];
7272
#definepg_copy_filecopy_file
7373
#definepg_mv_filerename
7474
#definepg_link_filelink
75+
#definePATH_SEPARATOR '/'
7576
#defineRM_CMD"rm -f"
7677
#defineRMDIR_CMD"rm -rf"
7778
#defineSCRIPT_EXT"sh"
@@ -81,6 +82,7 @@ extern char *output_files[];
8182
#definepg_mv_filepgrename
8283
#definepg_link_filewin32_pghardlink
8384
#definesleep(x)Sleep(x * 1000)
85+
#definePATH_SEPARATOR '\\'
8486
#defineRM_CMD"DEL /q"
8587
#defineRMDIR_CMD"RMDIR /s/q"
8688
#defineSCRIPT_EXT"bat"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp