7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.72 1997/06/06 22:05:23 scrappy Exp $
10
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.73 1997/06/11 01:03:38 scrappy Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -81,7 +81,7 @@ static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream);
81
81
static void
82
82
handleCopyIn (PGresult * res , const bool mustprompt ,
83
83
FILE * copystream );
84
- static int tableList (PsqlSettings * ps , bool deep_tablelist , char table_index_both );
84
+ static int tableList (PsqlSettings * ps , bool deep_tablelist , char info_type );
85
85
static int tableDesc (PsqlSettings * ps , char * table );
86
86
static int rightsList (PsqlSettings * ps );
87
87
static void prompt_for_password (char * username , char * password );
@@ -160,6 +160,7 @@ slashUsage(PsqlSettings * ps)
160
160
fprintf (stderr , " \\copy table {from | to} <fname>\n" );
161
161
fprintf (stderr , " \\d [<table>] -- list tables and indicies in database or columns in <table>, * for all\n" );
162
162
fprintf (stderr , " \\di -- list only indicies in database\n" );
163
+ fprintf (stderr , " \\ds -- list only sequences in database\n" );
163
164
fprintf (stderr , " \\dt -- list only tables in database\n" );
164
165
fprintf (stderr , " \\e [<fname>] -- edit the current query buffer or <fname>, \\E execute too\n" );
165
166
fprintf (stderr , " \\f [<sep>] -- change field separater (currently '%s')\n" , ps -> opt .fieldSep );
@@ -228,7 +229,7 @@ listAllDbs(PsqlSettings * ps)
228
229
*
229
230
*/
230
231
int
231
- tableList (PsqlSettings * ps , bool deep_tablelist , char table_index_both )
232
+ tableList (PsqlSettings * ps , bool deep_tablelist , char info_type )
232
233
{
233
234
char listbuf [256 ];
234
235
int nColumns ;
@@ -241,13 +242,15 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
241
242
listbuf [0 ] = '\0' ;
242
243
strcat (listbuf , "SELECT usename, relname, relkind, relhasrules" );
243
244
strcat (listbuf , " FROM pg_class, pg_user " );
244
- switch (table_index_both ) {
245
+ switch (info_type ) {
245
246
case 't' : strcat (listbuf , "WHERE ( relkind = 'r') " );
246
247
break ;
247
248
case 'i' : strcat (listbuf , "WHERE ( relkind = 'i') " );
248
249
break ;
250
+ case 'S' : strcat (listbuf , "WHERE ( relkind = 'S') " );
251
+ break ;
249
252
case 'b' :
250
- default : strcat (listbuf , "WHERE ( relkind = 'r' OR relkind = 'i') " );
253
+ default : strcat (listbuf , "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S' ) " );
251
254
break ;
252
255
}
253
256
strcat (listbuf , " and relname !~ '^pg_'" );
@@ -300,7 +303,10 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
300
303
if (strcmp (rk , "r" ) == 0 )
301
304
printf ("%-8.8s |" , (rr [0 ] == 't' ) ? "view?" : "table" );
302
305
else
306
+ if (strcmp (rk , "i" ) == 0 )
303
307
printf ("%-8.8s |" , "index" );
308
+ else
309
+ printf ("%-8.8s |" , "sequence" );
304
310
printf ("\n" );
305
311
}
306
312
printf (" +------------------+----------------------------------+----------+\n" );
@@ -310,13 +316,15 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
310
316
311
317
} else {
312
318
PQclear (res ); /* PURIFY */
313
- switch (table_index_both ) {
319
+ switch (info_type ) {
314
320
case 't' : fprintf (stderr , "Couldn't find any tables!\n" );
315
321
break ;
316
322
case 'i' : fprintf (stderr , "Couldn't find any indicies!\n" );
317
323
break ;
324
+ case 'S' : fprintf (stderr , "Couldn't find any sequences!\n" );
325
+ break ;
318
326
case 'b' :
319
- default : fprintf (stderr , "Couldn't find any tables or indicies!\n" );
327
+ default : fprintf (stderr , "Couldn't find any tables, sequences or indicies!\n" );
320
328
break ;
321
329
}
322
330
return (-1 );
@@ -1176,7 +1184,9 @@ HandleSlashCmds(PsqlSettings * settings,
1176
1184
tableList (settings , 0 , 't' );
1177
1185
} else if (strncmp (cmd , "di" , 2 ) == 0 ) { /* only indicies */
1178
1186
tableList (settings , 0 , 'i' );
1179
- } else if (!optarg ) { /* show tables and indicies */
1187
+ } else if (strncmp (cmd , "ds" , 2 ) == 0 ) { /* only sequences */
1188
+ tableList (settings , 0 , 'S' );
1189
+ } else if (!optarg ) { /* show tables, sequences and indicies */
1180
1190
tableList (settings , 0 , 'b' );
1181
1191
} else if (strcmp (optarg , "*" ) == 0 ) { /* show everything */
1182
1192
tableList (settings , 0 , 'b' );
0 commit comments