7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -421,6 +421,7 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
421
421
char * rr ;
422
422
PGresult * res ;
423
423
int usePipe = 0 ;
424
+ bool haveIndexes = false;
424
425
char * pagerenv ;
425
426
FILE * fout ;
426
427
@@ -440,27 +441,39 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
440
441
listbuf [0 ] = '\0' ;
441
442
strcat (listbuf , "SELECT usename, relname, relkind, relhasrules " );
442
443
strcat (listbuf , "FROM pg_class, pg_user " );
444
+ strcat (listbuf , "WHERE usesysid = relowner " );
443
445
switch (info_type )
444
446
{
445
447
case 't' :
446
- strcat (listbuf , "WHERE ( relkind = 'r') " );
448
+ strcat (listbuf , "and ( relkind = 'r') " );
447
449
break ;
448
450
case 'i' :
449
- strcat (listbuf , "WHERE ( relkind = 'i') " );
451
+ strcat (listbuf , "and ( relkind = 'i') " );
452
+ haveIndexes = true;
450
453
break ;
451
454
case 'S' :
452
- strcat (listbuf , "WHERE ( relkind = 'S') " );
455
+ strcat (listbuf , "and ( relkind = 'S') " );
453
456
break ;
454
457
case 'b' :
455
458
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;
457
461
break ;
458
462
}
459
463
if (!system_tables )
460
- strcat (listbuf , " and relname !~ '^pg_'" );
464
+ strcat (listbuf , "and relname !~ '^pg_' " );
461
465
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
+
464
477
strcat (listbuf , " ORDER BY relname " );
465
478
if (!(res = PSQLexec (pset , listbuf )))
466
479
return -1 ;
@@ -603,10 +616,10 @@ rightsList(PsqlSettings *pset)
603
616
604
617
listbuf [0 ] = '\0' ;
605
618
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') " );
608
622
strcat (listbuf , " and relname !~ '^pg_'" );
609
- strcat (listbuf , " and usesysid = relowner" );
610
623
strcat (listbuf , " ORDER BY relname " );
611
624
if (!(res = PSQLexec (pset , listbuf )))
612
625
return -1 ;
0 commit comments