Hi

Ășt 13. 7. 2021 v 19:50 odesĂ­latel Tom Lane <t...@sss.pgh.pa.us> napsal:

> Thomas Munro <thomas.mu...@gmail.com> writes:
> > Pushed, after retesting on macOS (with the fixed pspg that has by now
> > arrived in MacPorts), FreeBSD and Linux.  Thanks!
>
> After playing with this along the way to fixing the sigwait issues,
> I have a gripe/suggestion.  If I hit control-C while the thing
> is waiting between queries, eg
>
> regression=# select now() \watch
> Tue Jul 13 13:44:44 2021 (every 2s)
>
>               now
> -------------------------------
>  2021-07-13 13:44:44.396565-04
> (1 row)
>
> Tue Jul 13 13:44:46 2021 (every 2s)
>
>               now
> -------------------------------
>  2021-07-13 13:44:46.396572-04
> (1 row)
>
> ^Cregression=#
>
> then as you can see I get nothing but the "^C" echo before the next
> psql prompt.  The problem with this is that now libreadline is
> misinformed about the cursor position, messing up any editing I
> might try to do on the next line of input.  So I think it would
> be a good idea to have some explicit final output when the \watch
> command terminates, along the line of
>
> ...
> Tue Jul 13 13:44:46 2021 (every 2s)
>
>               now
> -------------------------------
>  2021-07-13 13:44:46.396572-04
> (1 row)
>
> ^C\watch cancelled
> regression=#
>
> This strikes me as a usability improvement even without the
> readline-confusion angle.
>

here is an patch

Regards

Pavel



>                         regards, tom lane
>
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index b51d28780b..21da8296bd 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -5169,6 +5169,11 @@ do_watch(PQExpBuffer query_buf, double sleep)
 		pclose(pagerpipe);
 		restore_sigpipe_trap();
 	}
+	else
+	{
+		fprintf(stdout, "watch cancelled\n");
+		fflush(stdout);
+	}
 
 #ifdef HAVE_POSIX_DECL_SIGWAIT
 	/* Disable the interval timer. */

Reply via email to