Re: very long record lines in expanded psql output - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: very long record lines in expanded psql output
Date
Msg-id CAFj8pRATS90qiF-RVe0z3JhE7ak3hb4rFdW3T1Tfsvo5+wj1QQ@mail.gmail.com
Whole thread Raw
In response to Re: very long record lines in expanded psql output  (Platon Pronko <platon7pronko@gmail.com>)
Responses Re: very long record lines in expanded psql output  (Platon Pronko <platon7pronko@gmail.com>)
List pgsql-hackers


čt 5. 8. 2021 v 15:30 odesílatel Platon Pronko <platon7pronko@gmail.com> napsal:
Hi!

> a) with line cursor

Tried in different configurations, seems that line cursor works fine.

> b) format detection - I try to detect the header line - and I expect this
> line has the most length of all lines. I use a line with the same length as
> the column's type info (data, border).

I looked at pspg source, and here's what I found (please correct me if some/all
of my assumptions are wrong):

1. Input handling and format detection happens in table.c readfile().

2. There's some variables in DataDesc - maxx and maxbytes - that store the
longest line seen so far. But they are re-updated on each new row, so the fact
that header is shorter shouldn't affect them.

3. Expanded header detection is handled by is_expanded_header function. It has
ei_minx and ei_maxx return pointers, but when it is used from readfile() these
pointers are set to NULL in both cases - so header length is simply ignored.

The problem can be in translate_headline in bad desc->headline_size


> Did you test the wrapped format? It is working
>
> \pset format wrapped
> \x
> select  * from pg_class;

There's no difference in outputs in wrapped format, so pspg behavior is also unaffected.

By the way, it seems that pspg recommends setting \pset border 2 anyway, so in vast
majority of cases there should be no possibility of difference at all - proposed patch
doesn't change output for \pset border 2 (because there's no sane way of making it
look okay in presence of long fields anyway).

Although pspg prefers border 2, it is working for all configurations now.

I think your proposal is not good, because it is breaking consistency and if people want similar output, then they can use a wrapped format.

Regards

Pavel


 

Best regards,
Platon Pronko

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: .ready and .done files considered harmful
Next
From: Andrew Dunstan
Date:
Subject: Re: Commitfest overflow