Re: \gexec \watch

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: \gexec \watch
Дата
Msg-id e45b1486-9695-4a06-aeb6-1279d0a733a6@manitou-mail.org
обсуждение исходный текст
Ответ на Re: \gexec \watch  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: \gexec \watch  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: \gexec \watch
Следующее
От: Dagfinn Ilmari Mannsåker
Дата:
Сообщение: Re: [proposal] Add an option for returning SQLSTATE in psql errormessage