aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-04-08 15:52:49 -0400
committerRobert Haas <rhaas@postgresql.org>2011-04-08 15:52:49 -0400
commitcba9cd419270a9b7f442877e21685ac0de5730b3 (patch)
tree24a53b614e61abecf4e0d635c717151bb958daca
parent0bd155cbf2543cdead70b6e6390e9260035e1468 (diff)
downloadpostgresql-cba9cd419270a9b7f442877e21685ac0de5730b3.tar.gz
postgresql-cba9cd419270a9b7f442877e21685ac0de5730b3.zip
Make psql use pg_table_size instead of pg_relation_size on 9.0+ servers.
Per discussion, pg_table_size() is a more helpful number than pg_relation_size(). Bernd Helmle, reviewed by Susanne Ebrecht and me.
-rw-r--r--src/bin/psql/describe.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index a89c9385c04..09a40093d1f 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2522,14 +2522,25 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
",\n c2.relname as \"%s\"",
gettext_noop("Table"));
- if (verbose && pset.sversion >= 80100)
- appendPQExpBuffer(&buf,
- ",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
- gettext_noop("Size"));
if (verbose)
+ {
+ /*
+ * As of PostgreSQL 9.0, use pg_table_size() to show a more acurate size
+ * of a table, including FSM, VM and TOAST tables.
+ */
+ if (pset.sversion >= 90000)
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) as \"%s\"",
+ gettext_noop("Size"));
+ else if (pset.sversion >= 80100)
+ appendPQExpBuffer(&buf,
+ ",\n pg_catalog.pg_size_pretty(pg_catalog.pg_relation_size(c.oid)) as \"%s\"",
+ gettext_noop("Size"));
+
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(c.oid, 'pg_class') as \"%s\"",
gettext_noop("Description"));
+ }
appendPQExpBuffer(&buf,
"\nFROM pg_catalog.pg_class c"