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

Commit6525b42

Browse files
committed
Add make_native_path() because Win32 COPY is an internal CMD.EXE command
and doesn't process forward slashes in the same way as externalcommands. Quoting the first argument to COPY does not convert forwardto backward slashes, but COPY does properly process quoted forwardslashes in the second argument.Win32 COPY works with quoted forward slashes in the first argument only if thecurrent directory is the same as the directory of the first argument.
1 parente48322a commit6525b42

File tree

4 files changed

+44
-19
lines changed

4 files changed

+44
-19
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.159 2004/08/11 04:07:15 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.160 2004/08/12 18:32:25 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1962,17 +1962,20 @@ RestoreArchivedFile(char *path, const char *xlogfname,
19621962
/* %p: full path of target file */
19631963
sp++;
19641964
StrNCpy(dp,xlogpath,endp-dp);
1965-
#ifndefWIN32
1965+
/*
1966+
*make_native_path() is required because COPY is an internal
1967+
*CMD.EXE command and doesn't process forward slashes in the
1968+
*same way as external commands. Quoting the first argument
1969+
*to COPY does not convert forward to backward slashes, but
1970+
*COPY does properly process quoted forward slashes in the
1971+
*second argument.
1972+
*
1973+
*COPY works with quoted forward slashes in the first argument
1974+
*only if the current directory is the same as the directory
1975+
*of the first argument.
1976+
*/
1977+
make_native_path(dp);
19661978
dp+=strlen(dp);
1967-
#else
1968-
/* On Windows, change / to \ in the substituted path */
1969-
while (*dp)
1970-
{
1971-
if (*dp=='/')
1972-
*dp='\\';
1973-
dp++;
1974-
}
1975-
#endif
19761979
break;
19771980
case'f':
19781981
/* %f: filename of desired file */

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,17 @@
117117
# - Archiving -
118118

119119
#archive_command = ''# command to use to archive a logfile segment
120-
120+
#
121121
# If archive_command is '' then archiving is disabled. Otherwise, set it
122-
# to a command to copy a file to the proper place. A simplistic example
123-
# is 'cp %p /mnt/server/archivedir/%f'. Any %p in the string is replaced
124-
# by the absolute path of the file to archive, while any %f is replaced by
125-
# the file name only. NOTE: it is important for the command to return
126-
# zero exit status if and only if it succeeded.
122+
# to a command to copy a file to the proper place. Any %p in the string
123+
# is replaced by the absolute path of the file to archive, while any %f is
124+
# replaced by the file name only. NOTE: it is important for the command to
125+
# return zero exit status only if it succeeds.
126+
#
127+
# Examples:
128+
# archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
129+
# archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
130+
127131

128132
#---------------------------------------------------------------------------
129133
# QUERY TUNING

‎src/include/port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.51 2004/08/09 02:12:51 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.52 2004/08/12 18:32:43 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -39,6 +39,7 @@ extern char *last_dir_separator(const char *filename);
3939
externchar*first_path_separator(constchar*filename);
4040

4141
externvoidcanonicalize_path(char*path);
42+
externvoidmake_native_path(char*path);
4243
externconstchar*get_progname(constchar*argv0);
4344
externvoidget_share_path(constchar*my_exec_path,char*ret_path);
4445
externvoidget_etc_path(constchar*my_exec_path,char*ret_path);

‎src/port/path.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.27 2004/08/09 20:20:46 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.28 2004/08/12 18:32:52 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -87,6 +87,23 @@ last_dir_separator(const char *filename)
8787
}
8888

8989

90+
/*
91+
*make_native_path
92+
*On WIN32, change / to \ in the path.
93+
*/
94+
void
95+
make_native_path(char*filename)
96+
{
97+
#ifdefWIN32
98+
char*p;
99+
100+
for (p=filename;*p;p++)
101+
if (*p=='/')
102+
*p='\\';
103+
#endif
104+
}
105+
106+
90107
/*
91108
* Make all paths look like Unix
92109
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp