8
8
*
9
9
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
10
10
*
11
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.219 2009/07/03 18:56:50 petere Exp $
11
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.220 2009/07/06 17:01:42 petere Exp $
12
12
*/
13
13
#include "postgres_fe.h"
14
14
@@ -1163,6 +1163,8 @@ describeOneTableDetails(const char *schemaname,
1163
1163
"\n FROM pg_catalog.pg_attrdef d"
1164
1164
"\n WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),"
1165
1165
"\n a.attnotnull, a.attnum" );
1166
+ if (tableinfo .relkind == 'i' )
1167
+ appendPQExpBuffer (& buf , ", pg_get_indexdef(i.indexrelid,a.attnum, TRUE) AS indexdef" );
1166
1168
if (verbose )
1167
1169
appendPQExpBuffer (& buf , ", a.attstorage, pg_catalog.col_description(a.attrelid, a.attnum)" );
1168
1170
appendPQExpBuffer (& buf , "\nFROM pg_catalog.pg_attribute a" );
@@ -1232,6 +1234,9 @@ describeOneTableDetails(const char *schemaname,
1232
1234
if (tableinfo .relkind == 'S' )
1233
1235
headers [cols ++ ] = gettext_noop ("Value" );
1234
1236
1237
+ if (tableinfo .relkind == 'i' )
1238
+ headers [cols ++ ] = gettext_noop ("Definition" );
1239
+
1235
1240
if (verbose )
1236
1241
{
1237
1242
headers [cols ++ ] = gettext_noop ("Storage" );
@@ -1297,10 +1302,15 @@ describeOneTableDetails(const char *schemaname,
1297
1302
if (tableinfo .relkind == 'S' )
1298
1303
printTableAddCell (& cont , seq_values [i ], false);
1299
1304
1305
+ /* Expression for index */
1306
+ if (tableinfo .relkind == 'i' )
1307
+ printTableAddCell (& cont , PQgetvalue (res , i , 5 ), false);
1308
+
1300
1309
/* Storage and Description */
1301
1310
if (verbose )
1302
1311
{
1303
- char * storage = PQgetvalue (res , i , 5 );
1312
+ int fnum = (tableinfo .relkind == 'i' ? 6 : 5 );
1313
+ char * storage = PQgetvalue (res , i , fnum );
1304
1314
1305
1315
/* these strings are literal in our syntax, so not translated. */
1306
1316
printTableAddCell (& cont , (storage [0 ] == 'p' ? "plain" :
@@ -1309,7 +1319,7 @@ describeOneTableDetails(const char *schemaname,
1309
1319
(storage [0 ] == 'e' ? "external" :
1310
1320
"???" )))),
1311
1321
false);
1312
- printTableAddCell (& cont , PQgetvalue (res , i , 6 ), false);
1322
+ printTableAddCell (& cont , PQgetvalue (res , i , fnum + 1 ), false);
1313
1323
}
1314
1324
}
1315
1325
0 commit comments