Обсуждение: patch: psql - enforce constant width of last column

Поиск
Список
Период
Сортировка

patch: psql - enforce constant width of last column

От
Pavel Stehule
Дата:
Hi

When I played with vertical cursor support I got badly displayed last columns when border was not 2. Only when border is 2, then psql displays last column with same width for each row.

I think so we can force column width alignment for any border styles today (for alignment and wrapping styles) or as minimum this behave can be optional.

I wrote a patch with pset option "final_spaces", but I don't see a reason why we trim rows today.

Regards

Pavel
Вложения

Re: patch: psql - enforce constant width of last column

От
Ahsan Hadi
Дата:
Hi Pavel,

I have been trying to reproduce the case of badly displaying last columns of a query result-set. I played around with the legal values for psql border variable but not able to find a case where last columns are badly displayed. Can you please share an example that I can use to reproduce this problem. I will try out your patch once I am able to reproduce the problem.

Thanks,

-- Ahsan


On Mon, Sep 9, 2019 at 2:32 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

When I played with vertical cursor support I got badly displayed last columns when border was not 2. Only when border is 2, then psql displays last column with same width for each row.

I think so we can force column width alignment for any border styles today (for alignment and wrapping styles) or as minimum this behave can be optional.

I wrote a patch with pset option "final_spaces", but I don't see a reason why we trim rows today.

Regards

Pavel

Re: patch: psql - enforce constant width of last column

От
Pavel Stehule
Дата:


út 17. 9. 2019 v 17:06 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
Hi Pavel,

I have been trying to reproduce the case of badly displaying last columns of a query result-set. I played around with the legal values for psql border variable but not able to find a case where last columns are badly displayed. Can you please share an example that I can use to reproduce this problem. I will try out your patch once I am able to reproduce the problem.

you need to use pspg, and vertical cursor.

vertical cursor should be active

\pset border 1
\pset linestyle ascii
\pset pager always

select * from generate_series(1,3);

Regards

Pavel


Thanks,

-- Ahsan


On Mon, Sep 9, 2019 at 2:32 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

When I played with vertical cursor support I got badly displayed last columns when border was not 2. Only when border is 2, then psql displays last column with same width for each row.

I think so we can force column width alignment for any border styles today (for alignment and wrapping styles) or as minimum this behave can be optional.

I wrote a patch with pset option "final_spaces", but I don't see a reason why we trim rows today.

Regards

Pavel
Вложения

Re: patch: psql - enforce constant width of last column

От
Ahsan Hadi
Дата:


On Tue, Sep 17, 2019 at 8:16 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:


út 17. 9. 2019 v 17:06 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
Hi Pavel,

I have been trying to reproduce the case of badly displaying last columns of a query result-set. I played around with the legal values for psql border variable but not able to find a case where last columns are badly displayed. Can you please share an example that I can use to reproduce this problem. I will try out your patch once I am able to reproduce the problem.

you need to use pspg, and vertical cursor.

vertical cursor should be active

okay thanks for the info. I don't think it was possible to figure this out by reading the initial post. I will check it out.

does this patch have any value for psql without pspg? 


\pset border 1
\pset linestyle ascii
\pset pager always

select * from generate_series(1,3);

Regards

Pavel


Thanks,

-- Ahsan


On Mon, Sep 9, 2019 at 2:32 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

When I played with vertical cursor support I got badly displayed last columns when border was not 2. Only when border is 2, then psql displays last column with same width for each row.

I think so we can force column width alignment for any border styles today (for alignment and wrapping styles) or as minimum this behave can be optional.

I wrote a patch with pset option "final_spaces", but I don't see a reason why we trim rows today.

Regards

Pavel

Re: patch: psql - enforce constant width of last column

От
Pavel Stehule
Дата:


st 18. 9. 2019 v 12:52 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:


On Tue, Sep 17, 2019 at 8:16 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:


út 17. 9. 2019 v 17:06 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
Hi Pavel,

I have been trying to reproduce the case of badly displaying last columns of a query result-set. I played around with the legal values for psql border variable but not able to find a case where last columns are badly displayed. Can you please share an example that I can use to reproduce this problem. I will try out your patch once I am able to reproduce the problem.

you need to use pspg, and vertical cursor.

vertical cursor should be active

okay thanks for the info. I don't think it was possible to figure this out by reading the initial post. I will check it out.

does this patch have any value for psql without pspg? 

The benefit of this patch is just for pspg users today.

Pavel




\pset border 1
\pset linestyle ascii
\pset pager always

select * from generate_series(1,3);

Regards

Pavel


Thanks,

-- Ahsan


On Mon, Sep 9, 2019 at 2:32 PM Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

When I played with vertical cursor support I got badly displayed last columns when border was not 2. Only when border is 2, then psql displays last column with same width for each row.

I think so we can force column width alignment for any border styles today (for alignment and wrapping styles) or as minimum this behave can be optional.

I wrote a patch with pset option "final_spaces", but I don't see a reason why we trim rows today.

Regards

Pavel

Re: patch: psql - enforce constant width of last column

От
Bruce Momjian
Дата:
On Tue, Sep 17, 2019 at 05:15:42PM +0200, Pavel Stehule wrote:
> 
> 
> út 17. 9. 2019 v 17:06 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
> 
>     Hi Pavel,
> 
>     I have been trying to reproduce the case of badly displaying last columns
>     of a query result-set. I played around with the legal values for psql
>     border variable but not able to find a case where last columns are badly
>     displayed. Can you please share an example that I can use to reproduce this
>     problem. I will try out your patch once I am able to reproduce the problem.
> 
> 
> you need to use pspg, and vertical cursor.
> 
> https://github.com/okbob/pspg
> vertical cursor should be active
> 
> \pset border 1
> \pset linestyle ascii
> \pset pager always
> 
> select * from generate_series(1,3);

I was able to reproduce the failure, but with a little more work:

    $ export PSQL_PAGER='pspg --vertical-cursor'
    $ psql test
    \pset border 1
    \pset linestyle ascii
    \pset pager always
    select * from generate_series(1,3);

Line '1' has highlighted trailing space.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +



Re: patch: psql - enforce constant width of last column

От
Tom Lane
Дата:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> st 18. 9. 2019 v 12:52 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
>> does this patch have any value for psql without pspg?

> The benefit of this patch is just for pspg users today.

TBH, I think we should just reject this patch.  It makes psql's
table-printing behavior even more complicated than it was before.
And I don't see how pspg gets any benefit --- you'll still have
to deal with the old code, for an indefinite time into the future.

Moreover, *other* programs that pay close attention to the output
format will be forced to deal with the possibility that this flag
has been turned on, which typically they wouldn't even have a way
to find out.  So I think you're basically trying to export your
problems onto everyone else.

            regards, tom lane



Re: patch: psql - enforce constant width of last column

От
Pavel Stehule
Дата:
Hi

po 4. 11. 2019 v 21:55 odesílatel Tom Lane <tgl@sss.pgh.pa.us> napsal:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> st 18. 9. 2019 v 12:52 odesílatel Ahsan Hadi <ahsan.hadi@gmail.com> napsal:
>> does this patch have any value for psql without pspg?

> The benefit of this patch is just for pspg users today.

TBH, I think we should just reject this patch.  It makes psql's
table-printing behavior even more complicated than it was before.
And I don't see how pspg gets any benefit --- you'll still have
to deal with the old code, for an indefinite time into the future.

I don't think so it increase printing rules too much. A default value "auto" doesn't any change against current state, "always" ensure same line width of any row.

The problem, that this patch try to solve, is different width of rows - although the result is aligned.

Personally I think so current behave is not correct. Correct solution should be set "finalspaces true" every time - for aligned output. But I don't know a motivation of authors and as solution with minimal impacts I wrote a possibility to set (it's not default) to finalspace to "always" as fix of some possible visual artefact (although these artefacts are almost time invisible).

The patch maybe looks not trivial (although it is trivial), but it is due I try to reduce possible impact on any other application to zero.
 

Moreover, *other* programs that pay close attention to the output
format will be forced to deal with the possibility that this flag
has been turned on, which typically they wouldn't even have a way
to find out.  So I think you're basically trying to export your
problems onto everyone else.

I try to fix this issue where this issue coming. For this patch is important to get a agreement (or not) if this problem is a issue that should be fixed.

I think so in aligned mode all rows should to have same width.

On second hand, really I don't know why the last space is not printed, and if some applications had a problem with it. I have not any idea. Current code where last spaces are not printed is little bit complex than if the align was really complete.

Sure, "the issue of last invisible space" is not big issue (it's triviality) - I really think so it should be fixed on psql side, but if there will not be a agreement, I can fix it on pspg side (although it will not be elegant - because I have to print chars that doesn't exists).

Is here any man who remember this implementation, who can say, why the code is implemented how it is implemented?

Regards

Pavel



                        regards, tom lane