Thread: Unused pg_class columns

Unused pg_class columns

From
"Christopher Kings-Lynne"
Date:
Are these columns in pg_class:

relukeys | relfkeys | relhaspkey

unused or what?

Chris



Re: Unused pg_class columns

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Are these columns in pg_class:
> relukeys | relfkeys | relhaspkey
> unused or what?

They may be unused by the backend, but that doesn't mean that
applications don't look at them.  I find references to relhaspkey
in pgaccess, for example.
        regards, tom lane


Re: Unused pg_class columns

From
Bruce Momjian
Date:
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > Are these columns in pg_class:
> > relukeys | relfkeys | relhaspkey
> > unused or what?
> 
> They may be unused by the backend, but that doesn't mean that
> applications don't look at them.  I find references to relhaspkey
> in pgaccess, for example.

So pgaccess just reads it but doesn't write it, right?  Seems we should
mark this in the code so we can delete them some day, and perhaps remove
the refrence to it in pgaccess.

--  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,
Pennsylvania19026
 


Re: Unused pg_class columns

From
Bruce Momjian
Date:
I have marked these columns as unused in pg_class.h.

> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > Are these columns in pg_class:
> > relukeys | relfkeys | relhaspkey
> > unused or what?
> 
> They may be unused by the backend, but that doesn't mean that
> applications don't look at them.  I find references to relhaspkey
> in pgaccess, for example.
> 
>             regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 

--  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,
Pennsylvania19026
 


Re: Unused pg_class columns

From
Bruce Momjian
Date:
> "Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> > Are these columns in pg_class:
> > relukeys | relfkeys | relhaspkey
> > unused or what?
> 
> They may be unused by the backend, but that doesn't mean that
> applications don't look at them.  I find references to relhaspkey
> in pgaccess, for example.

I removed the reference in pgaccess.  After a few releases of pgaccess
we can remove the column.

--  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,
Pennsylvania19026
 


Re: Unused pg_class columns

From
Bruce Momjian
Date:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I have marked these columns as unused in pg_class.h.
> 
> Keep your hands off 'em!
> 
> There are other purposes for system catalogs besides the internal
> convenience of the backend, you know.  "Unused at the moment by the
> backend" does not mean "removable" --- you have no way to know what
> user code you may break by removing such info.

I didn't remove them.  I marked them as unused, like other columns
already marked as unused in the file.

For example:
   int2        relrefs;        /* # of references to this rel (not used) */

was already marked as "(not used)".

--  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,
Pennsylvania19026
 


Re: Unused pg_class columns

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I removed the reference in pgaccess.  After a few releases of pgaccess
> we can remove the column.

Put it back please.  Or have you become the unilateral arbiter of what
functions pgaccess has?
        regards, tom lane


Re: Unused pg_class columns

From
Bruce Momjian
Date:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I removed the reference in pgaccess.  After a few releases of pgaccess
> > we can remove the column.
> 
> Put it back please.  Or have you become the unilateral arbiter of what
> functions pgaccess has?

Pgaccess is referencing system columns that are never set.   What
possible value could they be except to confuse users, and this column
was visible in pgaccess.

--  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,
Pennsylvania19026
 


Re: Unused pg_class columns

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I have marked these columns as unused in pg_class.h.

Keep your hands off 'em!

There are other purposes for system catalogs besides the internal
convenience of the backend, you know.  "Unused at the moment by the
backend" does not mean "removable" --- you have no way to know what
user code you may break by removing such info.
        regards, tom lane


Re: Unused pg_class columns

From
Tom Lane
Date:
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.

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.
        regards, tom lane


Re: Unused pg_class columns

From
Bruce Momjian
Date:
> 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 ----

Re: Unused pg_class columns

From
Peter Eisentraut
Date:
Tom Lane writes:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I removed the reference in pgaccess.  After a few releases of pgaccess
> > we can remove the column.
>
> Put it back please.  Or have you become the unilateral arbiter of what
> functions pgaccess has?

If pgaccess only reads the column and the backend doesn't use it, it seems
reasonable to remove the reference.  It looks like it was a mistake to
begin with.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter