Re: Prevent psql \watch from running queries that return no rows

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: daniel(at)yesql(dot)se
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Prevent psql \watch from running queries that return no rows
Date: 2023-07-05 14:14:22
Message-ID: CAKAnmmLoiePXb9W9V+Jig9Rai2AuuTWxdz5kutJuqmTGQoDK7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the feedback!

On Wed, Jul 5, 2023 at 5:51 AM Daniel Gustafsson <daniel(at)yesql(dot)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 Content-Type Size
psql_watch_exit_on_zero_rows_v3.patch application/octet-stream 8.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2023-07-05 14:24:36 Re: logicalrep_message_type throws an error
Previous Message Euler Taveira 2023-07-05 14:01:08 Re: Allow specifying a dbname in pg_basebackup connection string