Skip to content

Commit ebcadba

Browse files
committed
Show statistics target for columns in \d+ on a table
1 parent 6f81a1f commit ebcadba

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/bin/psql/describe.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ describeOneTableDetails(const char *schemaname,
12801280
if (verbose)
12811281
{
12821282
appendPQExpBuffer(&buf, ",\n a.attstorage");
1283+
appendPQExpBuffer(&buf, ",\n CASE WHEN a.attstattarget=-1 THEN NULL ELSE a.attstattarget END AS attstattarget");
12831284
/*
12841285
* In 9.0+, we have column comments for: relations, views, composite
12851286
* types, and foreign tables (c.f. CommentObject() in comment.c).
@@ -1374,6 +1375,8 @@ describeOneTableDetails(const char *schemaname,
13741375
if (verbose)
13751376
{
13761377
headers[cols++] = gettext_noop("Storage");
1378+
if (tableinfo.relkind == 'r')
1379+
headers[cols++] = gettext_noop("Stats target");
13771380
/* Column comments, if the relkind supports this feature. */
13781381
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v' ||
13791382
tableinfo.relkind == 'c' || tableinfo.relkind == 'f')
@@ -1473,10 +1476,18 @@ describeOneTableDetails(const char *schemaname,
14731476
(storage[0] == 'e' ? "external" :
14741477
"???")))),
14751478
false, false);
1479+
1480+
/* Statistics target, if the relkind supports this feature */
1481+
if (tableinfo.relkind == 'r')
1482+
{
1483+
printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1),
1484+
false, false);
1485+
}
1486+
14761487
/* Column comments, if the relkind supports this feature. */
14771488
if (tableinfo.relkind == 'r' || tableinfo.relkind == 'v' ||
14781489
tableinfo.relkind == 'c' || tableinfo.relkind == 'f')
1479-
printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 1),
1490+
printTableAddCell(&cont, PQgetvalue(res, i, firstvcol + 2),
14801491
false, false);
14811492
}
14821493
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy