public inbox for [email protected]
help / color / mirror / Atom feed\i and \watch
4+ messages / 3 participants
[nested] [flat]
* \i and \watch
@ 2024-11-07 05:09 Edwin UY <[email protected]>
2024-11-07 05:26 ` Re: \i and \watch David G. Johnston <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Edwin UY @ 2024-11-07 05:09 UTC (permalink / raw)
To: [email protected]
Hi,
Is there no way to use \watch to let it run the last script that I just run?
When do I do as below:
select 1 ;
\i x.sql
\watch 20
It runs select 1 instead.
At the moment, a workaround is I run the content of x.sql itself and then
run watch.
Please advise. Thanks.
Regards,
Ed
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: \i and \watch
2024-11-07 05:09 \i and \watch Edwin UY <[email protected]>
@ 2024-11-07 05:26 ` David G. Johnston <[email protected]>
2024-11-07 07:49 ` Re: \i and \watch Edwin UY <[email protected]>
2024-11-07 13:43 ` Re: \i and \watch Tom Lane <[email protected]>
0 siblings, 2 replies; 4+ messages in thread
From: David G. Johnston @ 2024-11-07 05:26 UTC (permalink / raw)
To: Edwin UY <[email protected]>; +Cc: [email protected] <[email protected]>
On Wednesday, November 6, 2024, Edwin UY <[email protected]> wrote:
>
> Is there no way to use \watch to let it run the last script that I just
> run?
>
> When do I do as below:
>
> select 1 ;
> \i x.sql
> \watch 20
>
> It runs select 1 instead.
>
>
Watch is documented to act on either a non-empty query buffer or the last
sent command. I would expect that whatever the final SQL command present
in x.sql is would be the command that gets watched. If indeed the
preceding select 1 command is watched there would seem to be an
undocumented interaction going on.
In any case, no, you cannot watch a meta-command. You’d have to resort to
shell scripting the repeated execution of the psql program itself.
David J.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: \i and \watch
2024-11-07 05:09 \i and \watch Edwin UY <[email protected]>
2024-11-07 05:26 ` Re: \i and \watch David G. Johnston <[email protected]>
@ 2024-11-07 07:49 ` Edwin UY <[email protected]>
1 sibling, 0 replies; 4+ messages in thread
From: Edwin UY @ 2024-11-07 07:49 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: [email protected] <[email protected]>
Thanks for the explanation.
Yeah, here's what's happening. So, yeah, we'll check on having to script it
instead.
###
=> select now() ;
now
-------------------------------
2024-11-07 07:46:23.876888+00
(1 row)
=> \! cat x.sql
select version() ;
=> \i x.sql
version
--------------------------------------------------------------------------------------------------------------
PostgreSQL 14.12 on aarch64-unknown-linux-gnu, compiled by
aarch64-unknown-linux-gnu-gcc (GCC) 9.5.0, 64-bit
(1 row)
=> \watch 5
Thu 07 Nov 2024 20:47:05 NZDT (every 5s)
now
-------------------------------
2024-11-07 07:47:05.411747+00
(1 row)
Thu 07 Nov 2024 20:47:10 NZDT (every 5s)
now
-------------------------------
2024-11-07 07:47:10.418915+00
(1 row)
^C
On Thu, Nov 7, 2024 at 6:26 PM David G. Johnston <[email protected]>
wrote:
> On Wednesday, November 6, 2024, Edwin UY <[email protected]> wrote:
>
>>
>> Is there no way to use \watch to let it run the last script that I just
>> run?
>>
>> When do I do as below:
>>
>> select 1 ;
>> \i x.sql
>> \watch 20
>>
>> It runs select 1 instead.
>>
>>
> Watch is documented to act on either a non-empty query buffer or the last
> sent command. I would expect that whatever the final SQL command present
> in x.sql is would be the command that gets watched. If indeed the
> preceding select 1 command is watched there would seem to be an
> undocumented interaction going on.
>
> In any case, no, you cannot watch a meta-command. You’d have to resort to
> shell scripting the repeated execution of the psql program itself.
>
> David J.
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: \i and \watch
2024-11-07 05:09 \i and \watch Edwin UY <[email protected]>
2024-11-07 05:26 ` Re: \i and \watch David G. Johnston <[email protected]>
@ 2024-11-07 13:43 ` Tom Lane <[email protected]>
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lane @ 2024-11-07 13:43 UTC (permalink / raw)
To: David G. Johnston <[email protected]>; +Cc: Edwin UY <[email protected]>; [email protected] <[email protected]>
"David G. Johnston" <[email protected]> writes:
> Watch is documented to act on either a non-empty query buffer or the last
> sent command. I would expect that whatever the final SQL command present
> in x.sql is would be the command that gets watched. If indeed the
> preceding select 1 command is watched there would seem to be an
> undocumented interaction going on.
It looks like there's a separate query_buf for each recursive level
of MainLoop(), that is, each level of \i. So maybe the docs need
improvement here. (I think the actual behavior is probably fine.)
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-11-07 13:43 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-07 05:09 \i and \watch Edwin UY <[email protected]>
2024-11-07 05:26 ` David G. Johnston <[email protected]>
2024-11-07 07:49 ` Edwin UY <[email protected]>
2024-11-07 13:43 ` Tom Lane <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox