OK, patch attached and applied.
---------------------------------------------------------------------------
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > The attached applied patch cleans up our implementation and documents
> > its purpose. I also added some examples for 'archive_command'.
>
> If you're going to do that, do it in both places ... you missed
> pgarch.c.
>
> Also, I would say that the large block comment belongs with
> make_native_path, not with its caller.
>
> > ! #
> > # If archive_command is '' then archiving is disabled. Otherwise, set it
> > ! # to a command to copy a file to the proper place. Any %p in the string
> > ! # is replaced by the absolute path of the file to archive, while any %f is
> > ! # replaced by the file name only. NOTE: it is important for the command to
> > ! # return zero exit status only if it succeeds.
> > ! #
> > ! # Examples:
> > ! # archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
> > ! # archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
> > !
>
> This text should probably be removed from postgresql.conf.sample
> altogether; we are not in the habit of providing more than one-line
> documentation there. I stuck it in there as a quick and dirty thing
> because we didn't have archive_command in the SGML docs at the time.
> But now we do, and I'd say this info should be moved to runtime.sgml.
>
> regards, tom lane
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.275
diff -c -c -r1.275 runtime.sgml
*** doc/src/sgml/runtime.sgml 8 Aug 2004 20:17:33 -0000 1.275
--- doc/src/sgml/runtime.sgml 12 Aug 2004 18:54:37 -0000
***************
*** 1435,1450 ****
<term><varname>archive_command</varname> (<type>string</type>)</term>
<listitem>
<para>
! The shell command to execute to archive a completed segment of the
! WAL file series. If this is an empty string (which is the default),
! WAL archiving is disabled. Any <literal>%p</> in the string is
! replaced
! by the absolute path of the file to archive, while any <literal>%f</>
! is replaced by the file name only. Write <literal>%%</> if you need
! to embed an actual <literal>%</> character in the command. For more
! information see <xref linkend="backup-archiving-wal">. This option
! can only be set at server start or in the
! <filename>postgresql.conf</filename> file.
</para>
</listitem>
</varlistentry>
--- 1435,1458 ----
<term><varname>archive_command</varname> (<type>string</type>)</term>
<listitem>
<para>
! The shell command to execute to archive a completed segment of
! the WAL file series. If this is an empty string (the default),
! WAL archiving is disabled. Any <literal>%p</> in the string is
! replaced by the absolute path of the file to archive, and any
! <literal>%f</> is replaced by the file name only. Use
! <literal>%%</> to embed an actual <literal>%</> character in the
! command. For more information see <xref
! linkend="backup-archiving-wal">. This option can only be set at
! server start or in the <filename>postgresql.conf</filename>
! file.
! </para>
! <para>
! It is important for the command to return a zero exit status only if
! it succeeds. Examples:
! <programlisting>
! archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
! archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
! </programlisting>
</para>
</listitem>
</varlistentry>
Index: src/backend/access/transam/xlog.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/access/transam/xlog.c,v
retrieving revision 1.161
diff -c -c -r1.161 xlog.c
*** src/backend/access/transam/xlog.c 12 Aug 2004 18:34:45 -0000 1.161
--- src/backend/access/transam/xlog.c 12 Aug 2004 18:54:50 -0000
***************
*** 1962,1979 ****
/* %p: full path of target file */
sp++;
StrNCpy(dp, xlogpath, endp-dp);
- /*
- * make_native_path() is required because WIN32 COPY is
- * an internal CMD.EXE command and doesn't process
- * forward slashes in the same way as external commands.
- * Quoting the first argument to COPY does not convert
- * forward to backward slashes, but COPY does properly
- * process quoted forward slashes in the second argument.
- *
- * COPY works with quoted forward slashes in the first argument
- * only if the current directory is the same as the directory
- * of the first argument.
- */
make_native_path(dp);
dp += strlen(dp);
break;
--- 1962,1967 ----
Index: src/backend/postmaster/pgarch.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/pgarch.c,v
retrieving revision 1.6
diff -c -c -r1.6 pgarch.c
*** src/backend/postmaster/pgarch.c 9 Aug 2004 16:26:06 -0000 1.6
--- src/backend/postmaster/pgarch.c 12 Aug 2004 18:54:52 -0000
***************
*** 436,452 ****
/* %p: full path of source file */
sp++;
StrNCpy(dp, pathname, endp-dp);
! #ifndef WIN32
dp += strlen(dp);
- #else
- /* On Windows, change / to \ in the substituted path */
- while (*dp)
- {
- if (*dp == '/')
- *dp = '\\';
- dp++;
- }
- #endif
break;
case 'f':
/* %f: filename of source file */
--- 436,443 ----
/* %p: full path of source file */
sp++;
StrNCpy(dp, pathname, endp-dp);
! make_native_path(dp);
dp += strlen(dp);
break;
case 'f':
/* %f: filename of source file */
Index: src/backend/utils/misc/postgresql.conf.sample
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v
retrieving revision 1.125
diff -c -c -r1.125 postgresql.conf.sample
*** src/backend/utils/misc/postgresql.conf.sample 12 Aug 2004 18:32:37 -0000 1.125
--- src/backend/utils/misc/postgresql.conf.sample 12 Aug 2004 18:54:55 -0000
***************
*** 117,132 ****
# - Archiving -
#archive_command = '' # command to use to archive a logfile segment
- #
- # If archive_command is '' then archiving is disabled. Otherwise, set it
- # to a command to copy a file to the proper place. Any %p in the string
- # is replaced by the absolute path of the file to archive, while any %f is
- # replaced by the file name only. NOTE: it is important for the command to
- # return zero exit status only if it succeeds.
- #
- # Examples:
- # archive_command = 'cp "%p" /mnt/server/archivedir/"%f"'
- # archive_command = 'copy "%p" /mnt/server/archivedir/"%f"' # Win32
#---------------------------------------------------------------------------
--- 117,122 ----
Index: src/port/path.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/path.c,v
retrieving revision 1.28
diff -c -c -r1.28 path.c
*** src/port/path.c 12 Aug 2004 18:32:52 -0000 1.28
--- src/port/path.c 12 Aug 2004 18:55:02 -0000
***************
*** 88,95 ****
/*
! * make_native_path
! * On WIN32, change / to \ in the path.
*/
void
make_native_path(char *filename)
--- 88,104 ----
/*
! * make_native_path - on WIN32, change / to \ in the path
! *
! * This is required because WIN32 COPY is an internal CMD.EXE
! * command and doesn't process forward slashes in the same way
! * as external commands. Quoting the first argument to COPY
! * does not convert forward to backward slashes, but COPY does
! * properly process quoted forward slashes in the second argument.
! *
! * COPY works with quoted forward slashes in the first argument
! * only if the current directory is the same as the directory
! * of the first argument.
*/
void
make_native_path(char *filename)