Thread: CLASSOID patch

CLASSOID patch

From
Chris Bitmead
Date:
Attached is a first attempt at implementing the classoid feature. It
works! Can the postgres gurus comment if I've done it right and point
out any problems. A lot of it was guess work so I'm sure it can be
cleaned up some.

--
Chris Bitmead
mailto:chris@bitmead.com? config.log
? config.cache
? config.status
? nohup.out
? GNUmakefile
? src/GNUmakefile
? src/Makefile.global
? src/ID
? src/nohup.out
? src/backend/fmgr.h
? src/backend/parse.h
? src/backend/postgres
? src/backend/global1.bki.source
? src/backend/local1_template1.bki.source
? src/backend/global1.description
? src/backend/local1_template1.description
? src/backend/1
? src/backend/catalog/genbki.sh
? src/backend/catalog/global1.bki.source
? src/backend/catalog/global1.description
? src/backend/catalog/local1_template1.bki.source
? src/backend/catalog/local1_template1.description
? src/backend/parser/y.output
? src/backend/parser/y.output.gz
? src/backend/parser/gram.y.works
? src/backend/parser/gram.y.works.try
? src/backend/parser/y.output.noerror
? src/backend/parser/gram.y.gz
? src/backend/port/Makefile
? src/backend/utils/Gen_fmgrtab.sh
? src/backend/utils/fmgr.h
? src/backend/utils/fmgrstamp-h
? src/bin/initdb/initdb
? src/bin/initlocation/initlocation
? src/bin/ipcclean/ipcclean
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/Makefile
? src/bin/pg_dump/pg_dump
? src/bin/pg_id/pg_id
? src/bin/pg_passwd/pg_passwd
? src/bin/pg_version/Makefile
? src/bin/pg_version/pg_version
? src/bin/pgtclsh/mkMakefile.tcldefs.sh
? src/bin/pgtclsh/mkMakefile.tkdefs.sh
? src/bin/psql/Makefile
? src/bin/psql/psql
? src/bin/scripts/createlang
? src/include/version.h
? src/include/config.h
? src/include/parser/parse.h
? src/include/utils/fmgroids.h
? src/interfaces/Makefile
? src/interfaces/ecpg/lib/Makefile
? src/interfaces/ecpg/lib/libecpg.so.3.1.1
? src/interfaces/ecpg/preproc/Makefile
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/jdbc/postgresql.jar
? src/interfaces/jdbc/example/psql.class
? src/interfaces/jdbc/postgresql/DriverClass.java
? src/interfaces/jdbc/postgresql/DriverClass.class
? src/interfaces/jdbc/postgresql/Connection.class
? src/interfaces/jdbc/postgresql/Field.class
? src/interfaces/jdbc/postgresql/PG_Stream.class
? src/interfaces/jdbc/postgresql/Driver.class
? src/interfaces/jdbc/postgresql/ResultSet.class
? src/interfaces/jdbc/postgresql/fastpath/Fastpath.class
? src/interfaces/jdbc/postgresql/fastpath/FastpathArg.class
? src/interfaces/jdbc/postgresql/geometric/PGbox.class
? src/interfaces/jdbc/postgresql/geometric/PGpoint.class
? src/interfaces/jdbc/postgresql/geometric/PGcircle.class
? src/interfaces/jdbc/postgresql/geometric/PGline.class
? src/interfaces/jdbc/postgresql/geometric/PGlseg.class
? src/interfaces/jdbc/postgresql/geometric/PGpath.class
? src/interfaces/jdbc/postgresql/geometric/PGpolygon.class
? src/interfaces/jdbc/postgresql/jdbc2/ResultSet.class
? src/interfaces/jdbc/postgresql/jdbc2/Connection.class
? src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.class
? src/interfaces/jdbc/postgresql/jdbc2/DatabaseMetaData.class
? src/interfaces/jdbc/postgresql/jdbc2/Statement.class
? src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.class
? src/interfaces/jdbc/postgresql/jdbc2/CallableStatement.class
? src/interfaces/jdbc/postgresql/largeobject/LargeObjectManager.class
? src/interfaces/jdbc/postgresql/largeobject/LargeObject.class
? src/interfaces/jdbc/postgresql/util/PSQLException.class
? src/interfaces/jdbc/postgresql/util/UnixCrypt.class
? src/interfaces/jdbc/postgresql/util/Serialize.class
? src/interfaces/jdbc/postgresql/util/PGobject.class
? src/interfaces/jdbc/postgresql/util/PGtokenizer.class
? src/interfaces/jdbc/postgresql/util/PGmoney.class
? src/interfaces/libpgeasy/Makefile
? src/interfaces/libpgeasy/libpgeasy.so.2.1
? src/interfaces/libpgtcl/Makefile
? src/interfaces/libpgtcl/mkMakefile.tcldefs.sh
? src/interfaces/libpgtcl/mkMakefile.tkdefs.sh
? src/interfaces/libpq/Makefile
? src/interfaces/libpq/libpq.so.2.1
? src/interfaces/libpq++/Makefile
? src/interfaces/libpq++/libpq++.so.3.1
? src/interfaces/odbc/GNUmakefile
? src/interfaces/odbc/Makefile.global
? src/interfaces/perl5/GNUmakefile
? src/interfaces/python/GNUmakefile
? src/pl/Makefile
? src/pl/plperl/GNUmakefile
? src/pl/plpgsql/Makefile
? src/pl/plpgsql/src/Makefile
? src/pl/plpgsql/src/libplpgsql.so.1.0
? src/pl/tcl/mkMakefile.tcldefs.sh
? src/test/regress/GNUmakefile
? src/test/regress/x.x
? src/test/regress/nohup.out
Index: src/backend/access/common/heaptuple.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v
retrieving revision 1.62
diff -c -r1.62 heaptuple.c
*** src/backend/access/common/heaptuple.c    2000/04/12 17:14:36    1.62
--- src/backend/access/common/heaptuple.c    2000/06/24 15:24:46
***************
*** 9,15 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12 17:14:36
momjianExp $ 
   *
   * NOTES
   *      The old interface functions have been converted to macros
--- 9,15 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12 17:14:36 momjian
Exp$ 
   *
   * NOTES
   *      The old interface functions have been converted to macros
***************
*** 169,174 ****
--- 169,175 ----
      else
          switch (attnum)
          {
+             case ClassOidAttributeNumber:
              case SelfItemPointerAttributeNumber:
              case ObjectIdAttributeNumber:
              case MinTransactionIdAttributeNumber:
***************
*** 205,210 ****
--- 206,213 ----

      switch (attno)
      {
+         case ClassOidAttributeNumber:
+             return sizeof f->t_oid;
          case SelfItemPointerAttributeNumber:
              return sizeof f->t_ctid;
          case ObjectIdAttributeNumber:
***************
*** 237,242 ****
--- 240,248 ----

      switch (attno)
      {
+         case ClassOidAttributeNumber:
+             byval = true;
+             break;
          case SelfItemPointerAttributeNumber:
              byval = false;
              break;
***************
*** 275,281 ****
  {
      switch (attnum)
      {
!             case SelfItemPointerAttributeNumber:
              return (Datum) &tup->t_ctid;
          case ObjectIdAttributeNumber:
              return (Datum) (long) tup->t_oid;
--- 281,289 ----
  {
      switch (attnum)
      {
!         case ClassOidAttributeNumber:
!             return (Datum) &tup->t_classoid;
!         case SelfItemPointerAttributeNumber:
              return (Datum) &tup->t_ctid;
          case ObjectIdAttributeNumber:
              return (Datum) (long) tup->t_oid;
Index: src/backend/access/heap/heapam.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/heap/heapam.c,v
retrieving revision 1.71
diff -c -r1.71 heapam.c
*** src/backend/access/heap/heapam.c    2000/06/15 04:09:34    1.71
--- src/backend/access/heap/heapam.c    2000/06/24 15:24:49
***************
*** 235,240 ****
--- 235,242 ----
      int            linesleft;
      ItemPointer tid = (tuple->t_data == NULL) ?
      (ItemPointer) NULL : &(tuple->t_self);
+
+     tuple->relation = relation;

      /* ----------------
       *    increment access statistics
***************
*** 567,572 ****
--- 569,575 ----

      Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);

+
      /* ----------------
       *    increment access statistics
       * ----------------
***************
*** 1030,1035 ****
--- 1033,1039 ----
      ItemPointer tid = &(tuple->t_self);
      OffsetNumber offnum;

+     tuple->relation = relation;
      /* ----------------
       *    increment access statistics
       * ----------------
***************
*** 1124,1129 ****
--- 1128,1134 ----
      bool        invalidBlock,
                  linkend;

+     tp.relation = relation;
      /* ----------------
       *    get the buffer from the relation descriptor
       *    Note that this does a buffer pin.
***************
*** 1216,1221 ****
--- 1221,1227 ----
       *    increment access statistics
       * ----------------
       */
+     tup->relation = relation;
      IncrHeapAccessStat(local_insert);
      IncrHeapAccessStat(global_insert);

***************
*** 1284,1289 ****
--- 1290,1296 ----
      Buffer        buffer;
      int            result;

+     tp.relation = relation;
      /* increment access statistics */
      IncrHeapAccessStat(local_delete);
      IncrHeapAccessStat(global_delete);
***************
*** 1396,1401 ****
--- 1403,1409 ----
      Buffer        buffer;
      int            result;

+     newtup->relation = relation;
      /* increment access statistics */
      IncrHeapAccessStat(local_replace);
      IncrHeapAccessStat(global_replace);
***************
*** 1524,1529 ****
--- 1532,1538 ----
      PageHeader    dp;
      int            result;

+     tuple->relation = relation;
      /* increment access statistics */
      IncrHeapAccessStat(local_mark4update);
      IncrHeapAccessStat(global_mark4update);
Index: src/backend/catalog/heap.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/heap.c,v
retrieving revision 1.133
diff -c -r1.133 heap.c
*** src/backend/catalog/heap.c    2000/06/18 22:43:55    1.133
--- src/backend/catalog/heap.c    2000/06/24 15:24:54
***************
*** 101,106 ****
--- 101,107 ----
   *                be more difficult if not impossible.
   */

+
  static FormData_pg_attribute a1 = {
      0xffffffff, {"ctid"}, TIDOID, 0, sizeof(ItemPointerData),
      SelfItemPointerAttributeNumber, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0'
***************
*** 130,137 ****
      0xffffffff, {"cmax"}, CIDOID, 0, sizeof(CommandId),
      MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
  };

! static Form_pg_attribute HeapAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};

  /* ----------------------------------------------------------------
   *                XXX END OF UGLY HARD CODED BADNESS XXX
--- 131,143 ----
      0xffffffff, {"cmax"}, CIDOID, 0, sizeof(CommandId),
      MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
  };
+
+ static FormData_pg_attribute a7 = {
+     0xffffffff, {"classoid"}, OIDOID, 0, sizeof(Oid),
+     ClassOidAttributeNumber, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0'
+ };

! static Form_pg_attribute HeapAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};

  /* ----------------------------------------------------------------
   *                XXX END OF UGLY HARD CODED BADNESS XXX
Index: src/backend/optimizer/path/tidpath.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/path/tidpath.c,v
retrieving revision 1.7
diff -c -r1.7 tidpath.c
*** src/backend/optimizer/path/tidpath.c    2000/05/30 00:49:47    1.7
--- src/backend/optimizer/path/tidpath.c    2000/06/24 15:24:55
***************
*** 105,110 ****
--- 105,118 ----
                   var->varoattno == SelfItemPointerAttributeNumber &&
                   var->vartype == TIDOID)
              arg = arg2;
+ /*        else if (var->varno == varno &&
+             var->varattno == ClassOidAttributeNumber &&
+             var->vartype == OIDCLASSOID)
+             arg = arg2;
+         else if (var->varnoold == varno &&
+                  var->varoattno == ClassOidAttributeNumber &&
+                  var->vartype == OIDCLASSOID)
+             arg = arg2; */
      }
      if ((!arg) && IsA(arg2, Var))
      {
***************
*** 113,118 ****
--- 121,130 ----
              var->varattno == SelfItemPointerAttributeNumber &&
              var->vartype == TIDOID)
              arg = arg1;
+ /*        else if (var->varno == varno &&
+             var->varattno == ClassOidAttributeNumber &&
+             var->vartype == OIDCLASSOID)
+             arg = arg1; */
      }
      if (!arg)
          return rnode;
Index: src/backend/optimizer/prep/preptlist.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v
retrieving revision 1.36
diff -c -r1.36 preptlist.c
*** src/backend/optimizer/prep/preptlist.c    2000/04/12 17:15:23    1.36
--- src/backend/optimizer/prep/preptlist.c    2000/06/24 15:24:57
***************
*** 15,21 ****
   * Portions Copyright (c) 1994, Regents of the University of California
   *
   * IDENTIFICATION
!  *      $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.36 2000/04/12 17:15:23
momjianExp $ 
   *
   *-------------------------------------------------------------------------
   */
--- 15,21 ----
   * Portions Copyright (c) 1994, Regents of the University of California
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.36 2000/04/12 17:15:23 momjian
Exp$ 
   *
   *-------------------------------------------------------------------------
   */
***************
*** 66,72 ****
      if (command_type == CMD_UPDATE || command_type == CMD_DELETE)
      {
          Resdom       *resdom;
!         Var           *var;

          resdom = makeResdom(length(tlist) + 1,
                              TIDOID,
--- 66,72 ----
      if (command_type == CMD_UPDATE || command_type == CMD_DELETE)
      {
          Resdom       *resdom;
!         Var           *var1, *var2;

          resdom = makeResdom(length(tlist) + 1,
                              TIDOID,
***************
*** 76,83 ****
                              0,
                              true);

!         var = makeVar(result_relation, SelfItemPointerAttributeNumber,
                        TIDOID, -1, 0);

          /*
           * For an UPDATE, expand_targetlist already created a fresh tlist.
--- 76,85 ----
                              0,
                              true);

!         var1 = makeVar(result_relation, SelfItemPointerAttributeNumber,
                        TIDOID, -1, 0);
+         var2 = makeVar(result_relation, ClassOidAttributeNumber,
+                       OIDOID, -1, 0);

          /*
           * For an UPDATE, expand_targetlist already created a fresh tlist.
***************
*** 87,93 ****
          if (command_type == CMD_DELETE)
              tlist = listCopy(tlist);

!         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var));
      }

      return tlist;
--- 89,96 ----
          if (command_type == CMD_DELETE)
              tlist = listCopy(tlist);

!         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var1));
!         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var2));
      }

      return tlist;
Index: src/backend/parser/parse_relation.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_relation.c,v
retrieving revision 1.44
diff -c -r1.44 parse_relation.c
*** src/backend/parser/parse_relation.c    2000/06/20 01:41:21    1.44
--- src/backend/parser/parse_relation.c    2000/06/24 15:24:58
***************
*** 40,45 ****
--- 40,48 ----

  {
      {
+         "classoid", ClassOidAttributeNumber, OIDOID
+     },
+     {
          "ctid", SelfItemPointerAttributeNumber, TIDOID
      },
      {
Index: src/backend/utils/cache/lsyscache.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v
retrieving revision 1.42
diff -c -r1.42 lsyscache.c
*** src/backend/utils/cache/lsyscache.c    2000/06/08 22:37:30    1.42
--- src/backend/utils/cache/lsyscache.c    2000/06/24 15:25:00
***************
*** 249,254 ****
--- 249,256 ----
      if (attnum == ObjectIdAttributeNumber ||
          attnum == SelfItemPointerAttributeNumber)
          return 1.0 / (double) ntuples;
+     if (attnum == ClassOidAttributeNumber)
+         return 1.0;

      /*
       * VACUUM ANALYZE has not been run for this table. Produce an estimate
Index: src/include/access/heapam.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/access/heapam.h,v
retrieving revision 1.53
diff -c -r1.53 heapam.h
*** src/include/access/heapam.h    2000/06/18 22:44:23    1.53
--- src/include/access/heapam.h    2000/06/24 15:25:02
***************
*** 230,239 ****
                  (Datum)((char *)&((tup)->t_self)) \
              ) \
              : \
              ( \
                  (Datum)*(unsigned int *) \
                      ((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
!             ) \
          ) \
      ) \
  )
--- 230,244 ----
                  (Datum)((char *)&((tup)->t_self)) \
              ) \
              : \
+             (((attnum) == ClassOidAttributeNumber) ? \
              ( \
+                 (Datum)((tup)->relation->rd_id) \
+             ) \
+             : \
+             ( \
                  (Datum)*(unsigned int *) \
                      ((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
!             )) \
          ) \
      ) \
  )
Index: src/include/access/htup.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/access/htup.h,v
retrieving revision 1.30
diff -c -r1.30 htup.h
*** src/include/access/htup.h    2000/06/02 10:20:26    1.30
--- src/include/access/htup.h    2000/06/24 15:25:02
***************
*** 133,139 ****
  #define MinCommandIdAttributeNumber                (-4)
  #define MaxTransactionIdAttributeNumber            (-5)
  #define MaxCommandIdAttributeNumber                (-6)
! #define FirstLowInvalidHeapAttributeNumber        (-7)

  /* If you make any changes above, the order off offsets in this must change */
  extern long heap_sysoffset[];
--- 133,140 ----
  #define MinCommandIdAttributeNumber                (-4)
  #define MaxTransactionIdAttributeNumber            (-5)
  #define MaxCommandIdAttributeNumber                (-6)
! #define ClassOidAttributeNumber                    (-7)
! #define FirstLowInvalidHeapAttributeNumber        (-8)

  /* If you make any changes above, the order off offsets in this must change */
  extern long heap_sysoffset[];
***************
*** 156,161 ****
--- 157,163 ----
  {
      uint32        t_len;            /* length of *t_data */
      ItemPointerData t_self;        /* SelfItemPointer */
+     Relation relation;          /* */
      MemoryContext t_datamcxt;    /* */
      HeapTupleHeader t_data;        /* */
  } HeapTupleData;
Index: src/include/catalog/pg_attribute.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_attribute.h,v
retrieving revision 1.59
diff -c -r1.59 pg_attribute.h
*** src/include/catalog/pg_attribute.h    2000/06/12 03:40:52    1.59
--- src/include/catalog/pg_attribute.h    2000/06/24 15:25:04
***************
*** 267,272 ****
--- 267,273 ----
  DATA(insert OID = 0 ( 1247 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1247 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1247 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1247 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_database
***************
*** 282,287 ****
--- 283,289 ----
  DATA(insert OID = 0 ( 1262 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1262 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1262 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1262 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_proc
***************
*** 329,334 ****
--- 331,337 ----
  DATA(insert OID = 0 ( 1255 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1255 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1255 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1255 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_shadow
***************
*** 348,353 ****
--- 351,357 ----
  DATA(insert OID = 0 ( 1260 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1260 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1260 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1260 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_group
***************
*** 362,367 ****
--- 366,372 ----
  DATA(insert OID = 0 ( 1261 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1261 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1261 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1261 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_attribute
***************
*** 405,410 ****
--- 410,416 ----
  DATA(insert OID = 0 ( 1249 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1249 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1249 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1249 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_class
***************
*** 458,463 ****
--- 464,470 ----
  DATA(insert OID = 0 ( 1259 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1259 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1259 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1259 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_attrdef
***************
*** 473,478 ****
--- 480,486 ----
  DATA(insert OID = 0 ( 1215 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1215 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1215 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1215 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_relcheck
***************
*** 488,493 ****
--- 496,502 ----
  DATA(insert OID = 0 ( 1216 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1216 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1216 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1216 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_trigger
***************
*** 513,518 ****
--- 522,528 ----
  DATA(insert OID = 0 ( 1219 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1219 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
  DATA(insert OID = 0 ( 1219 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
+ DATA(insert OID = 0 ( 1219 classoid            26 0  4  -7 0 -1 -1 t p f i f f));

  /* ----------------
   *        pg_variable - this relation is modified by special purpose access
Index: src/include/catalog/pg_type.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_type.h,v
retrieving revision 1.89
diff -c -r1.89 pg_type.h
*** src/include/catalog/pg_type.h    2000/06/05 07:29:01    1.89
--- src/include/catalog/pg_type.h    2000/06/24 15:25:06
***************
*** 337,342 ****
--- 337,343 ----
  DATA(insert OID = 1025 (  _tinterval PGUID -1  -1 f b t \054 0 704 array_in array_out array_in array_out i _null_ ));
  DATA(insert OID = 1026 (  _filename  PGUID -1  -1 f b t \054 0 605 array_in array_out array_in array_out i _null_ ));
  DATA(insert OID = 1027 (  _polygon     PGUID -1  -1 f b t \054 0 604 array_in array_out array_in array_out d _null_
));
+
  /*
   *    Note: the size of aclitem needs to match sizeof(AclItem) in acl.h.
   *    Thanks to some padding, this will be 8 on all platforms.
Index: src/tools/make_mkid
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/tools/make_mkid,v
retrieving revision 1.4
diff -c -r1.4 make_mkid
*** src/tools/make_mkid    2000/03/31 01:41:27    1.4
--- src/tools/make_mkid    2000/06/24 15:25:09
***************
*** 1,6 ****
  #!/bin/sh
  find `pwd`/ \( -name _deadcode -a -prune \) -o \
!     -type f -name '*.[chyl]' -print|sed 's;//;/;g' | mkid

  find . -name  'CVS' -prune -o -type d -print  |while read DIR
  do
--- 1,6 ----
  #!/bin/sh
  find `pwd`/ \( -name _deadcode -a -prune \) -o \
!     -type f -name '*.[chyl]' -print|sed 's;//;/;g' | mkid -

  find . -name  'CVS' -prune -o -type d -print  |while read DIR
  do

Re: CLASSOID patch

From
Peter Eisentraut
Date:
Chris Bitmead writes:

> Attached is a first attempt at implementing the classoid feature.

I'm wondering what other people think about the naming. Firstly, it's my
feeling that TABLEOID would be more in line with the general conventions.
Secondly, maybe we ought to make the name less susceptible to collision by
choosing a something like _CLASSOID (or whatever).

> It works!

Great! :)


--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden


RE: CLASSOID patch

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: pgsql-hackers-owner@hub.org [mailto:pgsql-hackers-owner@hub.org]On
> Behalf Of Chris Bitmead
>
> Attached is a first attempt at implementing the classoid feature. It
> works! Can the postgres gurus comment if I've done it right and point
> out any problems. A lot of it was guess work so I'm sure it can be
> cleaned up some.
>

The points I've noticed are the following.

1) It seems not preferable to add an entry *relation* which is of
    Relation type in HeapTupleData. Relation OID seems to be
    sufficient for your purpose.

2) The change in optimizer/path/tidpath.c seems to have
    no meaning.

Sorry,I have no time to check your patch more now.

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp

Re: [PATCHES] RE: CLASSOID patch

From
Tom Lane
Date:
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> The points I've noticed are the following.
> 1) It seems not preferable to add an entry *relation* which is of
>     Relation type in HeapTupleData. Relation OID seems to be
>     sufficient for your purpose.

I haven't looked at the patch at all yet, but I agree 100% with
Hiroshi on this point.  Relation is a pointer to a relcache entry
and relcache entries are *volatile*.  If all you need is the OID
then store the OID --- don't open Pandora's box by assuming the
relcache entry will never disappear before your tuple value does.

            regards, tom lane

Re: CLASSOID patch

From
Chris Bitmead
Date:
Peter Eisentraut wrote:
> 
> Chris Bitmead writes:
> 
> > Attached is a first attempt at implementing the classoid feature.
> 
> I'm wondering what other people think about the naming. Firstly, it's my
> feeling that TABLEOID would be more in line with the general conventions.

I was thinking this myself today. Mainly because I wonder if in the
future there may be support for more than one table implementing a
particular class type. On the other hand the oid is a reference to the
pg_class table. Maybe pg_class should be renamed pg_table? Anyway, my
current thinking is that tableoid is better.

The general naming conventions in postgres are a bit disturbing. Some
places refer to classes, some to tables, some to relations. One day it
should all be reconciled :-).

> Secondly, maybe we ought to make the name less susceptible to collision by
> choosing a something like _CLASSOID (or whatever).

Only if oid becomes _oid and ctid becomes _ctid. I don't think it's
worth it myself.

> > It works!
> 
> Great! :)


Re: CLASSOID patch

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> I'm wondering what other people think about the naming. Firstly, it's my
> feeling that TABLEOID would be more in line with the general conventions.

No strong feeling either way.  The old-line Postgres naming conventions
would suggest CLASSOID or RELATIONOID, but I sure wouldn't propose
RELATIONOID.

> Secondly, maybe we ought to make the name less susceptible to collision by
> choosing a something like _CLASSOID (or whatever).

No, I don't like that.  If we're going to do this at all then the name
ought to be consistent with the names of existing system attributes,
and those have no underscore decoration.

            regards, tom lane

Re: CLASSOID patch

From
Chris Bitmead
Date:
Hiroshi Inoue wrote:
> The points I've noticed are the following.
> 
> 1) It seems not preferable to add an entry *relation* which is of
>     Relation type in HeapTupleData. Relation OID seems to be
>     sufficient for your purpose.

Only that I was contemplating whether there should also be a "tablename"
attribute in addition to "classoid"/"tableoid", and I thought that
somehow it should be easier to get from Relation to its name, although
it's not immediately obvious to me if it is possible. If it is easily
done it seems desirable not to force people to join with pg_class.

> 2) The change in optimizer/path/tidpath.c seems to have
>     no meaning.

Yes that was definitely a mistake, and is commented out as you see.

Specific questions I have about the patch are...

*) Does this change not add additional storage to disk? I understand it
doesn't, but I don't understand the details.

*) in access/heap/heapam.c I wildly inserted a tuple->relation =
relation everywhere I could see. Perhaps someone with more insight can
tell me if some of these are excessive, or conversly if there are some
other access methods which will cause it not to work.


Re: CLASSOID patch

From
Chris Bitmead
Date:
Chris Bitmead wrote:
>
> Peter Eisentraut wrote:
> >
> > Chris Bitmead writes:
> >
> > > Attached is a first attempt at implementing the classoid feature.
> >
> > I'm wondering what other people think about the naming. Firstly, it's my
> > feeling that TABLEOID would be more in line with the general conventions.
>
> I was thinking this myself today. Mainly because I wonder if in the
> future there may be support for more than one table implementing a
> particular class type. On the other hand the oid is a reference to the
> pg_class table. Maybe pg_class should be renamed pg_table? Anyway, my
> current thinking is that tableoid is better.

Or put another way, I see SQL3 has a feature S051 "CREATE TABLE
<tablename> OF <type>", and it seems maybe the <type> should be called a
class, and the table a collection of that class. This would advocate the
tableoid name I think. Someone please correct me if my thinking is
muddled here.

RE: CLASSOID patch

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: chrisb@nimrod.itg.telstra.com.au
>
> Hiroshi Inoue wrote:
> > The points I've noticed are the following.
> >
> > 1) It seems not preferable to add an entry *relation* which is of
> >     Relation type in HeapTupleData. Relation OID seems to be
> >     sufficient for your purpose.
>
> Only that I was contemplating whether there should also be a "tablename"
> attribute in addition to "classoid"/"tableoid", and I thought that
> somehow it should be easier to get from Relation to its name, although
> it's not immediately obvious to me if it is possible. If it is easily
> done it seems desirable not to force people to join with pg_class.
>

Though the entries other than t_data in HeapTupleData
aren't stored to disk,HeapTupleData is just an extension
of HeapTupleHeaderData which represents the stored
format of tuples. Isn't it strange to you that htup.h is
dependent on rel.h ?

>
> Specific questions I have about the patch are...
>
> *) Does this change not add additional storage to disk? I understand it
> doesn't, but I don't understand the details.
>

AFAIK,it doesn't.

> *) in access/heap/heapam.c I wildly inserted a tuple->relation =
> relation everywhere I could see. Perhaps someone with more insight can
> tell me if some of these are excessive, or conversly if there are some
> other access methods which will cause it not to work.
>

It may be unnecessary for heap_insert/delete/update/mark4update().
I'm not sure however.

Hiroshi Inoue
Inoue@tpf.co.jp

Re: CLASSOID patch

From
M.Feldtmann@t-online.de (Marten Feldtmann)
Date:
On Mon, 26 Jun 2000 13:24:56 +1000, Chris Bitmead wrote:

>
>I was thinking this myself today. Mainly because I wonder if in the
>future there may be support for more than one table implementing a
>particular class type. On the other hand the oid is a reference to the

 Which is very common in wrapper software technology ! Normally only
the first implementation is done this way: one class - one table. But
this is only a very naive design decision. Then when the performance
lacks hierarchy tree are converted into one table ... etc

 Just my thoughts about something like this ....

 Marten


Marten Feldtmann, Germany


Re: [PATCHES] CLASSOID patch

From
Bruce Momjian
Date:
I don't see this in the tree.  Status, please.

>
> Attached is a first attempt at implementing the classoid feature. It
> works! Can the postgres gurus comment if I've done it right and point
> out any problems. A lot of it was guess work so I'm sure it can be
> cleaned up some.
>
> --
> Chris Bitmead
> mailto:chris@bitmead.com

> ? config.log
> ? config.cache
> ? config.status
> ? nohup.out
> ? GNUmakefile
> ? src/GNUmakefile
> ? src/Makefile.global
> ? src/ID
> ? src/nohup.out
> ? src/backend/fmgr.h
> ? src/backend/parse.h
> ? src/backend/postgres
> ? src/backend/global1.bki.source
> ? src/backend/local1_template1.bki.source
> ? src/backend/global1.description
> ? src/backend/local1_template1.description
> ? src/backend/1
> ? src/backend/catalog/genbki.sh
> ? src/backend/catalog/global1.bki.source
> ? src/backend/catalog/global1.description
> ? src/backend/catalog/local1_template1.bki.source
> ? src/backend/catalog/local1_template1.description
> ? src/backend/parser/y.output
> ? src/backend/parser/y.output.gz
> ? src/backend/parser/gram.y.works
> ? src/backend/parser/gram.y.works.try
> ? src/backend/parser/y.output.noerror
> ? src/backend/parser/gram.y.gz
> ? src/backend/port/Makefile
> ? src/backend/utils/Gen_fmgrtab.sh
> ? src/backend/utils/fmgr.h
> ? src/backend/utils/fmgrstamp-h
> ? src/bin/initdb/initdb
> ? src/bin/initlocation/initlocation
> ? src/bin/ipcclean/ipcclean
> ? src/bin/pg_ctl/pg_ctl
> ? src/bin/pg_dump/Makefile
> ? src/bin/pg_dump/pg_dump
> ? src/bin/pg_id/pg_id
> ? src/bin/pg_passwd/pg_passwd
> ? src/bin/pg_version/Makefile
> ? src/bin/pg_version/pg_version
> ? src/bin/pgtclsh/mkMakefile.tcldefs.sh
> ? src/bin/pgtclsh/mkMakefile.tkdefs.sh
> ? src/bin/psql/Makefile
> ? src/bin/psql/psql
> ? src/bin/scripts/createlang
> ? src/include/version.h
> ? src/include/config.h
> ? src/include/parser/parse.h
> ? src/include/utils/fmgroids.h
> ? src/interfaces/Makefile
> ? src/interfaces/ecpg/lib/Makefile
> ? src/interfaces/ecpg/lib/libecpg.so.3.1.1
> ? src/interfaces/ecpg/preproc/Makefile
> ? src/interfaces/ecpg/preproc/ecpg
> ? src/interfaces/jdbc/postgresql.jar
> ? src/interfaces/jdbc/example/psql.class
> ? src/interfaces/jdbc/postgresql/DriverClass.java
> ? src/interfaces/jdbc/postgresql/DriverClass.class
> ? src/interfaces/jdbc/postgresql/Connection.class
> ? src/interfaces/jdbc/postgresql/Field.class
> ? src/interfaces/jdbc/postgresql/PG_Stream.class
> ? src/interfaces/jdbc/postgresql/Driver.class
> ? src/interfaces/jdbc/postgresql/ResultSet.class
> ? src/interfaces/jdbc/postgresql/fastpath/Fastpath.class
> ? src/interfaces/jdbc/postgresql/fastpath/FastpathArg.class
> ? src/interfaces/jdbc/postgresql/geometric/PGbox.class
> ? src/interfaces/jdbc/postgresql/geometric/PGpoint.class
> ? src/interfaces/jdbc/postgresql/geometric/PGcircle.class
> ? src/interfaces/jdbc/postgresql/geometric/PGline.class
> ? src/interfaces/jdbc/postgresql/geometric/PGlseg.class
> ? src/interfaces/jdbc/postgresql/geometric/PGpath.class
> ? src/interfaces/jdbc/postgresql/geometric/PGpolygon.class
> ? src/interfaces/jdbc/postgresql/jdbc2/ResultSet.class
> ? src/interfaces/jdbc/postgresql/jdbc2/Connection.class
> ? src/interfaces/jdbc/postgresql/jdbc2/ResultSetMetaData.class
> ? src/interfaces/jdbc/postgresql/jdbc2/DatabaseMetaData.class
> ? src/interfaces/jdbc/postgresql/jdbc2/Statement.class
> ? src/interfaces/jdbc/postgresql/jdbc2/PreparedStatement.class
> ? src/interfaces/jdbc/postgresql/jdbc2/CallableStatement.class
> ? src/interfaces/jdbc/postgresql/largeobject/LargeObjectManager.class
> ? src/interfaces/jdbc/postgresql/largeobject/LargeObject.class
> ? src/interfaces/jdbc/postgresql/util/PSQLException.class
> ? src/interfaces/jdbc/postgresql/util/UnixCrypt.class
> ? src/interfaces/jdbc/postgresql/util/Serialize.class
> ? src/interfaces/jdbc/postgresql/util/PGobject.class
> ? src/interfaces/jdbc/postgresql/util/PGtokenizer.class
> ? src/interfaces/jdbc/postgresql/util/PGmoney.class
> ? src/interfaces/libpgeasy/Makefile
> ? src/interfaces/libpgeasy/libpgeasy.so.2.1
> ? src/interfaces/libpgtcl/Makefile
> ? src/interfaces/libpgtcl/mkMakefile.tcldefs.sh
> ? src/interfaces/libpgtcl/mkMakefile.tkdefs.sh
> ? src/interfaces/libpq/Makefile
> ? src/interfaces/libpq/libpq.so.2.1
> ? src/interfaces/libpq++/Makefile
> ? src/interfaces/libpq++/libpq++.so.3.1
> ? src/interfaces/odbc/GNUmakefile
> ? src/interfaces/odbc/Makefile.global
> ? src/interfaces/perl5/GNUmakefile
> ? src/interfaces/python/GNUmakefile
> ? src/pl/Makefile
> ? src/pl/plperl/GNUmakefile
> ? src/pl/plpgsql/Makefile
> ? src/pl/plpgsql/src/Makefile
> ? src/pl/plpgsql/src/libplpgsql.so.1.0
> ? src/pl/tcl/mkMakefile.tcldefs.sh
> ? src/test/regress/GNUmakefile
> ? src/test/regress/x.x
> ? src/test/regress/nohup.out
> Index: src/backend/access/common/heaptuple.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v
> retrieving revision 1.62
> diff -c -r1.62 heaptuple.c
> *** src/backend/access/common/heaptuple.c    2000/04/12 17:14:36    1.62
> --- src/backend/access/common/heaptuple.c    2000/06/24 15:24:46
> ***************
> *** 9,15 ****
>    *
>    *
>    * IDENTIFICATION
> !  *      $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12
17:14:36momjian Exp $ 
>    *
>    * NOTES
>    *      The old interface functions have been converted to macros
> --- 9,15 ----
>    *
>    *
>    * IDENTIFICATION
> !  *      $Header: /usr/local/cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.62 2000/04/12 17:14:36 momjian
Exp$ 
>    *
>    * NOTES
>    *      The old interface functions have been converted to macros
> ***************
> *** 169,174 ****
> --- 169,175 ----
>       else
>           switch (attnum)
>           {
> +             case ClassOidAttributeNumber:
>               case SelfItemPointerAttributeNumber:
>               case ObjectIdAttributeNumber:
>               case MinTransactionIdAttributeNumber:
> ***************
> *** 205,210 ****
> --- 206,213 ----
>
>       switch (attno)
>       {
> +         case ClassOidAttributeNumber:
> +             return sizeof f->t_oid;
>           case SelfItemPointerAttributeNumber:
>               return sizeof f->t_ctid;
>           case ObjectIdAttributeNumber:
> ***************
> *** 237,242 ****
> --- 240,248 ----
>
>       switch (attno)
>       {
> +         case ClassOidAttributeNumber:
> +             byval = true;
> +             break;
>           case SelfItemPointerAttributeNumber:
>               byval = false;
>               break;
> ***************
> *** 275,281 ****
>   {
>       switch (attnum)
>       {
> !             case SelfItemPointerAttributeNumber:
>               return (Datum) &tup->t_ctid;
>           case ObjectIdAttributeNumber:
>               return (Datum) (long) tup->t_oid;
> --- 281,289 ----
>   {
>       switch (attnum)
>       {
> !         case ClassOidAttributeNumber:
> !             return (Datum) &tup->t_classoid;
> !         case SelfItemPointerAttributeNumber:
>               return (Datum) &tup->t_ctid;
>           case ObjectIdAttributeNumber:
>               return (Datum) (long) tup->t_oid;
> Index: src/backend/access/heap/heapam.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/access/heap/heapam.c,v
> retrieving revision 1.71
> diff -c -r1.71 heapam.c
> *** src/backend/access/heap/heapam.c    2000/06/15 04:09:34    1.71
> --- src/backend/access/heap/heapam.c    2000/06/24 15:24:49
> ***************
> *** 235,240 ****
> --- 235,242 ----
>       int            linesleft;
>       ItemPointer tid = (tuple->t_data == NULL) ?
>       (ItemPointer) NULL : &(tuple->t_self);
> +
> +     tuple->relation = relation;
>
>       /* ----------------
>        *    increment access statistics
> ***************
> *** 567,572 ****
> --- 569,575 ----
>
>       Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
>
> +
>       /* ----------------
>        *    increment access statistics
>        * ----------------
> ***************
> *** 1030,1035 ****
> --- 1033,1039 ----
>       ItemPointer tid = &(tuple->t_self);
>       OffsetNumber offnum;
>
> +     tuple->relation = relation;
>       /* ----------------
>        *    increment access statistics
>        * ----------------
> ***************
> *** 1124,1129 ****
> --- 1128,1134 ----
>       bool        invalidBlock,
>                   linkend;
>
> +     tp.relation = relation;
>       /* ----------------
>        *    get the buffer from the relation descriptor
>        *    Note that this does a buffer pin.
> ***************
> *** 1216,1221 ****
> --- 1221,1227 ----
>        *    increment access statistics
>        * ----------------
>        */
> +     tup->relation = relation;
>       IncrHeapAccessStat(local_insert);
>       IncrHeapAccessStat(global_insert);
>
> ***************
> *** 1284,1289 ****
> --- 1290,1296 ----
>       Buffer        buffer;
>       int            result;
>
> +     tp.relation = relation;
>       /* increment access statistics */
>       IncrHeapAccessStat(local_delete);
>       IncrHeapAccessStat(global_delete);
> ***************
> *** 1396,1401 ****
> --- 1403,1409 ----
>       Buffer        buffer;
>       int            result;
>
> +     newtup->relation = relation;
>       /* increment access statistics */
>       IncrHeapAccessStat(local_replace);
>       IncrHeapAccessStat(global_replace);
> ***************
> *** 1524,1529 ****
> --- 1532,1538 ----
>       PageHeader    dp;
>       int            result;
>
> +     tuple->relation = relation;
>       /* increment access statistics */
>       IncrHeapAccessStat(local_mark4update);
>       IncrHeapAccessStat(global_mark4update);
> Index: src/backend/catalog/heap.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/catalog/heap.c,v
> retrieving revision 1.133
> diff -c -r1.133 heap.c
> *** src/backend/catalog/heap.c    2000/06/18 22:43:55    1.133
> --- src/backend/catalog/heap.c    2000/06/24 15:24:54
> ***************
> *** 101,106 ****
> --- 101,107 ----
>    *                be more difficult if not impossible.
>    */
>
> +
>   static FormData_pg_attribute a1 = {
>       0xffffffff, {"ctid"}, TIDOID, 0, sizeof(ItemPointerData),
>       SelfItemPointerAttributeNumber, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0'
> ***************
> *** 130,137 ****
>       0xffffffff, {"cmax"}, CIDOID, 0, sizeof(CommandId),
>       MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
>   };
>
> ! static Form_pg_attribute HeapAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};
>
>   /* ----------------------------------------------------------------
>    *                XXX END OF UGLY HARD CODED BADNESS XXX
> --- 131,143 ----
>       0xffffffff, {"cmax"}, CIDOID, 0, sizeof(CommandId),
>       MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
>   };
> +
> + static FormData_pg_attribute a7 = {
> +     0xffffffff, {"classoid"}, OIDOID, 0, sizeof(Oid),
> +     ClassOidAttributeNumber, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0'
> + };
>
> ! static Form_pg_attribute HeapAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
>
>   /* ----------------------------------------------------------------
>    *                XXX END OF UGLY HARD CODED BADNESS XXX
> Index: src/backend/optimizer/path/tidpath.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/path/tidpath.c,v
> retrieving revision 1.7
> diff -c -r1.7 tidpath.c
> *** src/backend/optimizer/path/tidpath.c    2000/05/30 00:49:47    1.7
> --- src/backend/optimizer/path/tidpath.c    2000/06/24 15:24:55
> ***************
> *** 105,110 ****
> --- 105,118 ----
>                    var->varoattno == SelfItemPointerAttributeNumber &&
>                    var->vartype == TIDOID)
>               arg = arg2;
> + /*        else if (var->varno == varno &&
> +             var->varattno == ClassOidAttributeNumber &&
> +             var->vartype == OIDCLASSOID)
> +             arg = arg2;
> +         else if (var->varnoold == varno &&
> +                  var->varoattno == ClassOidAttributeNumber &&
> +                  var->vartype == OIDCLASSOID)
> +             arg = arg2; */
>       }
>       if ((!arg) && IsA(arg2, Var))
>       {
> ***************
> *** 113,118 ****
> --- 121,130 ----
>               var->varattno == SelfItemPointerAttributeNumber &&
>               var->vartype == TIDOID)
>               arg = arg1;
> + /*        else if (var->varno == varno &&
> +             var->varattno == ClassOidAttributeNumber &&
> +             var->vartype == OIDCLASSOID)
> +             arg = arg1; */
>       }
>       if (!arg)
>           return rnode;
> Index: src/backend/optimizer/prep/preptlist.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v
> retrieving revision 1.36
> diff -c -r1.36 preptlist.c
> *** src/backend/optimizer/prep/preptlist.c    2000/04/12 17:15:23    1.36
> --- src/backend/optimizer/prep/preptlist.c    2000/06/24 15:24:57
> ***************
> *** 15,21 ****
>    * Portions Copyright (c) 1994, Regents of the University of California
>    *
>    * IDENTIFICATION
> !  *      $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.36 2000/04/12
17:15:23momjian Exp $ 
>    *
>    *-------------------------------------------------------------------------
>    */
> --- 15,21 ----
>    * Portions Copyright (c) 1994, Regents of the University of California
>    *
>    * IDENTIFICATION
> !  *      $Header: /usr/local/cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.36 2000/04/12 17:15:23 momjian
Exp$ 
>    *
>    *-------------------------------------------------------------------------
>    */
> ***************
> *** 66,72 ****
>       if (command_type == CMD_UPDATE || command_type == CMD_DELETE)
>       {
>           Resdom       *resdom;
> !         Var           *var;
>
>           resdom = makeResdom(length(tlist) + 1,
>                               TIDOID,
> --- 66,72 ----
>       if (command_type == CMD_UPDATE || command_type == CMD_DELETE)
>       {
>           Resdom       *resdom;
> !         Var           *var1, *var2;
>
>           resdom = makeResdom(length(tlist) + 1,
>                               TIDOID,
> ***************
> *** 76,83 ****
>                               0,
>                               true);
>
> !         var = makeVar(result_relation, SelfItemPointerAttributeNumber,
>                         TIDOID, -1, 0);
>
>           /*
>            * For an UPDATE, expand_targetlist already created a fresh tlist.
> --- 76,85 ----
>                               0,
>                               true);
>
> !         var1 = makeVar(result_relation, SelfItemPointerAttributeNumber,
>                         TIDOID, -1, 0);
> +         var2 = makeVar(result_relation, ClassOidAttributeNumber,
> +                       OIDOID, -1, 0);
>
>           /*
>            * For an UPDATE, expand_targetlist already created a fresh tlist.
> ***************
> *** 87,93 ****
>           if (command_type == CMD_DELETE)
>               tlist = listCopy(tlist);
>
> !         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var));
>       }
>
>       return tlist;
> --- 89,96 ----
>           if (command_type == CMD_DELETE)
>               tlist = listCopy(tlist);
>
> !         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var1));
> !         tlist = lappend(tlist, makeTargetEntry(resdom, (Node *) var2));
>       }
>
>       return tlist;
> Index: src/backend/parser/parse_relation.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/parser/parse_relation.c,v
> retrieving revision 1.44
> diff -c -r1.44 parse_relation.c
> *** src/backend/parser/parse_relation.c    2000/06/20 01:41:21    1.44
> --- src/backend/parser/parse_relation.c    2000/06/24 15:24:58
> ***************
> *** 40,45 ****
> --- 40,48 ----
>
>   {
>       {
> +         "classoid", ClassOidAttributeNumber, OIDOID
> +     },
> +     {
>           "ctid", SelfItemPointerAttributeNumber, TIDOID
>       },
>       {
> Index: src/backend/utils/cache/lsyscache.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v
> retrieving revision 1.42
> diff -c -r1.42 lsyscache.c
> *** src/backend/utils/cache/lsyscache.c    2000/06/08 22:37:30    1.42
> --- src/backend/utils/cache/lsyscache.c    2000/06/24 15:25:00
> ***************
> *** 249,254 ****
> --- 249,256 ----
>       if (attnum == ObjectIdAttributeNumber ||
>           attnum == SelfItemPointerAttributeNumber)
>           return 1.0 / (double) ntuples;
> +     if (attnum == ClassOidAttributeNumber)
> +         return 1.0;
>
>       /*
>        * VACUUM ANALYZE has not been run for this table. Produce an estimate
> Index: src/include/access/heapam.h
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/access/heapam.h,v
> retrieving revision 1.53
> diff -c -r1.53 heapam.h
> *** src/include/access/heapam.h    2000/06/18 22:44:23    1.53
> --- src/include/access/heapam.h    2000/06/24 15:25:02
> ***************
> *** 230,239 ****
>                   (Datum)((char *)&((tup)->t_self)) \
>               ) \
>               : \
>               ( \
>                   (Datum)*(unsigned int *) \
>                       ((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
> !             ) \
>           ) \
>       ) \
>   )
> --- 230,244 ----
>                   (Datum)((char *)&((tup)->t_self)) \
>               ) \
>               : \
> +             (((attnum) == ClassOidAttributeNumber) ? \
>               ( \
> +                 (Datum)((tup)->relation->rd_id) \
> +             ) \
> +             : \
> +             ( \
>                   (Datum)*(unsigned int *) \
>                       ((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
> !             )) \
>           ) \
>       ) \
>   )
> Index: src/include/access/htup.h
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/access/htup.h,v
> retrieving revision 1.30
> diff -c -r1.30 htup.h
> *** src/include/access/htup.h    2000/06/02 10:20:26    1.30
> --- src/include/access/htup.h    2000/06/24 15:25:02
> ***************
> *** 133,139 ****
>   #define MinCommandIdAttributeNumber                (-4)
>   #define MaxTransactionIdAttributeNumber            (-5)
>   #define MaxCommandIdAttributeNumber                (-6)
> ! #define FirstLowInvalidHeapAttributeNumber        (-7)
>
>   /* If you make any changes above, the order off offsets in this must change */
>   extern long heap_sysoffset[];
> --- 133,140 ----
>   #define MinCommandIdAttributeNumber                (-4)
>   #define MaxTransactionIdAttributeNumber            (-5)
>   #define MaxCommandIdAttributeNumber                (-6)
> ! #define ClassOidAttributeNumber                    (-7)
> ! #define FirstLowInvalidHeapAttributeNumber        (-8)
>
>   /* If you make any changes above, the order off offsets in this must change */
>   extern long heap_sysoffset[];
> ***************
> *** 156,161 ****
> --- 157,163 ----
>   {
>       uint32        t_len;            /* length of *t_data */
>       ItemPointerData t_self;        /* SelfItemPointer */
> +     Relation relation;          /* */
>       MemoryContext t_datamcxt;    /* */
>       HeapTupleHeader t_data;        /* */
>   } HeapTupleData;
> Index: src/include/catalog/pg_attribute.h
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_attribute.h,v
> retrieving revision 1.59
> diff -c -r1.59 pg_attribute.h
> *** src/include/catalog/pg_attribute.h    2000/06/12 03:40:52    1.59
> --- src/include/catalog/pg_attribute.h    2000/06/24 15:25:04
> ***************
> *** 267,272 ****
> --- 267,273 ----
>   DATA(insert OID = 0 ( 1247 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1247 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1247 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1247 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_database
> ***************
> *** 282,287 ****
> --- 283,289 ----
>   DATA(insert OID = 0 ( 1262 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1262 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1262 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1262 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_proc
> ***************
> *** 329,334 ****
> --- 331,337 ----
>   DATA(insert OID = 0 ( 1255 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1255 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1255 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1255 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_shadow
> ***************
> *** 348,353 ****
> --- 351,357 ----
>   DATA(insert OID = 0 ( 1260 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1260 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1260 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1260 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_group
> ***************
> *** 362,367 ****
> --- 366,372 ----
>   DATA(insert OID = 0 ( 1261 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1261 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1261 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1261 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_attribute
> ***************
> *** 405,410 ****
> --- 410,416 ----
>   DATA(insert OID = 0 ( 1249 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1249 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1249 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1249 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_class
> ***************
> *** 458,463 ****
> --- 464,470 ----
>   DATA(insert OID = 0 ( 1259 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1259 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1259 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1259 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_attrdef
> ***************
> *** 473,478 ****
> --- 480,486 ----
>   DATA(insert OID = 0 ( 1215 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1215 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1215 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1215 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_relcheck
> ***************
> *** 488,493 ****
> --- 496,502 ----
>   DATA(insert OID = 0 ( 1216 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1216 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1216 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1216 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_trigger
> ***************
> *** 513,518 ****
> --- 522,528 ----
>   DATA(insert OID = 0 ( 1219 cmin                29 0  4  -4 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1219 xmax                28 0  4  -5 0 -1 -1 t p f i f f));
>   DATA(insert OID = 0 ( 1219 cmax                29 0  4  -6 0 -1 -1 t p f i f f));
> + DATA(insert OID = 0 ( 1219 classoid            26 0  4  -7 0 -1 -1 t p f i f f));
>
>   /* ----------------
>    *        pg_variable - this relation is modified by special purpose access
> Index: src/include/catalog/pg_type.h
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/catalog/pg_type.h,v
> retrieving revision 1.89
> diff -c -r1.89 pg_type.h
> *** src/include/catalog/pg_type.h    2000/06/05 07:29:01    1.89
> --- src/include/catalog/pg_type.h    2000/06/24 15:25:06
> ***************
> *** 337,342 ****
> --- 337,343 ----
>   DATA(insert OID = 1025 (  _tinterval PGUID -1  -1 f b t \054 0 704 array_in array_out array_in array_out i _null_
));
>   DATA(insert OID = 1026 (  _filename  PGUID -1  -1 f b t \054 0 605 array_in array_out array_in array_out i _null_
));
>   DATA(insert OID = 1027 (  _polygon     PGUID -1  -1 f b t \054 0 604 array_in array_out array_in array_out d _null_
));
> +
>   /*
>    *    Note: the size of aclitem needs to match sizeof(AclItem) in acl.h.
>    *    Thanks to some padding, this will be 8 on all platforms.
> Index: src/tools/make_mkid
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/tools/make_mkid,v
> retrieving revision 1.4
> diff -c -r1.4 make_mkid
> *** src/tools/make_mkid    2000/03/31 01:41:27    1.4
> --- src/tools/make_mkid    2000/06/24 15:25:09
> ***************
> *** 1,6 ****
>   #!/bin/sh
>   find `pwd`/ \( -name _deadcode -a -prune \) -o \
> !     -type f -name '*.[chyl]' -print|sed 's;//;/;g' | mkid
>
>   find . -name  'CVS' -prune -o -type d -print  |while read DIR
>   do
> --- 1,6 ----
>   #!/bin/sh
>   find `pwd`/ \( -name _deadcode -a -prune \) -o \
> !     -type f -name '*.[chyl]' -print|sed 's;//;/;g' | mkid -
>
>   find . -name  'CVS' -prune -o -type d -print  |while read DIR
>   do


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

Re: [PATCHES] CLASSOID patch

From
Tom Lane
Date:
It's TableOid now.  That patch is long dead...

            regards, tom lane