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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: turon(dot)david(at)seznam(dot)cz, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16743: psql doesn't show whole expression in stored column
Date: 2020-11-25 15:03:53
Message-ID: 426714.1606316633@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
> On 2020-11-24 16:46, 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 we should get rid of the truncating. Otherwise, there is no way
> to actually get the full information, is there? (Other than pg_dump or
> manual catalog queries.)

That'd be okay with me. It's always seemed a little odd that we do that
for attrdefs but not anything else.

A bit of checking with git blame says that the habit came in with
the very first version of describe.c, in

commit a45195a191eec367a4f305bb71ab541d17a3b9f9
Author: Bruce Momjian <bruce(at)momjian(dot)us>
Date: Thu Nov 4 21:56:02 1999 +0000

Major psql overhaul by Peter Eisentraut.

which has

+ /* Info */
+ cells[i*cols + 2] = xmalloc(128 + 128); /* I'm cutting off the default string at 128 */
+ cells[i*cols + 2][0] = '\0';
+ if (strcmp(PQgetvalue(res, i, 4), "t") == 0)
+ strcat(cells[i*cols + 2], "not null");
+ if (strcmp(PQgetvalue(res, i, 5), "t") == 0) {
+ /* handle "default" here */
+ strcpy(descbuf, "SELECT substring(d.adsrc for 128) FROM pg_attrdef d, pg_class c\n"
+ "WHERE c.relname = '");

So that looks very much like the truncation was an expedient thing
to do to work with a fixed-size result buffer, rather than something
that was chosen to improve the user experience.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-11-25 16:15:39 Re: BUG #16743: psql doesn't show whole expression in stored column
Previous Message James Coleman 2020-11-25 14:57:37 Re: segfault with incremental sort