Have psql's \d+ print reloptions. Extracted from Euler Taveira de Oliveira's
reloptions patch for autovacuum and revised by me. Note that there doesn't seem to be a way to display an index's reloptions.
This commit is contained in:
parent
adac22bf8a
commit
1eec10a2de
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.188 2008/11/09 21:24:33 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.189 2008/12/19 14:39:58 alvherre Exp $
|
||||||
*/
|
*/
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
|
||||||
@ -846,6 +846,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
bool hastriggers;
|
bool hastriggers;
|
||||||
bool hasoids;
|
bool hasoids;
|
||||||
Oid tablespace;
|
Oid tablespace;
|
||||||
|
char *reloptions;
|
||||||
} tableinfo;
|
} tableinfo;
|
||||||
bool show_modifiers = false;
|
bool show_modifiers = false;
|
||||||
bool retval;
|
bool retval;
|
||||||
@ -862,9 +863,12 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
/* Get general table info */
|
/* Get general table info */
|
||||||
printfPQExpBuffer(&buf,
|
printfPQExpBuffer(&buf,
|
||||||
"SELECT relchecks, relkind, relhasindex, relhasrules, %s, "
|
"SELECT relchecks, relkind, relhasindex, relhasrules, %s, "
|
||||||
"relhasoids%s\n"
|
"relhasoids"
|
||||||
|
"%s%s\n"
|
||||||
"FROM pg_catalog.pg_class WHERE oid = '%s'",
|
"FROM pg_catalog.pg_class WHERE oid = '%s'",
|
||||||
(pset.sversion >= 80400 ? "relhastriggers" : "reltriggers <> 0"),
|
(pset.sversion >= 80400 ? "relhastriggers" : "reltriggers <> 0"),
|
||||||
|
(pset.sversion >= 80200 && verbose ?
|
||||||
|
", pg_catalog.array_to_string(reloptions, E', ')" : ",''"),
|
||||||
(pset.sversion >= 80000 ? ", reltablespace" : ""),
|
(pset.sversion >= 80000 ? ", reltablespace" : ""),
|
||||||
oid);
|
oid);
|
||||||
res = PSQLexec(buf.data, false);
|
res = PSQLexec(buf.data, false);
|
||||||
@ -886,8 +890,10 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 3), "t") == 0;
|
tableinfo.hasrules = strcmp(PQgetvalue(res, 0, 3), "t") == 0;
|
||||||
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 ?
|
||||||
|
strdup(PQgetvalue(res, 0, 6)) : 0;
|
||||||
tableinfo.tablespace = (pset.sversion >= 80000) ?
|
tableinfo.tablespace = (pset.sversion >= 80000) ?
|
||||||
atooid(PQgetvalue(res, 0, 6)) : 0;
|
atooid(PQgetvalue(res, 0, 7)) : 0;
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
res = NULL;
|
res = NULL;
|
||||||
|
|
||||||
@ -1586,6 +1592,19 @@ 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 */
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
add_tablespace_footer(&cont, tableinfo.relkind, tableinfo.tablespace,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user