Thread: proposal - psql - possibility to redirect only tabular output

proposal - psql - possibility to redirect only tabular output

From
Pavel Stehule
Date:
Hi

Now, the content of redirect output has two parts

1. tabular output
2. cmd tags

There is a problem with command tags, because it is specific kind of information and can be nice if can be redirected to stdout every time like \h output. There can be new psql variable like REDIRECTED_OUTPUT with possibilities (all, tabular)

What do you think about this?

Pavel

Re: proposal - psql - possibility to redirect only tabular output

From
Pavel Stehule
Date:


so 11. 4. 2020 v 8:54 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:
Hi

Now, the content of redirect output has two parts

1. tabular output
2. cmd tags

There is a problem with command tags, because it is specific kind of information and can be nice if can be redirected to stdout every time like \h output. There can be new psql variable like REDIRECTED_OUTPUT with possibilities (all, tabular)

What do you think about this?

or different method - set target of status row - with result (default) or stdout (terminal)

patch assigned

When I pin status rows just to stdout, then redirected output contains only query results

Regards

Pavel


Pavel
Attachment

Re: proposal - psql - possibility to redirect only tabular output

From
Erik Rijkers
Date:
On 2020-04-11 10:21, Pavel Stehule wrote:
> so 11. 4. 2020 v 8:54 odesílatel Pavel Stehule 
> <pavel.stehule@gmail.com>
> napsal:

> [psql-status-target.patch]

Hi Pavel,

This looks interesting, and I built an instance with the patch to try 
it, but I can't figure out how to use it.

Can you perhaps give a few or even just one example?

thanks!

Erik Rijkers



Re: proposal - psql - possibility to redirect only tabular output

From
Pavel Stehule
Date:


so 11. 4. 2020 v 11:04 odesílatel Erik Rijkers <er@xs4all.nl> napsal:
On 2020-04-11 10:21, Pavel Stehule wrote:
> so 11. 4. 2020 v 8:54 odesílatel Pavel Stehule
> <pavel.stehule@gmail.com>
> napsal:

> [psql-status-target.patch]

Hi Pavel,

This looks interesting, and I built an instance with the patch to try
it, but I can't figure out how to use it.

Can you perhaps give a few or even just one example?

Main motivation for this patch is working with psql for writing and editing queries, and browsing result in second terminal with pspg or any other similar tool (tail, ...). The advantage of this setup is possibility to see sql and query result together. I use terminal multiplicator (Tilix), but it can be used without it.

So example with pspg (should be some fresh release)

1. create fifo used for communication - mkfifo ~/pipe

2. run in one terminal pspg - pspg -f ~/pipe --hold-stream=2

3. run psql in other terminal

psql
\o ~/pipe
CREATE TABLE foo(a int);
INSERT INTO foo VALUES(10);
-- in default case, the status row "CREATE", "INSERT" is redirected to "browser terminal" and it doesn't look well (and it is not user friendly).

with patched version you can

\set STATUS_TARGET stdout
-- after this setting, the status row will be displayed in psql terminal

Regards

Pavel





thanks!

Erik Rijkers

Re: proposal - psql - possibility to redirect only tabular output

From
Artur Zakirov
Date:
Hello,

On Sat, Apr 11, 2020 at 6:20 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Main motivation for this patch is working with psql for writing and editing queries, and browsing result in second
terminalwith pspg or any other similar tool (tail, ...). The advantage of this setup is possibility to see sql and
queryresult together. I use terminal multiplicator (Tilix), but it can be used without it. 
>
> So example with pspg (should be some fresh release)
>
> 1. create fifo used for communication - mkfifo ~/pipe
>
> 2. run in one terminal pspg - pspg -f ~/pipe --hold-stream=2
>
> 3. run psql in other terminal

The patch looks interesting. As far as I understand the purpose of the
patch is to hide status messages from result output.
So maybe it would be enough just to hide status messages at all. There
is the QUIET variable for that. The main advantage of this variable is
that it hides a status of "\lo_" commands, for example, as well as a
status of utility commands. So the QUIET variable covers more use
cases already.

--
Artur



Re: proposal - psql - possibility to redirect only tabular output

From
Pavel Stehule
Date:


pá 3. 7. 2020 v 12:16 odesílatel Artur Zakirov <zaartur@gmail.com> napsal:
Hello,

On Sat, Apr 11, 2020 at 6:20 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Main motivation for this patch is working with psql for writing and editing queries, and browsing result in second terminal with pspg or any other similar tool (tail, ...). The advantage of this setup is possibility to see sql and query result together. I use terminal multiplicator (Tilix), but it can be used without it.
>
> So example with pspg (should be some fresh release)
>
> 1. create fifo used for communication - mkfifo ~/pipe
>
> 2. run in one terminal pspg - pspg -f ~/pipe --hold-stream=2
>
> 3. run psql in other terminal

The patch looks interesting. As far as I understand the purpose of the
patch is to hide status messages from result output.
So maybe it would be enough just to hide status messages at all. There
is the QUIET variable for that. The main advantage of this variable is
that it hides a status of "\lo_" commands, for example, as well as a
status of utility commands. So the QUIET variable covers more use
cases already.

The quiet mode isn't exactly what I want (it can be used as a workaround - and now, pspg https://github.com/okbob/pspg knows a format of status line and can work it).

I would like to see a status row. For me it is a visual check so some statements like INSERT or UPDATE was done successfully. But I would not send it to the terminal with an active tabular pager.

Pavel




--
Artur