Re: psql \watch 2nd argument: iteration count

2023-05-09 Thread Tom Lane
Peter Eisentraut writes: > On 13.03.23 02:17, Michael Paquier wrote: >> I am not sure that this will be the last option we'll ever add to >> \watch, so I'd rather have us choose a design more flexible than >> what's proposed here, in a way similar to \g or \gx. > On the other hand, we also have

Re: psql \watch 2nd argument: iteration count

2023-05-09 Thread Peter Eisentraut
On 13.03.23 02:17, Michael Paquier wrote: On Sun, Mar 12, 2023 at 01:05:39PM -0700, Andrey Borodin wrote: In the review above Kyotaro-san suggested that message should contain information on what it expects... So, maybe then pg_log_error("\\watch interval must be non-negative number, but

Re: psql \watch 2nd argument: iteration count

2023-04-06 Thread Andrey Borodin
On Thu, Apr 6, 2023 at 10:23 PM Tom Lane wrote: > > Kirk Wolak writes: > > Marked as Ready for Committer. > > Pushed with a pretty fair number of cosmetic changes. Great, thank you! > If you write a semicolon first, you get four, but it's the semicolon > producing the first result not \watch.

Re: psql \watch 2nd argument: iteration count

2023-04-06 Thread Tom Lane
Kirk Wolak writes: > Marked as Ready for Committer. Pushed with a pretty fair number of cosmetic changes. One non-cosmetic change I made is that I didn't agree with your interpretation of the execution count. IMO this ought to produce three executions: regression=# select 1 \watch c=3 Thu Apr

Re: psql \watch 2nd argument: iteration count

2023-04-04 Thread Kirk Wolak
On Fri, Mar 24, 2023 at 10:32 PM Andrey Borodin wrote: > On Thu, Mar 23, 2023 at 10:15 PM Yugo NAGATA wrote: > > > > Here is my review on the v9 patch. > > > > + /* we do not prevent numerous names iterations like > i=1 i=1 i=1 */ > > + have_sleep = true; > >

Re: psql \watch 2nd argument: iteration count

2023-03-24 Thread Andrey Borodin
On Thu, Mar 23, 2023 at 10:15 PM Yugo NAGATA wrote: > > Here is my review on the v9 patch. > > + /* we do not prevent numerous names iterations like i=1 > i=1 i=1 */ > + have_sleep = true; > > Why this is allowed here? I am not sure there is any reason to

Re: psql \watch 2nd argument: iteration count

2023-03-23 Thread Yugo NAGATA
Hello, On Thu, 16 Mar 2023 21:15:30 -0700 Andrey Borodin wrote: > On Wed, Mar 15, 2023 at 5:54 PM Michael Paquier wrote: > > > > On Wed, Mar 15, 2023 at 04:58:49PM +0900, Michael Paquier wrote: > > > Yep. You are right. > > > > Fixed that and applied 0001. > Great, thanks! > > > > > +

Re: psql \watch 2nd argument: iteration count

2023-03-16 Thread Andrey Borodin
On Wed, Mar 15, 2023 at 5:54 PM Michael Paquier wrote: > > On Wed, Mar 15, 2023 at 04:58:49PM +0900, Michael Paquier wrote: > > Yep. You are right. > > Fixed that and applied 0001. Great, thanks! > > +valptr++; > +if (strncmp("i", opt, strlen("i")) == 0 || > +

Re: psql \watch 2nd argument: iteration count

2023-03-15 Thread Michael Paquier
On Wed, Mar 15, 2023 at 04:58:49PM +0900, Michael Paquier wrote: > Yep. You are right. Fixed that and applied 0001. +valptr++; +if (strncmp("i", opt, strlen("i")) == 0 || +strncmp("interval", opt, strlen("interval")) == 0) +{ Did you look at process_command_g_options()

Re: psql \watch 2nd argument: iteration count

2023-03-15 Thread Michael Paquier
On Tue, Mar 14, 2023 at 09:23:48PM -0700, Nathan Bossart wrote: > + sleep = strtod(opt, _end); > + if (sleep < 0 || *opt_end || errno == ERANGE) > > Should we set errno to 0 before calling strtod()? Yep. You are right. -- Michael signature.asc

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Nathan Bossart
+ sleep = strtod(opt, _end); + if (sleep < 0 || *opt_end || errno == ERANGE) Should we set errno to 0 before calling strtod()? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Michael Paquier
On Tue, Mar 14, 2023 at 08:20:23PM -0700, Andrey Borodin wrote: > PFA v8. Thanks! Looks OK to me. I've looked as well at resetting query_buffer on failure, which I guess is better this way because this is an accumulation of the previous results, right? -- Michael signature.asc Description: PGP

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Andrey Borodin
On Tue, Mar 14, 2023 at 6:25 PM Michael Paquier wrote: > > On Wed, Mar 15, 2023 at 10:19:28AM +0900, Kyotaro Horiguchi wrote: > > I hesitated to propose such a level of simplification, but basically I > > was alsothinking the same thing. +1 > Okay, fine by me to use one single message. I'd

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Michael Paquier
On Wed, Mar 15, 2023 at 10:19:28AM +0900, Kyotaro Horiguchi wrote: > I hesitated to propose such a level of simplification, but basically I > was alsothinking the same thing. Okay, fine by me to use one single message. I'd rather still keep the three tests, though, as they check the three

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Kyotaro Horiguchi
At Tue, 14 Mar 2023 12:03:00 -0700, Nathan Bossart wrote in > On Tue, Mar 14, 2023 at 01:58:59PM +0900, Kyotaro Horiguchi wrote: > > + if (*opt_end) > > + pg_log_error("\\watch: incorrect > > interval value '%s'", opt); > > +

Re: psql \watch 2nd argument: iteration count

2023-03-14 Thread Nathan Bossart
On Tue, Mar 14, 2023 at 01:58:59PM +0900, Kyotaro Horiguchi wrote: > + if (*opt_end) > + pg_log_error("\\watch: incorrect > interval value '%s'", opt); > + else if (errno == ERANGE) > +

Re: psql \watch 2nd argument: iteration count

2023-03-13 Thread Kyotaro Horiguchi
At Tue, 14 Mar 2023 11:36:17 +0900, Michael Paquier wrote in > Ok, thanks for looking. Let's wait a bit and see if others have an > opinion to offer. At least, the CI is green. + if (*opt_end) + pg_log_error("\\watch:

Re: psql \watch 2nd argument: iteration count

2023-03-13 Thread Michael Paquier
On Mon, Mar 13, 2023 at 06:14:18PM -0700, Andrey Borodin wrote: > Looks good to me. Ok, thanks for looking. Let's wait a bit and see if others have an opinion to offer. At least, the CI is green. -- Michael signature.asc Description: PGP signature

Re: psql \watch 2nd argument: iteration count

2023-03-13 Thread Andrey Borodin
On Mon, Mar 13, 2023 at 5:26 PM Michael Paquier wrote: > > I have tweaked things as bit as of the attached, and ran pgindent. > What do you think? > Looks good to me. Thanks! Best regards, Andrey Borodin.

Re: psql \watch 2nd argument: iteration count

2023-03-13 Thread Michael Paquier
On Sun, Mar 12, 2023 at 08:59:44PM -0700, Andrey Borodin wrote: > I've tried this approach, but could not come up with sufficiently > different error messages... > >> Wouldn't it be better to have a couple of regression >> tests, as well? > Added two tests. It should have three tests with one

Re: psql \watch 2nd argument: iteration count

2023-03-12 Thread Andrey Borodin
Michael, thanks for reviewing this! On Sun, Mar 12, 2023 at 6:17 PM Michael Paquier wrote: > > On Sun, Mar 12, 2023 at 01:05:39PM -0700, Andrey Borodin wrote: > > In the review above Kyotaro-san suggested that message should contain > > information on what it expects... So, maybe then > >

Re: psql \watch 2nd argument: iteration count

2023-03-12 Thread Michael Paquier
On Mon, Mar 13, 2023 at 10:17:12AM +0900, Michael Paquier wrote: > I am not sure that this will be the last option we'll ever add to > \watch, so I'd rather have us choose a design more flexible than > what's proposed here, in a way similar to \g or \gx. While on it, I have some comments about

Re: psql \watch 2nd argument: iteration count

2023-03-12 Thread Michael Paquier
On Sun, Mar 12, 2023 at 01:05:39PM -0700, Andrey Borodin wrote: > In the review above Kyotaro-san suggested that message should contain > information on what it expects... So, maybe then > pg_log_error("\\watch interval must be non-negative number, but > argument is '%s'", opt); ? > Or perhaps

Re: psql \watch 2nd argument: iteration count

2023-03-12 Thread Andrey Borodin
On Thu, Mar 9, 2023 at 11:25 AM Nathan Bossart wrote: > > + pg_log_error("Watch period must be > non-negative number, but argument is '%s'", opt); > > After looking around at the other error messages in this file, I think we > should make this more concise. Maybe

Re: psql \watch 2nd argument: iteration count

2023-03-09 Thread Nathan Bossart
+ pg_log_error("Watch period must be non-negative number, but argument is '%s'", opt); After looking around at the other error messages in this file, I think we should make this more concise. Maybe something like pg_log_error("\\watch: invalid delay

Re: psql \watch 2nd argument: iteration count

2023-03-08 Thread Andrey Borodin
On Wed, Mar 8, 2023 at 10:49 AM Nathan Bossart wrote: > > Is there any reason to disallow 0 for the sleep argument? I often use > commands like "\watch .1" to run statements repeatedly with very little > time in between, and I'd use "\watch 0" instead if it was available. > Yes, that makes

Re: psql \watch 2nd argument: iteration count

2023-03-08 Thread Nathan Bossart
+1 for adding an iteration count argument to \watch. + char *opt_end; + sleep = strtod(opt, _end); + if (sleep <= 0 || *opt_end) + { + pg_log_error("Watch period must be positive

Re: psql \watch 2nd argument: iteration count

2023-02-26 Thread Andrey Borodin
Thanks for looking into this! On Mon, Feb 20, 2023 at 6:15 PM Kyotaro Horiguchi wrote: > > FWIW the patch still accepts an incorrect parameter '1abc' > by ignoring any trailing garbage. Indeed, fixed. > > In any case, I reckon the error message should be more specific. In > other words, it

Re: psql \watch 2nd argument: iteration count

2023-02-20 Thread Kyotaro Horiguchi
At Mon, 20 Feb 2023 10:45:53 -0800, Andrey Borodin wrote in > > > > Also, if we do not provide a timespan, 2 seconds are selected. But if > > > > we provide an incorrect argument - 1 second is selected. > > > > PFA the patch that adds iteration count argument and makes timespan > > > > argument

Re: psql \watch 2nd argument: iteration count

2023-02-20 Thread Andrey Borodin
> > > Also, if we do not provide a timespan, 2 seconds are selected. But if > > > we provide an incorrect argument - 1 second is selected. > > > PFA the patch that adds iteration count argument and makes timespan > > > argument more consistent. > > > > That should probably be fixed. > > And should

Re: psql \watch 2nd argument: iteration count

2023-02-20 Thread Stephen Frost
Greetings, * Peter Eisentraut (peter.eisentr...@enterprisedb.com) wrote: > On 17.02.23 00:33, Andrey Borodin wrote: > > From time to time I want to collect some stats from locks, activity > > and other stat views into one table from different time points. In > > this case the \watch psql command

Re: psql \watch 2nd argument: iteration count

2023-02-20 Thread Peter Eisentraut
On 17.02.23 00:33, Andrey Borodin wrote: From time to time I want to collect some stats from locks, activity and other stat views into one table from different time points. In this case the \watch psql command is very handy. However, it's not currently possible to specify the number of times a

psql \watch 2nd argument: iteration count

2023-02-16 Thread Andrey Borodin
Hi hackers! >From time to time I want to collect some stats from locks, activity and other stat views into one table from different time points. In this case the \watch psql command is very handy. However, it's not currently possible to specify the number of times a query is performed. Also, if