From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com> |
Cc: | "David Fetter" <david(at)fetter(dot)org>,"Pg Hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: \gexec \watch |
Date: | 2018-12-06 13:13:20 |
Message-ID: | e45b1486-9695-4a06-aeb6-1279d0a733a6@manitou-mail.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera wrote:
> Honestly, I don't see the mathematicality in this. It either works, or
> it doesn't -- and from my POV right now it doesn't. Are you saying we
> need a \gexecwatch for this to work?
>
> I can of course solve my problem with a simple python program, but psql
> is so close ...
\watch reexecutes what's in the query buffer, and \gexec does not
write into the query buffer, so the desired piping does not happen
by design.
I think you could achieve more or less the result with a pre-gexec
hack like that:
postgres=# \pset tuples_only on
postgres=# select 'select now();' \g /tmp/file.sql
postgres=# \setenv EDITOR touch
postgres=# \e /tmp/file.sql
2018-12-06 13:54:24.915752+01
postgres=# \watch
2018-12-06 13:54:42.366559+01
2018-12-06 13:54:44.368962+01
2018-12-06 13:54:46.3713+01
....
The "\setenv EDITOR touch" kludge is meant to force \e to
inject the contents of /tmp/file.sql into the query buffer.
It's needed because "\e file" actually checks whether the file has
been modified (per mtime) after $EDITOR returns, and discards it
if it hasn't.
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite
From | Date | Subject | |
---|---|---|---|
Next Message | Dagfinn Ilmari Mannsåker | 2018-12-06 13:18:20 | Re: [proposal] Add an option for returning SQLSTATE in psql error message |
Previous Message | Pavel Stehule | 2018-12-06 13:03:26 | Re: \gexec \watch |