Skip to content

Commit 10249ab

Browse files
committed
Cleanup Win32 COPY handling, and move archive examples to SGML.
1 parent 43ea65a commit 10249ab

File tree

5 files changed

+34
-48
lines changed

5 files changed

+34
-48
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.275 2004/08/08 20:17:33 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.276 2004/08/12 19:03:17 momjian Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -1435,16 +1435,24 @@ SET ENABLE_SEQSCAN TO OFF;
14351435
<term><varname>archive_command</varname> (<type>string</type>)</term>
14361436
<listitem>
14371437
<para>
1438-
The shell command to execute to archive a completed segment of the
1439-
WAL file series. If this is an empty string (which is the default),
1440-
WAL archiving is disabled. Any <literal>%p</> in the string is
1441-
replaced
1442-
by the absolute path of the file to archive, while any <literal>%f</>
1443-
is replaced by the file name only. Write <literal>%%</> if you need
1444-
to embed an actual <literal>%</> character in the command. For more
1445-
information see <xref linkend="backup-archiving-wal">. This option
1446-
can only be set at server start or in the
1447-
<filename>postgresql.conf</filename> file.
1438+
The shell command to execute to archive a completed segment of
1439+
the WAL file series. If this is an empty string (the default),
1440+
WAL archiving is disabled. Any <literal>%p</> in the string is
1441+
replaced by the absolute path of the file to archive, and any
1442+
<literal>%f</> is replaced by the file name only. Use
1443+
<literal>%%</> to embed an actual <literal>%</> character in the
1444+
command. For more information see <xref
1445+
linkend="backup-archiving-wal">. This option can only be set at
1446+
server start or in the <filename>postgresql.conf</filename>
1447+
file.
1448+
</para>
1449+
<para>
1450+
It is important for the command to return a zero exit status only if
1451+
it succeeds. Examples:
1452+
<programlisting>
1453+
archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
1454+
archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
1455+
</programlisting>
14481456
</para>
14491457
</listitem>
14501458
</varlistentry>

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 13 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.161 2004/08/12 18:34:45 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.162 2004/08/12 19:03:23 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1962,18 +1962,6 @@ RestoreArchivedFile(char *path, const char *xlogfname,
19621962
/* %p: full path of target file */
19631963
sp++;
19641964
StrNCpy(dp, xlogpath, endp-dp);
1965-
/*
1966-
* make_native_path() is required because WIN32 COPY is
1967-
* an internal CMD.EXE command and doesn't process
1968-
* forward slashes in the same way as external commands.
1969-
* Quoting the first argument to COPY does not convert
1970-
* forward to backward slashes, but COPY does properly
1971-
* process quoted forward slashes in the 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-
*/
19771965
make_native_path(dp);
19781966
dp += strlen(dp);
19791967
break;

src/backend/postmaster/pgarch.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.6 2004/08/09 16:26:06 tgl Exp $
22+
* $PostgreSQL: pgsql/src/backend/postmaster/pgarch.c,v 1.7 2004/08/12 19:03:34 momjian Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -436,17 +436,8 @@ pgarch_archiveXlog(char *xlog)
436436
/* %p: full path of source file */
437437
sp++;
438438
StrNCpy(dp, pathname, endp-dp);
439-
#ifndef WIN32
439+
make_native_path(dp);
440440
dp += strlen(dp);
441-
#else
442-
/* On Windows, change / to \ in the substituted path */
443-
while (*dp)
444-
{
445-
if (*dp == '/')
446-
*dp = '\\';
447-
dp++;
448-
}
449-
#endif
450441
break;
451442
case 'f':
452443
/* %f: filename of source file */

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

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

119119
#archive_command = '' # command to use to archive a logfile segment
120-
#
121-
# If archive_command is '' then archiving is disabled. Otherwise, set it
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
130120

131121

132122
#---------------------------------------------------------------------------

src/port/path.c

Lines changed: 12 additions & 3 deletions
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.28 2004/08/12 18:32:52 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.29 2004/08/12 19:03:44 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -88,8 +88,17 @@ last_dir_separator(const char *filename)
8888

8989

9090
/*
91-
* make_native_path
92-
* On WIN32, change / to \ in the path.
91+
* make_native_path - on WIN32, change / to \ in the path
92+
*
93+
* This is required because WIN32 COPY is an internal CMD.EXE
94+
* command and doesn't process forward slashes in the same way
95+
* as external commands. Quoting the first argument to COPY
96+
* does not convert forward to backward slashes, but COPY does
97+
* properly process quoted forward slashes in the second argument.
98+
*
99+
* COPY works with quoted forward slashes in the first argument
100+
* only if the current directory is the same as the directory
101+
* of the first argument.
93102
*/
94103
void
95104
make_native_path(char *filename)

0 commit comments

Comments
 (0)