mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Make psql's \d+ show reloptions for all relkinds.
Formerly it would only show them for relkinds 'r' and 'f' (plain tables and foreign tables). However, as of 9.2, views can also have reloptions, namely security_barrier. The relkind restriction seems pointless and not at all future-proof, so just print reloptions whenever there are any. In passing, make some cosmetic improvements to the code that pulls the "tableinfo" fields out of the PGresult. Noted and patched by Dean Rasheed, with adjustment for all relkinds by me.
This commit is contained in:
@ -1237,13 +1237,14 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
|
tableinfo.hastriggers = strcmp(PQgetvalue(res, 0, 4), "t") == 0;
|
||||||
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
|
tableinfo.hasoids = strcmp(PQgetvalue(res, 0, 5), "t") == 0;
|
||||||
tableinfo.reloptions = (pset.sversion >= 80200) ?
|
tableinfo.reloptions = (pset.sversion >= 80200) ?
|
||||||
strdup(PQgetvalue(res, 0, 6)) : 0;
|
strdup(PQgetvalue(res, 0, 6)) : NULL;
|
||||||
tableinfo.tablespace = (pset.sversion >= 80000) ?
|
tableinfo.tablespace = (pset.sversion >= 80000) ?
|
||||||
atooid(PQgetvalue(res, 0, 7)) : 0;
|
atooid(PQgetvalue(res, 0, 7)) : 0;
|
||||||
tableinfo.reloftype = (pset.sversion >= 90000 && strcmp(PQgetvalue(res, 0, 8), "") != 0) ?
|
tableinfo.reloftype = (pset.sversion >= 90000 &&
|
||||||
strdup(PQgetvalue(res, 0, 8)) : 0;
|
strcmp(PQgetvalue(res, 0, 8), "") != 0) ?
|
||||||
tableinfo.relpersistence = (pset.sversion >= 90100 && strcmp(PQgetvalue(res, 0, 9), "") != 0) ?
|
strdup(PQgetvalue(res, 0, 8)) : NULL;
|
||||||
PQgetvalue(res, 0, 9)[0] : 0;
|
tableinfo.relpersistence = (pset.sversion >= 90100) ?
|
||||||
|
*(PQgetvalue(res, 0, 9)) : 0;
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
res = NULL;
|
res = NULL;
|
||||||
|
|
||||||
@ -2224,7 +2225,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printTableAddFooter(&cont, buf.data);
|
printTableAddFooter(&cont, buf.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OIDs and options */
|
/* OIDs, if verbose */
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
const char *s = _("Has OIDs");
|
const char *s = _("Has OIDs");
|
||||||
@ -2232,24 +2233,22 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
printfPQExpBuffer(&buf, "%s: %s", s,
|
printfPQExpBuffer(&buf, "%s: %s", s,
|
||||||
(tableinfo.hasoids ? _("yes") : _("no")));
|
(tableinfo.hasoids ? _("yes") : _("no")));
|
||||||
printTableAddFooter(&cont, buf.data);
|
printTableAddFooter(&cont, buf.data);
|
||||||
|
}
|
||||||
|
|
||||||
/* print reloptions */
|
/* Tablespace info */
|
||||||
if (pset.sversion >= 80200)
|
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
||||||
{
|
true);
|
||||||
if (tableinfo.reloptions && tableinfo.reloptions[0] != '\0')
|
}
|
||||||
|
|
||||||
|
/* reloptions, if verbose */
|
||||||
|
if (verbose &&
|
||||||
|
tableinfo.reloptions && tableinfo.reloptions[0] != '\0')
|
||||||
{
|
{
|
||||||
const char *t = _("Options");
|
const char *t = _("Options");
|
||||||
|
|
||||||
printfPQExpBuffer(&buf, "%s: %s", t,
|
printfPQExpBuffer(&buf, "%s: %s", t, tableinfo.reloptions);
|
||||||
tableinfo.reloptions);
|
|
||||||
printTableAddFooter(&cont, buf.data);
|
printTableAddFooter(&cont, buf.data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
printTable(&cont, pset.queryFout, pset.logfile);
|
printTable(&cont, pset.queryFout, pset.logfile);
|
||||||
printTableCleanup(&cont);
|
printTableCleanup(&cont);
|
||||||
|
Reference in New Issue
Block a user