diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index c2bcc5abe08b8e64b2566af8713afb11d90412aa..12fcf4d04dda75a2f6ee88ef8d5994cb1281337a 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1236,13 +1236,14 @@ describeOneTableDetails(const char *schemaname, tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0; tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0; tableinfo.reloptions = (pset.sversion >= 80200) ? - strdup(PQgetvalue(res, 0, 6)) : 0; + strdup(PQgetvalue(res, 0, 6)) : NULL; tableinfo.tablespace = (pset.sversion >= 80000) ? atooid(PQgetvalue(res, 0, 7)) : 0; - tableinfo.reloftype = (pset.sversion >= 90000 && strcmp(PQgetvalue(res, 0, 8), "") != 0) ? - strdup(PQgetvalue(res, 0, 8)) : 0; - tableinfo.relpersistence = (pset.sversion >= 90100 && strcmp(PQgetvalue(res, 0, 9), "") != 0) ? - PQgetvalue(res, 0, 9)[0] : 0; + tableinfo.reloftype = (pset.sversion >= 90000 && + strcmp(PQgetvalue(res, 0, 8), "") != 0) ? + strdup(PQgetvalue(res, 0, 8)) : NULL; + tableinfo.relpersistence = (pset.sversion >= 90100) ? + *(PQgetvalue(res, 0, 9)) : 0; PQclear(res); res = NULL; @@ -2223,7 +2224,7 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } - /* OIDs and options */ + /* OIDs, if verbose */ if (verbose) { const char *s = _("Has OIDs"); @@ -2231,25 +2232,23 @@ describeOneTableDetails(const char *schemaname, printfPQExpBuffer(&buf, "%s: %s", s, (tableinfo.hasoids ? _("yes") : _("no"))); printTableAddFooter(&cont, buf.data); - - /* print reloptions */ - if (pset.sversion >= 80200) - { - if (tableinfo.reloptions && tableinfo.reloptions[0] != '\0') - { - const char *t = _("Options"); - - printfPQExpBuffer(&buf, "%s: %s", t, - tableinfo.reloptions); - printTableAddFooter(&cont, buf.data); - } - } } + /* Tablespace info */ add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace, true); } + /* reloptions, if verbose */ + if (verbose && + tableinfo.reloptions && tableinfo.reloptions[0] != '\0') + { + const char *t = _("Options"); + + printfPQExpBuffer(&buf, "%s: %s", t, tableinfo.reloptions); + printTableAddFooter(&cont, buf.data); + } + printTable(&cont, pset.queryFout, pset.logfile); printTableCleanup(&cont);