33 *
44 * Copyright (c) 2000-2003, PostgreSQL Global Development Group
55 *
6- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.95 2004/03/22 03:38:24 momjian Exp $
6+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.96 2004/04/06 04:05:17 momjian Exp $
77 */
88#include "postgres_fe.h"
99#include "describe.h"
@@ -831,7 +831,7 @@ describeOneTableDetails(const char *schemaname,
831831PGresult * result ;
832832
833833printfPQExpBuffer (& buf ,
834- "SELECT i.indisunique, i.indisprimary, a.amname, c2.relname,\n"
834+ "SELECT i.indisunique, i.indisprimary,i.indisclustered, a.amname, c2.relname,\n"
835835" pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
836836"FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n"
837837"WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
@@ -850,9 +850,10 @@ describeOneTableDetails(const char *schemaname,
850850{
851851char * indisunique = PQgetvalue (result ,0 ,0 );
852852char * indisprimary = PQgetvalue (result ,0 ,1 );
853- char * indamname = PQgetvalue (result ,0 ,2 );
854- char * indtable = PQgetvalue (result ,0 ,3 );
855- char * indpred = PQgetvalue (result ,0 ,4 );
853+ char * indisclustered = PQgetvalue (result ,0 ,2 );
854+ char * indamname = PQgetvalue (result ,0 ,3 );
855+ char * indtable = PQgetvalue (result ,0 ,4 );
856+ char * indpred = PQgetvalue (result ,0 ,5 );
856857
857858if (strcmp (indisprimary ,"t" )== 0 )
858859printfPQExpBuffer (& tmpbuf ,_ ("PRIMARY KEY, " ));
@@ -869,6 +870,9 @@ describeOneTableDetails(const char *schemaname,
869870if (strlen (indpred ))
870871appendPQExpBuffer (& tmpbuf ,_ (", predicate (%s)" ),indpred );
871872
873+ if (strcmp (indisclustered ,"t" )== 0 )
874+ appendPQExpBuffer (& tmpbuf ,_ (", CLUSTER" ));
875+
872876footers = pg_malloc_zero (2 * sizeof (* footers ));
873877footers [0 ]= pg_strdup (tmpbuf .data );
874878footers [1 ]= NULL ;
@@ -948,7 +952,7 @@ describeOneTableDetails(const char *schemaname,
948952if (tableinfo .hasindex )
949953{
950954printfPQExpBuffer (& buf ,
951- "SELECT c2.relname, i.indisprimary, i.indisunique, "
955+ "SELECT c2.relname, i.indisprimary, i.indisunique,i.indisclustered, "
952956"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)\n"
953957"FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
954958"WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
@@ -1080,15 +1084,17 @@ describeOneTableDetails(const char *schemaname,
10801084 (strcmp (PQgetvalue (result1 ,i ,2 ),"t" )== 0
10811085 ?_ (" UNIQUE," )
10821086 :"" ));
1083-
10841087/* Everything after "USING" is echoed verbatim */
1085- indexdef = PQgetvalue (result1 ,i ,3 );
1088+ indexdef = PQgetvalue (result1 ,i ,4 );
10861089usingpos = strstr (indexdef ," USING " );
10871090if (usingpos )
10881091indexdef = usingpos + 7 ;
10891092
10901093appendPQExpBuffer (& buf ," %s" ,indexdef );
10911094
1095+ if (strcmp (PQgetvalue (result1 ,i ,3 ),"t" )== 0 )
1096+ appendPQExpBuffer (& buf ,_ (" CLUSTER" ));
1097+
10921098footers [count_footers ++ ]= pg_strdup (buf .data );
10931099}
10941100}