Hi Pavel,
On 11/16/2012 12:21:11 AM, Pavel Stehule wrote:
> 2012/11/16 Karl O. Pinc <kop@meme.com>:
> > As long as I'm talking crazy talk, why not
> > abandon psql as a shell language and instead make a
> > pl/pgsql interpreter with readlne() in front
> > of it? Solve all these language-related
> > issues by using an actual programming language. :-)
> I though about it more time, but I don't thinking so this has a
> sense.
> Actually we cannot do perfect autocomplete for significantly simpler
> SQL and there are lot of client side interprets - is not reason for
> next one. I use psql together bash and it works well. But just very
> simple task as storing some volatile data for repetitive usage is
> relative laborious and it is a motivation for this patch. In psql I
> can simply work with any fields of returned record - what is more
> terrible work outside psql
You might consider using "do".
http://www.postgresql.org/docs/9.1/static/sql-do.html
If you need to maintain a single connection you can do
some interesting things with socat to feed a running psql
in the background.
socat -u UNIX-RECV:/tmp/msock EXEC:psql &
Followed by lots of
echo bar | socat -u STDIN UNIX-SENDTO:/tmp/mysock
\o can be used to send output for pickup, although
you do need to fuss around with the asynchronous nature
of things to be sure you're waiting for output.
I used inotifywait for this. YMMV.
Regards,
Karl <kop@meme.com>
Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein