aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-04-06 04:05:17 +0000
committerBruce Momjian <bruce@momjian.us>2004-04-06 04:05:17 +0000
commit5e9f4d26bce4082033dfc5c3c84e0011e7714f1d (patch)
treef0527fe2ea9d0502b879929eb47b24b4a53d1175
parentd8fe99d98c4ede4ff6ecc7d702c902c536d8b5f3 (diff)
downloadpostgresql-5e9f4d26bce4082033dfc5c3c84e0011e7714f1d.tar.gz
postgresql-5e9f4d26bce4082033dfc5c3c84e0011e7714f1d.zip
Add CLUSTER tag to psql \d display.
-rw-r--r--src/bin/psql/describe.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 3efb5d16db8..f37296a2cb6 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.95 2004/03/22 03:38:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.96 2004/04/06 04:05:17 momjian Exp $
*/
#include "postgres_fe.h"
#include "describe.h"
@@ -831,7 +831,7 @@ describeOneTableDetails(const char *schemaname,
PGresult *result;
printfPQExpBuffer(&buf,
- "SELECT i.indisunique, i.indisprimary, a.amname, c2.relname,\n"
+ "SELECT i.indisunique, i.indisprimary, i.indisclustered, a.amname, c2.relname,\n"
" pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
"FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n"
"WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
@@ -850,9 +850,10 @@ describeOneTableDetails(const char *schemaname,
{
char *indisunique = PQgetvalue(result, 0, 0);
char *indisprimary = PQgetvalue(result, 0, 1);
- char *indamname = PQgetvalue(result, 0, 2);
- char *indtable = PQgetvalue(result, 0, 3);
- char *indpred = PQgetvalue(result, 0, 4);
+ char *indisclustered = PQgetvalue(result, 0, 2);
+ char *indamname = PQgetvalue(result, 0, 3);
+ char *indtable = PQgetvalue(result, 0, 4);
+ char *indpred = PQgetvalue(result, 0, 5);
if (strcmp(indisprimary, "t") == 0)
printfPQExpBuffer(&tmpbuf, _("PRIMARY KEY, "));
@@ -869,6 +870,9 @@ describeOneTableDetails(const char *schemaname,
if (strlen(indpred))
appendPQExpBuffer(&tmpbuf, _(", predicate (%s)"), indpred);
+ if (strcmp(indisclustered, "t") == 0)
+ appendPQExpBuffer(&tmpbuf, _(", CLUSTER"));
+
footers = pg_malloc_zero(2 * sizeof(*footers));
footers[0] = pg_strdup(tmpbuf.data);
footers[1] = NULL;
@@ -948,7 +952,7 @@ describeOneTableDetails(const char *schemaname,
if (tableinfo.hasindex)
{
printfPQExpBuffer(&buf,
- "SELECT c2.relname, i.indisprimary, i.indisunique, "
+ "SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, "
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)\n"
"FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
"WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
@@ -1080,15 +1084,17 @@ describeOneTableDetails(const char *schemaname,
(strcmp(PQgetvalue(result1, i, 2), "t") == 0
? _(" UNIQUE,")
: ""));
-
/* Everything after "USING" is echoed verbatim */
- indexdef = PQgetvalue(result1, i, 3);
+ indexdef = PQgetvalue(result1, i, 4);
usingpos = strstr(indexdef, " USING ");
if (usingpos)
indexdef = usingpos + 7;
appendPQExpBuffer(&buf, " %s", indexdef);
+ if (strcmp(PQgetvalue(result1, i, 3), "t") == 0)
+ appendPQExpBuffer(&buf, _(" CLUSTER"));
+
footers[count_footers++] = pg_strdup(buf.data);
}
}