Skip site navigation (1) Skip section navigation (2)

Re: psql and named pipes

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Aidan Van Dyk <aidan(at)highrise(dot)ca>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql and named pipes
Date: 2008-03-27 17:51:39
Message-ID: 20080327175139.GO8764@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-hackers
Aidan Van Dyk wrote:

> I've had to use:
> 	while (true); do cat pipe; done | psql
> 
> The trick is that pipes "EOF"s everytime the cleint closes it.  (Not
> strictly true, but it appears that way to basic read()ers).

Ah!  Yeah, I knew that and forgot :-)  It's easier than that actually --
you just need to keep the pipe open in another process.  So I can do
this: first open a terminal with

$ psql -f foo

And then, in another terminal,

$ cat > foo &
[1] 29155

[1]+  Stopped                 cat >foo
$ echo "begin;" > foo
$ echo "create table a (a int);" > foo
$ echo "insert into a values (1);" > foo
$ echo "insert into a values (2);" > foo
$ echo "insert into a values (3);" > foo
$ echo "commit;" > foo
$ echo "select * from a;" > foo
$ kill %1
-bash: echo: write error: Appel système interrompu
[1]+  Complété              cat >foo


And while this is going on, the other terminal shows the output being
produced by psql.

Thanks for the reminder :-)

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

pgsql-hackers by date

Next:From: Aidan Van DykDate: 2008-03-27 17:55:03
Subject: Re: psql and named pipes
Previous:From: Simon RiggsDate: 2008-03-27 17:34:25
Subject: Re: Minor changes to Recovery related code

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group