3
3
*
4
4
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
5
5
*
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 $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "describe.h"
@@ -831,7 +831,7 @@ describeOneTableDetails(const char *schemaname,
831
831
PGresult * result ;
832
832
833
833
printfPQExpBuffer (& 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"
835
835
" pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
836
836
"FROM pg_catalog.pg_index i, pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_am a\n"
837
837
"WHERE i.indexrelid = c.oid AND c.oid = '%s' AND c.relam = a.oid\n"
@@ -850,9 +850,10 @@ describeOneTableDetails(const char *schemaname,
850
850
{
851
851
char * indisunique = PQgetvalue (result , 0 , 0 );
852
852
char * 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 );
856
857
857
858
if (strcmp (indisprimary , "t" ) == 0 )
858
859
printfPQExpBuffer (& tmpbuf , _ ("PRIMARY KEY, " ));
@@ -869,6 +870,9 @@ describeOneTableDetails(const char *schemaname,
869
870
if (strlen (indpred ))
870
871
appendPQExpBuffer (& tmpbuf , _ (", predicate (%s)" ), indpred );
871
872
873
+ if (strcmp (indisclustered , "t" ) == 0 )
874
+ appendPQExpBuffer (& tmpbuf , _ (", CLUSTER" ));
875
+
872
876
footers = pg_malloc_zero (2 * sizeof (* footers ));
873
877
footers [0 ] = pg_strdup (tmpbuf .data );
874
878
footers [1 ] = NULL ;
@@ -948,7 +952,7 @@ describeOneTableDetails(const char *schemaname,
948
952
if (tableinfo .hasindex )
949
953
{
950
954
printfPQExpBuffer (& buf ,
951
- "SELECT c2.relname, i.indisprimary, i.indisunique, "
955
+ "SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, "
952
956
"pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)\n"
953
957
"FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\n"
954
958
"WHERE c.oid = '%s' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\n"
@@ -1080,15 +1084,17 @@ describeOneTableDetails(const char *schemaname,
1080
1084
(strcmp (PQgetvalue (result1 , i , 2 ), "t" ) == 0
1081
1085
? _ (" UNIQUE," )
1082
1086
: "" ));
1083
-
1084
1087
/* Everything after "USING" is echoed verbatim */
1085
- indexdef = PQgetvalue (result1 , i , 3 );
1088
+ indexdef = PQgetvalue (result1 , i , 4 );
1086
1089
usingpos = strstr (indexdef , " USING " );
1087
1090
if (usingpos )
1088
1091
indexdef = usingpos + 7 ;
1089
1092
1090
1093
appendPQExpBuffer (& buf , " %s" , indexdef );
1091
1094
1095
+ if (strcmp (PQgetvalue (result1 , i , 3 ), "t" ) == 0 )
1096
+ appendPQExpBuffer (& buf , _ (" CLUSTER" ));
1097
+
1092
1098
footers [count_footers ++ ] = pg_strdup (buf .data );
1093
1099
}
1094
1100
}
0 commit comments