Re: BUG #16743: psql doesn't show whole expression in stored column

From: David Turoň <Turon(dot)David(at)seznam(dot)cz>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-bugs(at)lists(dot)postgresql(dot)org>, "Peter Eisentraut" <peter(dot)eisentraut(at)enterprisedb(dot)com>, "Bruce Momjian" <bruce(at)momjian(dot)us>
Subject: Re: BUG #16743: psql doesn't show whole expression in stored column
Date: 2020-11-25 07:46:32
Message-ID: EWs.5rNI.4xkN1D}JwHK.1VlWlO@seznam.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Yes ist little bit confusing with truncate only part and leave stored. Maybe
substring to first 125 and append at least '...' or some switch in psql '\
pset cut_row_length on' or something similar.

postgres(at)pgdist:test=# SELECT a.attname,

  pg_catalog.format_type(a.atttypid, a.atttypmod),

  (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid, true) for
125)||'...'

   FROM pg_catalog.pg_attrdef d

   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),

  a.attnotnull,

  (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t

   WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <>
t.typcollation) AS attcollation,

  a.attidentity,

  a.attgenerated

FROM pg_catalog.pg_attribute a

WHERE a.attrelid = '896567' AND a.attnum > 0 AND NOT a.attisdropped

ORDER BY a.attnum;

-[ RECORD 5 ]+--------------------------------------------------------------
-------------------------------------------------------------------

attname      | ts_vector

format_type  | tsvector

?column?     | ((setweight(to_tsvector('simple'::regconfig, COALESCE(a, ''::
text)), 'A'::"char") || setweight(to_tsvector('simple'::regconfi...

attnotnull   | f

attcollation | <NULL>

attidentity  | 

attgenerated | s

I am using pager, so for me fixed row/column lenght isn't priority.  

regards, David T.

---------- Původní e-mail ----------
Od: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Komu: Bruce Momjian <bruce(at)momjian(dot)us>
Datum: 24. 11. 2020 17:26:07
Předmět: Re: BUG #16743: psql doesn't show whole expression in stored column

"Bruce Momjian <bruce(at)momjian(dot)us> writes:
> On Tue, Nov 24, 2020 at 10:46:57AM -0500, Tom Lane wrote:
>> Maybe we should decide that completeness is more important than keeping
>> the line to some arbitrary width. But it's operating as designed.

> I think I am fine with the current behavior.

It's less great in the context of a GENERATED column. As things stand,
the psql-side code wraps the truncated result into some more syntax:

else if (generated[0] == ATTRIBUTE_GENERATED_STORED)
default_str = psprintf("generated always as (%s) stored", PQgetvalue(res, i,
attrdef_col));
else
/* (note: above we cut off the 'default' string at 128) */
default_str = PQgetvalue(res, i, attrdef_col);

which seems distinctly more confusing than just truncating the result.
So maybe there's justification here for revisiting that ancient decision.

One could also imagine not appending ") stored" if the attrdef value
appears to have been truncated --- although encoding-conversion effects
would make it hard to tell that for sure. Perhaps we'd be better off
to move the truncation logic to the psql side?

Another thing here, which is undeniably a bug, is that that psprintf
result is promptly leaked.

regards, tom lane
"

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2020-11-25 08:38:03 Re: BUG #16743: psql doesn't show whole expression in stored column
Previous Message Peter Smith 2020-11-25 05:49:51 Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop