Re: [COMMITTERS] pgsql: Don't use "cp -i" in the example WALarchive_command. - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [COMMITTERS] pgsql: Don't use "cp -i" in the example WALarchive_command.
Date
Msg-id 201106172332.p5HNWYZ20519@momjian.us
Whole thread Raw
Responses Re: Re: [COMMITTERS] pgsql: Don't use "cp -i" in the example WAL archive_command.
List pgsql-hackers
Wow, this is the first I am hearing GNU cp -i can return zero exit if it
doesn't do the copy.  I tested this on Ubuntu 10.04 using cp 7.4 and
got:

    $ touch x y
    $ cp -i x y; echo $?
    cp: overwrite `y'? n
    0

I see the same on my anchent BSD/OS machine too:

    $ touch x y
    $ cp -i x y; echo $?
    overwrite y? n
    0

Were we expecting an error if the file already existed?  Assuming that,
we should assume the file will always exist so basically archiving will
never progress.  Is this what we want?  I just wasn't aware we were
expecting an already-existing this to be an error --- I thought we just
didn't want to overwrite it.

---------------------------------------------------------------------------

Tom Lane wrote:
> Don't use "cp -i" in the example WAL archive_command.
>
> This is a dangerous example to provide because on machines with GNU cp,
> it will silently do the wrong thing and risk archive corruption.  Worse,
> during the 9.0 cycle somebody "improved" the discussion by removing the
> warning that used to be there about that, and instead leaving the
> impression that the command would work as desired on most Unixen.
> It doesn't.  Try to rectify the damage by providing an example that is safe
> most everywhere, and then noting that you can try cp -i if you want but
> you'd better test that.
>
> In back-patching this to all supported branches, I also added an example
> command for Windows, which wasn't provided before 9.0.
>
> Branch
> ------
> REL8_3_STABLE
>
> Details
> -------
> http://git.postgresql.org/pg/commitdiff/23843d242f00e6597af91d4f4d08b655b2b362ba
>
> Modified Files
> --------------
> doc/src/sgml/backup.sgml |   25 ++++++++++++++-----------
> 1 files changed, 14 insertions(+), 11 deletions(-)
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


pgsql-hackers by date:

Previous
From: Brendan Jurd
Date:
Subject: Fwd: Keywords in pg_hba.conf should be field-specific
Next
From: Brendan Jurd
Date:
Subject: Re: minor patch submission: CREATE CAST ... AS EXPLICIT