Re: Prevent psql \watch from running queries that return no rows - Mailing list pgsql-hackers

From Greg Sabino Mullane
Subject Re: Prevent psql \watch from running queries that return no rows
Date
Msg-id CAKAnmmLoiePXb9W9V+Jig9Rai2AuuTWxdz5kutJuqmTGQoDK7Q@mail.gmail.com
Whole thread Raw
In response to Re: Prevent psql \watch from running queries that return no rows  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: Prevent psql \watch from running queries that return no rows
List pgsql-hackers
Thanks for the feedback!

On Wed, Jul 5, 2023 at 5:51 AM Daniel Gustafsson <daniel@yesql.se> wrote:

The comment on ExecQueryAndProcessResults() needs to be updated with an
explanation of what this parameter is.

I added a comment in the place where min_rows is used, but not sure what you mean by adding it to the main comment at the top of the function?  None of the other args are explained there, even the non-intuitive ones  (e.g. svpt_gone_p)

-       return cancel_pressed ? 0 : success ? 1 : -1;
+       return (cancel_pressed || return_early) ? 0 : success ? 1 : -1;

I think this is getting tangled up enough that it should be replaced with
separate if() statements for the various cases.

Would like to hear others weigh in, I think it's still only three states plus a default, so I'm not convinced it warrants multiple statements yet. :)

+       HELP0("  \\watch [[i=]SEC] [c=N] [m=ROW]\n");
+       HELP0("                          execute query every SEC seconds, up to N times\n");
+       HELP0("                          stop if less than ROW minimum rows are rerturned\n");

"less than ROW minimum rows" reads a bit awkward IMO, how about calling it
[m=MIN] and describe as "stop if less than MIN rows are returned"?  Also, there
is a typo: s/rerturned/returned/.

Great idea: changed and will attach a new patch

Cheers,
Greg


Attachment

pgsql-hackers by date:

Previous
From: "Euler Taveira"
Date:
Subject: Re: Allow specifying a dbname in pg_basebackup connection string
Next
From: Ashutosh Bapat
Date:
Subject: Re: logicalrep_message_type throws an error