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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16743: psql doesn't show whole expression in stored column
Дата
Msg-id 426714.1606316633@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #16743: psql doesn't show whole expression in stored column  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Ответы Re: BUG #16743: psql doesn't show whole expression in stored column  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Peter Eisentraut <peter.eisentraut@enterprisedb.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@momjian.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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: James Coleman
Дата:
Сообщение: Re: segfault with incremental sort
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16743: psql doesn't show whole expression in stored column