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

Commit857c079

Browse files
committed
Suppress indexes on large objects from psql's \d listing;
they were confusing because the large object tables themselves are notshown. (Besides, if you've got hundreds or thousands of large objects,you really don't want to see 'em at all.)Also, suppress all indexes from the \z ACL listing, since indexes haveno meaningful protection information.
1 parent8f19603 commit857c079

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

‎src/bin/psql/psql.c

Lines changed: 24 additions & 11 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.181 1999/05/30 15:32:45 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.182 1999/06/04 21:21:13 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -421,6 +421,7 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
421421
char*rr;
422422
PGresult*res;
423423
intusePipe=0;
424+
boolhaveIndexes= false;
424425
char*pagerenv;
425426
FILE*fout;
426427

@@ -440,27 +441,39 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
440441
listbuf[0]='\0';
441442
strcat(listbuf,"SELECT usename, relname, relkind, relhasrules ");
442443
strcat(listbuf,"FROM pg_class, pg_user ");
444+
strcat(listbuf,"WHERE usesysid = relowner ");
443445
switch (info_type)
444446
{
445447
case't':
446-
strcat(listbuf,"WHERE ( relkind = 'r') ");
448+
strcat(listbuf,"and ( relkind = 'r') ");
447449
break;
448450
case'i':
449-
strcat(listbuf,"WHERE ( relkind = 'i') ");
451+
strcat(listbuf,"and ( relkind = 'i') ");
452+
haveIndexes= true;
450453
break;
451454
case'S':
452-
strcat(listbuf,"WHERE ( relkind = 'S') ");
455+
strcat(listbuf,"and ( relkind = 'S') ");
453456
break;
454457
case'b':
455458
default:
456-
strcat(listbuf,"WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
459+
strcat(listbuf,"and ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
460+
haveIndexes= true;
457461
break;
458462
}
459463
if (!system_tables)
460-
strcat(listbuf,"and relname !~ '^pg_'");
464+
strcat(listbuf,"and relname !~ '^pg_'");
461465
else
462-
strcat(listbuf," and relname ~ '^pg_'");
463-
strcat(listbuf," and usesysid = relowner");
466+
strcat(listbuf,"and relname ~ '^pg_' ");
467+
/*
468+
* Large-object relations are automatically ignored because they have
469+
* relkind 'l'. However, we want to ignore their indexes as well.
470+
* The clean way to do that would be to do a join to find out which
471+
* table each index is for. The ugly but fast way is to know that
472+
* large object indexes have names starting with 'xinx'.
473+
*/
474+
if (haveIndexes)
475+
strcat(listbuf,"and (relkind != 'i' OR relname !~ '^xinx') ");
476+
464477
strcat(listbuf," ORDER BY relname ");
465478
if (!(res=PSQLexec(pset,listbuf)))
466479
return-1;
@@ -603,10 +616,10 @@ rightsList(PsqlSettings *pset)
603616

604617
listbuf[0]='\0';
605618
strcat(listbuf,"SELECT relname, relacl ");
606-
strcat(listbuf,"FROM pg_class, pg_user ");
607-
strcat(listbuf,"WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') ");
619+
strcat(listbuf,"FROM pg_class ");
620+
/* Currently, we ignore indexes since they have no meaningful rights */
621+
strcat(listbuf,"WHERE ( relkind = 'r' OR relkind = 'S') ");
608622
strcat(listbuf," and relname !~ '^pg_'");
609-
strcat(listbuf," and usesysid = relowner");
610623
strcat(listbuf," ORDER BY relname ");
611624
if (!(res=PSQLexec(pset,listbuf)))
612625
return-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp