patch to add \watch to psql

From: Will Leinweber <will(at)heroku(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: patch to add \watch to psql
Date: 2012-10-20 00:15:27
Message-ID: CAL8LqZSE+3OC-rkG+rWFShWik=Qjw-K2zWAgjjiX0_fCwuRHhA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This patch adds \watch to psql. It is much like the unix equivalent,
defaulting to every 2 seconds, and allowing you optionally specify a number
of seconds.

I will add this to the commit fest app.

Thanks,
Will Leinweber

Example:

psql (9.3devel, server 9.1.4)
Type "help" for help.

will=# \watch select now();
Watch every 2s Fri Oct 19 17:09:23 2012

now
-------------------------------
2012-10-19 17:09:23.743176-07
(1 row)

Watch every 2s Fri Oct 19 17:09:25 2012

now
-------------------------------
2012-10-19 17:09:25.745125-07
(1 row)

Watch every 2s Fri Oct 19 17:09:27 2012

now
-------------------------------
2012-10-19 17:09:27.746732-07
(1 row)

^Cwill=# \watch 5 select now();
Watch every 5s Fri Oct 19 17:09:33 2012

now
-------------------------------
2012-10-19 17:09:33.563695-07
(1 row)

Watch every 5s Fri Oct 19 17:09:38 2012

now
-------------------------------
2012-10-19 17:09:38.564802-07
(1 row)

^Cwill=# \watch select pg_sleep(20);
^CCancel request sent
ERROR: canceling statement due to user request
will=#

Attachment Content-Type Size
psql-watch-v1.patch application/octet-stream 3.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2012-10-20 01:02:57 Re: pg_stat_lwlocks view - lwlocks statistics, round 2
Previous Message Jeremy Evans 2012-10-19 23:19:19 Re: Always include encoding of database in pg_dumpall