Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit735bf0b

Browse files
committed
From: Igor <igor@sba.miami.edu>
Subject: [PATCHES] sequences display in psqlWell, I am away at Progress training (not Postgres!!) and desided to dothis patch during a break. This will allow listing of sequences inaddition to listing of tables and indicies:\d would should indicies, tables, and sequences\ds would show sequences only.
1 parent65c4a52 commit735bf0b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

‎src/bin/psql/psql.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -81,7 +81,7 @@ static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream);
8181
staticvoid
8282
handleCopyIn(PGresult*res,constboolmustprompt,
8383
FILE*copystream);
84-
staticinttableList(PsqlSettings*ps,booldeep_tablelist,chartable_index_both);
84+
staticinttableList(PsqlSettings*ps,booldeep_tablelist,charinfo_type);
8585
staticinttableDesc(PsqlSettings*ps,char*table);
8686
staticintrightsList(PsqlSettings*ps);
8787
staticvoidprompt_for_password(char*username,char*password);
@@ -160,6 +160,7 @@ slashUsage(PsqlSettings * ps)
160160
fprintf(stderr," \\copy table {from | to} <fname>\n");
161161
fprintf(stderr," \\d [<table>] -- list tables and indicies in database or columns in <table>, * for all\n");
162162
fprintf(stderr," \\di -- list only indicies in database\n");
163+
fprintf(stderr," \\ds -- list only sequences in database\n");
163164
fprintf(stderr," \\dt -- list only tables in database\n");
164165
fprintf(stderr," \\e [<fname>] -- edit the current query buffer or <fname>, \\E execute too\n");
165166
fprintf(stderr," \\f [<sep>] -- change field separater (currently '%s')\n",ps->opt.fieldSep);
@@ -228,7 +229,7 @@ listAllDbs(PsqlSettings * ps)
228229
*
229230
*/
230231
int
231-
tableList(PsqlSettings*ps,booldeep_tablelist,chartable_index_both)
232+
tableList(PsqlSettings*ps,booldeep_tablelist,charinfo_type)
232233
{
233234
charlistbuf[256];
234235
intnColumns;
@@ -241,13 +242,15 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
241242
listbuf[0]='\0';
242243
strcat(listbuf,"SELECT usename, relname, relkind, relhasrules");
243244
strcat(listbuf," FROM pg_class, pg_user ");
244-
switch (table_index_both) {
245+
switch (info_type) {
245246
case't':strcat(listbuf,"WHERE ( relkind = 'r') ");
246247
break;
247248
case'i':strcat(listbuf,"WHERE ( relkind = 'i') ");
248249
break;
250+
case'S':strcat(listbuf,"WHERE ( relkind = 'S') ");
251+
break;
249252
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') ");
251254
break;
252255
}
253256
strcat(listbuf," and relname !~ '^pg_'");
@@ -300,7 +303,10 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
300303
if (strcmp(rk,"r")==0)
301304
printf("%-8.8s |", (rr[0]=='t') ?"view?" :"table");
302305
else
306+
if (strcmp(rk,"i")==0)
303307
printf("%-8.8s |","index");
308+
else
309+
printf("%-8.8s |","sequence");
304310
printf("\n");
305311
}
306312
printf(" +------------------+----------------------------------+----------+\n");
@@ -310,13 +316,15 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char table_index_both)
310316

311317
}else {
312318
PQclear(res);/* PURIFY */
313-
switch (table_index_both) {
319+
switch (info_type) {
314320
case't':fprintf(stderr,"Couldn't find any tables!\n");
315321
break;
316322
case'i':fprintf(stderr,"Couldn't find any indicies!\n");
317323
break;
324+
case'S':fprintf(stderr,"Couldn't find any sequences!\n");
325+
break;
318326
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");
320328
break;
321329
}
322330
return (-1);
@@ -1176,7 +1184,9 @@ HandleSlashCmds(PsqlSettings * settings,
11761184
tableList(settings,0,'t');
11771185
}elseif (strncmp(cmd,"di",2)==0) {/* only indicies */
11781186
tableList(settings,0,'i');
1179-
}elseif (!optarg) {/* show tables and indicies */
1187+
}elseif (strncmp(cmd,"ds",2)==0) {/* only sequences */
1188+
tableList(settings,0,'S');
1189+
}elseif (!optarg) {/* show tables, sequences and indicies */
11801190
tableList(settings,0,'b');
11811191
}elseif (strcmp(optarg,"*")==0) {/* show everything */
11821192
tableList(settings,0,'b');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp