proposal - psql - use pager for \watch command

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule


út 23. 3. 2021 v 0:35 odesílatel Thomas Munro <[hidden email]> napsal:
On Sun, Mar 21, 2021 at 11:43 PM Pavel Stehule <[hidden email]> wrote:
> so 20. 3. 2021 v 23:45 odesílatel Thomas Munro <[hidden email]> napsal:
>> Thoughts?  I put my changes into a separate patch for clarity, but
>> they need some more tidying up.
>
> yes, your solution is much better.

Hmm, there was a problem with it though: it blocked ^C while running
the query, which is bad.  I fixed that.   I did some polishing of the
code and some editing on the documentation and comments.  I disabled
the feature completely on Windows, because it seems unlikely that
we'll be able to know if it even works, in this cycle.

-       output = PageOutput(158, pager ? &(pset.popt.topt) : NULL);
+       output = PageOutput(160, pager ? &(pset.popt.topt) : NULL);

What is that change for?

This is correct - this is the number of printed rows - it is used for decisions about using a pager for help. There are two new rows, and the number is correctly +2

Pavel


Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule
In reply to this post by Thomas Munro-5


po 22. 3. 2021 v 13:13 odesílatel Thomas Munro <[hidden email]> napsal:
On Mon, Mar 22, 2021 at 5:10 PM Pavel Stehule <[hidden email]> wrote:
> probably there will not be an issue inside ncurses - the most complex part of get_event is polling of input sources - tty and some other. The pspg should not to stop there on tty reading.

The problem is that Apple's /dev/tty device is defective, and doesn't
work in poll().  It always returns immediately with revents=POLLNVAL,
but pspg assumes that data is ready and tries to read the keyboard and
then blocks until I press a key.  This seems to fix it:

+#ifndef __APPLE__
+               /* macOS can't use poll() on /dev/tty */
                state.tty = fopen("/dev/tty", "r+");
+#endif
                if (!state.tty)
                        state.tty = fopen(ttyname(fileno(stdout)), "r");

A minor problem is that on macOS, _GNU_SOURCE doesn't seem to imply
NCURSES_WIDECHAR, so I suspect Unicode will be broken unless you
manually add -DNCURSES_WIDECHAR=1, though I didn't check.

For record, this issue is fixed in pspg 4.5.0.

Regards

Pavel

Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Thomas Munro-5
Here's a rebase, due to a conflict with 3a513067 "psql: Show all query
results by default" which moved a few things around making it harder
to use the pager for the right scope.  Lacking time, I came up with
this change to PSQLexecWatch():

+       if (printQueryFout)
+       {
+               restoreQueryFout = pset.queryFout;
+               pset.queryFout = printQueryFout;
+       }
+
        SetCancelConn(pset.db);
        res = SendQueryAndProcessResults(query, &elapsed_msec, true);
        ResetCancelConn();

        fflush(pset.queryFout);

+       if (restoreQueryFout)
+               pset.queryFout = restoreQueryFout;
+

If someone has a tidier way to factor this, I'm keen to hear it.  I'd
like to push this today.

v5-0001-Add-PSQL_WATCH_PAGER-for-psql-s-watch-command.patch (16K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule
Hi

čt 8. 4. 2021 v 1:38 odesílatel Thomas Munro <[hidden email]> napsal:
Here's a rebase, due to a conflict with 3a513067 "psql: Show all query
results by default" which moved a few things around making it harder
to use the pager for the right scope.  Lacking time, I came up with
this change to PSQLexecWatch():

+       if (printQueryFout)
+       {
+               restoreQueryFout = pset.queryFout;
+               pset.queryFout = printQueryFout;
+       }
+
        SetCancelConn(pset.db);
        res = SendQueryAndProcessResults(query, &elapsed_msec, true);
        ResetCancelConn();

        fflush(pset.queryFout);

+       if (restoreQueryFout)
+               pset.queryFout = restoreQueryFout;
+

If someone has a tidier way to factor this, I'm keen to hear it.  I'd
like to push this today.

here is an rebase of Thomas's implementation

Regards

Pavel


v6-0001-Add-PSQL_WATCH_PAGER-for-psql-s-watch-command.patch (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Thomas Munro-5
On Wed, Apr 21, 2021 at 6:33 PM Pavel Stehule <[hidden email]> wrote:
> here is an rebase of Thomas's implementation

Thanks.  I finished up not committing that one for 14 because I wasn't
sure about the way to rebase it on top of 3a513067 (now reverted);
that "restore" stuff seemed a bit weird.  Let's try again in v15 CF1!


Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule


st 21. 4. 2021 v 8:49 odesílatel Thomas Munro <[hidden email]> napsal:
On Wed, Apr 21, 2021 at 6:33 PM Pavel Stehule <[hidden email]> wrote:
> here is an rebase of Thomas's implementation

Thanks.  I finished up not committing that one for 14 because I wasn't
sure about the way to rebase it on top of 3a513067 (now reverted);
that "restore" stuff seemed a bit weird.  Let's try again in v15 CF1!

Understand. Thank you

Pavel

Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule
Hi

st 21. 4. 2021 v 8:52 odesílatel Pavel Stehule <[hidden email]> napsal:


st 21. 4. 2021 v 8:49 odesílatel Thomas Munro <[hidden email]> napsal:
On Wed, Apr 21, 2021 at 6:33 PM Pavel Stehule <[hidden email]> wrote:
> here is an rebase of Thomas's implementation

Thanks.  I finished up not committing that one for 14 because I wasn't
sure about the way to rebase it on top of 3a513067 (now reverted);
that "restore" stuff seemed a bit weird.  Let's try again in v15 CF1!

Understand. Thank you

rebase

Regards

Pavel


Pavel


v7-0001-Add-PSQL_WATCH_PAGER-for-psql-s-watch-command.patch (14K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: proposal - psql - use pager for \watch command

Pavel Stehule


st 12. 5. 2021 v 12:25 odesílatel Pavel Stehule <[hidden email]> napsal:
Hi

st 21. 4. 2021 v 8:52 odesílatel Pavel Stehule <[hidden email]> napsal:


st 21. 4. 2021 v 8:49 odesílatel Thomas Munro <[hidden email]> napsal:
On Wed, Apr 21, 2021 at 6:33 PM Pavel Stehule <[hidden email]> wrote:
> here is an rebase of Thomas's implementation

Thanks.  I finished up not committing that one for 14 because I wasn't
sure about the way to rebase it on top of 3a513067 (now reverted);
that "restore" stuff seemed a bit weird.  Let's try again in v15 CF1!

Understand. Thank you

rebase

looks so with your patch psql doesn't work on ms


Regards

Pavel


Regards

Pavel


Pavel

12