pgcli: \watch command does not work
(this is a minor issue as \watch is not a well known command)
PostgreSQL has a \watch command to repeat queries every X seconds (as documented here): https://www.postgresql.org/docs/current/static/app-psql.html
It works perfectly on the psql CLI:
gab@db > SELECT 1; \watch 1;
?column?
----------
1
(1 row)
Time: 0.187 ms
Watch every 1s Wed Jul 6 12:01:54 2016
?column?
----------
1
(1 row)
Time: 0.047 ms
Watch every 1s Wed Jul 6 12:01:55 2016
?column?
----------
1
(1 row)
Time: 0.154 ms
Watch every 1s Wed Jul 6 12:01:56 2016
?column?
----------
1
(1 row)
Time: 0.164 ms
It does not work with pgcli:
db> SELECT 1; \watch 1;
+------------+
| ?column? |
|------------|
| 1 |
+------------+
SELECT 1
syntax error at or near "\"
LINE 1: \watch 1
^
Time: 0.003s
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 18 (9 by maintainers)
Commits related to this issue
- Issue #544 Implementation of watch command — committed to dbcli/pgcli by stuartquin 8 years ago
- Merge pull request #561 from dbcli/stuartquin/watch Issue #544 Implementation of watch command — committed to dbcli/pgcli by amjith 8 years ago
- Achieve better parity with psql's \watch - Include in '\?' documentation - Allow omitting a timing for default of 2s - Allow using \watch on multi-line SQL - Allow more whitespace Ref dbcli/pgcli#54... — committed to saifelse/pgspecial by saifelse 3 years ago
- Achieve better parity with psql's \watch - Include in '\?' documentation - Allow omitting a timing for default of 2s - Allow using \watch on multi-line SQL - Allow more whitespace Ref dbcli/pgcli#54... — committed to saifelse/pgspecial by saifelse 3 years ago
- Achieve better parity with psql's \watch - Include in '\?' documentation - Allow omitting a timing for default of 2s - Allow using \watch on multi-line SQL - Allow more whitespace Ref dbcli/pgcli#54... — committed to saifelse/pgspecial by saifelse 3 years ago
- Achieve better parity with psql's \watch (#120) - Include in '\?' documentation - Allow omitting a timing for default of 2s - Allow using \watch on multi-line SQL - Allow more whitespace Ref db... — committed to dbcli/pgspecial by saifelse 3 years ago
I guess the question is more “Is
\watchedsupposed to mimic thepsql\watchbehaviour exactly (as it seems the otherpgcli\xxxxfunctions do?”If
pgcliis just trying to be feature similar, it’s certainly there already, just fixing\?would suffice.If
pgcliis trying to act like a betterpsql, it’s definitely not correct yet.Fixed in pgspecial 1.8.0.
@ivyleavedtoadflax Now I got it. This happens when you don’t have a space after the semicolon:
This will work:
Yes, it’s a valid bug, because both versions should work. Thanks for the report.
I also just ran into this not working with a multiline query - e.g.
If it wasn’t required to have
\watchon the same line as the query I’d just use that and move on, but because it is necessary I figured I’d leave a comment. I’m using version 1.10.3 on mac.Oh, I see, it’s just it’s behaviour is different from
psql:So, the issue is then:
\watchas a single statement does not work (inpsql,\watchwith no SQL in the command line assumes you want to watch the previously executed query).\watchwith no argument does not work (psqldefaults to 2 seconds if the interval is not specified).\watchcommand doesn’t lead to any sort of helpful output.\?doesn’t list the mnemonics of\watchat all, so you don’t have anything to base how you are supposed to use it off of.For reference, here is how it works in
psql:Personally, I have never used watch as part of the query, but rather I futz with the query until it’s returning what I want, and then watch it, so I initially thought
pgclididn’t support\watchat all.