Re: [GENERAL] Archiving data to another server using copy, psql with pipe - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] Archiving data to another server using copy, psql with pipe
Date
Msg-id CAKFQuwZ3WX6wXn9n3x2GH6L7GvkxqDWH4zqMWz25cDdGvV6zNg@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Archiving data to another server using copy, psql withpipe  (Moreno Andreo <moreno.andreo@evolu-s.it>)
List pgsql-general
On Thu, Apr 6, 2017 at 4:24 AM, Moreno Andreo <moreno.andreo@evolu-s.it> wrote:
psql -h localhost postgres -c "copy (SELECT * FROM a WHERE time < now()) to
stdout " | psql -h localhost  postgres   -c "copy b from stdin"

​The first question at hand is whether the source psql command will provoke an EOF (which is the only thing that will stop the copy-from) even though the complete contents of the copy-to have not yet been sent.

​The second question is whether, even if it does send EOF, the second command will be allowed to see that EOF and complete its command.  Pipeline failure mode might impact this (from bash experience).

Unfortunately I do not know the answers to those questions.

The source code might be of some help on the first.

Another option is to replace the first psql process with custom program that will send data to stdout and in the middle of doing so die with a non-zero exit code.​  That should be a workable simulation of the copy to command and evaluation of the target can be done to see what behavior is exhibitied.

David J.

pgsql-general by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: [GENERAL] A change in the Debian install
Next
From: Tom DalPozzo
Date:
Subject: Re: [GENERAL] WAL being written during SELECT * query