Re: Unused pg_class columns - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Unused pg_class columns
Date
Msg-id 200105301542.f4UFgOP03816@candle.pha.pa.us
Whole thread Raw
In response to Re: Unused pg_class columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Pgaccess is referencing system columns that are never set.
>
> I wasn't aware that our standard procedure upon finding a bug was to rip
> out the feature, rather than fixing the bug ... this could make life a
> *lot* simpler.

Attached is a patch of all my pgaccess changes this morning.  If someone
wants to code the hasprimary test, feel free.  You can look at psql to
see new code that does tests for primary keys.  It was recently
committed to CVS.

If people would prefer me to comment out the primary key display rather
than remove it, I can do that.

> If relhaspkey isn't set by table creation, then let's set it.  Easy
> enough, and it seems like a clearly useful column.  As for the other
> columns at issue, those are not ancient history: they were added in
> release 6.4, by Vadim according to the CVS logs.  Perhaps you should ask
> him what they are intended for, rather than assuming that they are fair
> game for removal.

I only marked as "not used", not as "remove me".  Seems clear enough.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
? pgaccess
Index: lib/tables.tcl
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/pgaccess/lib/tables.tcl,v
retrieving revision 1.7
retrieving revision 1.9
diff -c -r1.7 -r1.9
*** lib/tables.tcl    2001/02/26 05:15:48    1.7
--- lib/tables.tcl    2001/05/30 15:37:38    1.9
***************
*** 44,50 ****
      set PgAcVar(tblinfo,isunique) {}
      set PgAcVar(tblinfo,isclustered) {}
      set PgAcVar(tblinfo,indexfields) {}
!     wpg_select $CurrentDB "select
attnum,attname,typname,attlen,attnotnull,atttypmod,usename,usesysid,pg_class.oid,relpages,reltuples,relhaspkey,relhasrules,relacl
frompg_class,pg_user,pg_attribute,pg_type where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and
(pg_class.oid=pg_attribute.attrelid)and (pg_class.relowner=pg_user.usesysid) and (pg_attribute.atttypid=pg_type.oid)
orderby attnum" rec { 
          set fsize $rec(attlen)
          set fsize1 $rec(atttypmod)
          set ftype $rec(typname)
--- 44,50 ----
      set PgAcVar(tblinfo,isunique) {}
      set PgAcVar(tblinfo,isclustered) {}
      set PgAcVar(tblinfo,indexfields) {}
!     wpg_select $CurrentDB "select
attnum,attname,typname,attlen,attnotnull,atttypmod,usename,usesysid,pg_class.oid,relpages,reltuples,relhasrules,relacl
frompg_class,pg_user,pg_attribute,pg_type where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and
(pg_class.oid=pg_attribute.attrelid)and (pg_class.relowner=pg_user.usesysid) and (pg_attribute.atttypid=pg_type.oid)
orderby attnum" rec { 
          set fsize $rec(attlen)
          set fsize1 $rec(atttypmod)
          set ftype $rec(typname)
***************
*** 68,78 ****
          set PgAcVar(tblinfo,numtuples) $rec(reltuples)
          set PgAcVar(tblinfo,numpages) $rec(relpages)
          set PgAcVar(tblinfo,permissions) $rec(relacl)
-         if {$rec(relhaspkey)=="t"} {
-             set PgAcVar(tblinfo,hasprimarykey) [intlmsg Yes]
-         } else {
-             set PgAcVar(tblinfo,hasprimarykey) [intlmsg No]
-         }
          if {$rec(relhasrules)=="t"} {
              set PgAcVar(tblinfo,hasrules) [intlmsg Yes]
          } else {
--- 68,73 ----
***************
*** 80,86 ****
          }
      }
      set PgAcVar(tblinfo,indexlist) {}
!     wpg_select $CurrentDB "select oid,indexrelid from pg_index where (pg_class.relname='$PgAcVar(tblinfo,tablename)')
and(pg_class.oid=pg_index.indrelid)" rec { 
          lappend PgAcVar(tblinfo,indexlist) $rec(oid)
          wpg_select $CurrentDB "select relname from pg_class where oid=$rec(indexrelid)" rec1 {
              .pgaw:TableInfo.f2.fl.ilb insert end $rec1(relname)
--- 75,81 ----
          }
      }
      set PgAcVar(tblinfo,indexlist) {}
!     wpg_select $CurrentDB "select pg_index.oid,indexrelid from pg_index, pg_class where
(pg_class.relname='$PgAcVar(tblinfo,tablename)')and (pg_class.oid=pg_index.indrelid)" rec { 
          lappend PgAcVar(tblinfo,indexlist) $rec(oid)
          wpg_select $CurrentDB "select relname from pg_class where oid=$rec(indexrelid)" rec1 {
              .pgaw:TableInfo.f2.fl.ilb insert end $rec1(relname)
***************
*** 1723,1735 ****
          -anchor w -borderwidth 1 \
          -relief sunken -text {} -textvariable PgAcVar(tblinfo,ownerid) \
          -width 200
-     label $base.f0.fi.l9 \
-         -borderwidth 0 \
-         -relief raised -text [intlmsg {Has primary key ?}]
-     label $base.f0.fi.l10 \
-         -anchor w -borderwidth 1 \
-         -relief sunken -text {} \
-         -textvariable PgAcVar(tblinfo,hasprimarykey) -width 200
      label $base.f0.fi.l11 \
          -borderwidth 0 \
          -relief raised -text [intlmsg {Has rules ?}]
--- 1718,1723 ----
***************
*** 1893,1903 ****
      grid $base.f0.fi.l8 \
          -in .pgaw:TableInfo.f0.fi -column 1 -row 3 -columnspan 1 -rowspan 1 -padx 2 \
          -pady 2
-     grid $base.f0.fi.l9 \
-         -in .pgaw:TableInfo.f0.fi -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w
-     grid $base.f0.fi.l10 \
-         -in .pgaw:TableInfo.f0.fi -column 1 -row 4 -columnspan 1 -rowspan 1 -padx 2 \
-         -pady 2
      grid $base.f0.fi.l11 \
          -in .pgaw:TableInfo.f0.fi -column 0 -row 5 -columnspan 1 -rowspan 1 -sticky w
      grid $base.f0.fi.l12 \
--- 1881,1886 ----

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Unused pg_class columns
Next
From: Peter Eisentraut
Date:
Subject: Re: Unused pg_class columns