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,
421421char * rr ;
422422PGresult * res ;
423423int usePipe = 0 ;
424+ bool haveIndexes = false;
424425char * pagerenv ;
425426FILE * fout ;
426427
@@ -440,27 +441,39 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
440441listbuf [0 ]= '\0' ;
441442strcat (listbuf ,"SELECT usename, relname, relkind, relhasrules " );
442443strcat (listbuf ,"FROM pg_class, pg_user " );
444+ strcat (listbuf ,"WHERE usesysid = relowner " );
443445switch (info_type )
444446{
445447case 't' :
446- strcat (listbuf ,"WHERE ( relkind = 'r') " );
448+ strcat (listbuf ,"and ( relkind = 'r') " );
447449break ;
448450case 'i' :
449- strcat (listbuf ,"WHERE ( relkind = 'i') " );
451+ strcat (listbuf ,"and ( relkind = 'i') " );
452+ haveIndexes = true;
450453break ;
451454case 'S' :
452- strcat (listbuf ,"WHERE ( relkind = 'S') " );
455+ strcat (listbuf ,"and ( relkind = 'S') " );
453456break ;
454457case 'b' :
455458default :
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;
457461break ;
458462}
459463if (!system_tables )
460- strcat (listbuf ," and relname !~ '^pg_'" );
464+ strcat (listbuf ,"and relname !~ '^pg_' " );
461465else
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+
464477strcat (listbuf ," ORDER BY relname " );
465478if (!(res = PSQLexec (pset ,listbuf )))
466479return -1 ;
@@ -603,10 +616,10 @@ rightsList(PsqlSettings *pset)
603616
604617listbuf [0 ]= '\0' ;
605618strcat (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') " );
608622strcat (listbuf ," and relname !~ '^pg_'" );
609- strcat (listbuf ," and usesysid = relowner" );
610623strcat (listbuf ," ORDER BY relname " );
611624if (!(res = PSQLexec (pset ,listbuf )))
612625return -1 ;