heap_fetch requires buffer pointer, must be released; heap_getnext
authorBruce Momjian
Wed, 19 Aug 1998 02:04:17 +0000 (02:04 +0000)
committerBruce Momjian
Wed, 19 Aug 1998 02:04:17 +0000 (02:04 +0000)
no longer returns buffer pointer, can be gotten from scan;
descriptor; bootstrap can create multi-key indexes;
pg_procname index now is multi-key index; oidint2, oidint4, oidname
are gone (must be removed from regression tests); use System Cache
rather than sequential scan in many places; heap_modifytuple no
longer takes buffer parameter; remove unused buffer parameter in
a few other functions; oid8 is not index-able; remove some use of
single-character variable names; cleanup Buffer variables usage
and scan descriptor looping; cleaned up allocation and freeing of
tuples; 18k lines of diff;

123 files changed:
src/backend/access/common/heaptuple.c
src/backend/access/common/printtup.c
src/backend/access/common/tupdesc.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistscan.c
src/backend/access/hash/hash.c
src/backend/access/hash/hashfunc.c
src/backend/access/hash/hashscan.c
src/backend/access/heap/heapam.c
src/backend/access/index/genam.c
src/backend/access/index/indexam.c
src/backend/access/index/istrat.c
src/backend/access/nbtree/nbtcompare.c
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtscan.c
src/backend/access/nbtree/nbtutils.c
src/backend/access/rtree/rtree.c
src/backend/access/rtree/rtscan.c
src/backend/bootstrap/bootparse.y
src/backend/bootstrap/bootstrap.c
src/backend/catalog/aclchk.c
src/backend/catalog/catalog.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_type.c
src/backend/commands/_deadcode/version.c
src/backend/commands/async.c
src/backend/commands/cluster.c
src/backend/commands/command.c
src/backend/commands/copy.c
src/backend/commands/creatinh.c
src/backend/commands/dbcommands.c
src/backend/commands/defind.c
src/backend/commands/proclang.c
src/backend/commands/remove.c
src/backend/commands/rename.c
src/backend/commands/sequence.c
src/backend/commands/trigger.c
src/backend/commands/user.c
src/backend/commands/vacuum.c
src/backend/executor/execMain.c
src/backend/executor/execUtils.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeMaterial.c
src/backend/executor/nodeSeqscan.c
src/backend/executor/nodeTee.c
src/backend/executor/spi.c
src/backend/libpq/be-fsstubs.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/xfunc.c
src/backend/optimizer/util/plancat.c
src/backend/parser/parse_agg.c
src/backend/parser/parse_func.c
src/backend/parser/parse_node.c
src/backend/parser/parse_oper.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parse_type.c
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteHandler.c
src/backend/rewrite/rewriteRemove.c
src/backend/rewrite/rewriteSupport.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/localbuf.c
src/backend/storage/large_object/inv_api.c
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/multi.c
src/backend/storage/smgr/mm.c
src/backend/tcop/fastpath.c
src/backend/utils/adt/Makefile
src/backend/utils/adt/acl.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/not_in.c
src/backend/utils/adt/oid.c
src/backend/utils/adt/oidint2.c [deleted file]
src/backend/utils/adt/oidint4.c [deleted file]
src/backend/utils/adt/oidname.c [deleted file]
src/backend/utils/adt/regproc.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/sets.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/fcache.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/init/miscinit.c
src/backend/utils/misc/database.c
src/backend/utils/misc/superuser.c
src/backend/utils/time/tqual.c
src/include/access/genam.h
src/include/access/hash.h
src/include/access/heapam.h
src/include/access/tupdesc.h
src/include/catalog/duplicate_oids
src/include/catalog/heap.h
src/include/catalog/index.h
src/include/catalog/indexing.h
src/include/catalog/pg_am.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h
src/include/postgres.h
src/include/storage/bufmgr.h
src/include/utils/builtins.h
src/include/utils/oidcompos.h [deleted file]
src/include/utils/rel.h
src/include/utils/syscache.h
src/interfaces/ecpg/preproc/type.h
src/man/create_index.l
src/pl/tcl/pltcl.c
src/tools/pgindent/pgindent

index ec5b756e7487088a65d0b5d1432e670d1df9f25d..cade50db3ca7668a7139bfb28913a329adfd82c7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.38 1998/06/15 19:27:44 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.39 1998/08/19 02:00:53 momjian Exp $
  *
  * NOTES
  *   The old interface functions have been converted to macros
@@ -736,13 +736,6 @@ heap_copytuple(HeapTuple tuple)
    if (!HeapTupleIsValid(tuple))
        return (NULL);
 
-   /* XXX For now, just prevent an undetectable executor related error */
-   if (tuple->t_len > MAXTUPLEN)
-   {
-       elog(ERROR, "palloctup: cannot handle length %d tuples",
-            tuple->t_len);
-   }
-
    newTuple = (HeapTuple) palloc(tuple->t_len);
    memmove((char *) newTuple, (char *) tuple, (int) tuple->t_len);
    return (newTuple);
@@ -863,11 +856,11 @@ heap_formtuple(TupleDesc tupleDescriptor,
  *     heap_modifytuple
  *
  *     forms a new tuple from an old tuple and a set of replacement values.
+ *     returns a new palloc'ed tuple.
  * ----------------
  */
 HeapTuple
 heap_modifytuple(HeapTuple tuple,
-                Buffer buffer,
                 Relation relation,
                 Datum replValue[],
                 char replNull[],
@@ -879,7 +872,6 @@ heap_modifytuple(HeapTuple tuple,
    char       *nulls;
    bool        isNull;
    HeapTuple   newTuple;
-   int         madecopy;
    uint8       infomask;
 
    /* ----------------
@@ -887,26 +879,11 @@ heap_modifytuple(HeapTuple tuple,
     * ----------------
     */
    Assert(HeapTupleIsValid(tuple));
-   Assert(BufferIsValid(buffer) || RelationIsValid(relation));
-   Assert(HeapTupleIsValid(tuple));
+   Assert(RelationIsValid(relation));
    Assert(PointerIsValid(replValue));
    Assert(PointerIsValid(replNull));
    Assert(PointerIsValid(repl));
 
-   /* ----------------
-    *  if we're pointing to a disk page, then first
-    *  make a copy of our tuple so that all the attributes
-    *  are available.  XXX this is inefficient -cim
-    * ----------------
-    */
-   madecopy = 0;
-   if (BufferIsValid(buffer) == true)
-   {
-       relation = (Relation) BufferGetRelation(buffer);
-       tuple = heap_copytuple(tuple);
-       madecopy = 1;
-   }
-
    numberOfAttributes = RelationGetRelationTupleForm(relation)->relnatts;
 
    /* ----------------
@@ -933,10 +910,7 @@ heap_modifytuple(HeapTuple tuple,
 
        }
        else if (repl[attoff] != 'r')
-       {
            elog(ERROR, "heap_modifytuple: repl is \\%3d", repl[attoff]);
-
-       }
        else
        {                       /* == 'r' */
            value[attoff] = replValue[attoff];
@@ -961,18 +935,8 @@ heap_modifytuple(HeapTuple tuple,
            (char *) &tuple->t_oid,
            ((char *) &tuple->t_hoff - (char *) &tuple->t_oid));        /* XXX */
    newTuple->t_infomask = infomask;
-   newTuple->t_natts = numberOfAttributes;     /* fix t_natts just in
-                                                * case */
-
-   /* ----------------
-    *  if we made a copy of the tuple, then free it.
-    * ----------------
-    */
-   if (madecopy)
-       pfree(tuple);
-
-   return
-       newTuple;
+   newTuple->t_natts = numberOfAttributes;     /* fix t_natts just in case */
+   return newTuple;
 }
 
 /* ----------------------------------------------------------------
index c07a2f9c978c7be1dd7123eabefb32215c6d0c89..936725a2ce51119c40c4c57550a791b63330cd45 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.31 1998/07/26 04:30:16 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.32 1998/08/19 02:00:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,8 +46,7 @@ typtoout(Oid type)
                                    0, 0, 0);
 
    if (HeapTupleIsValid(typeTuple))
-       return ((Oid)
-               ((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
+       return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typoutput);
 
    elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
    return (InvalidOid);
@@ -63,8 +62,7 @@ gettypelem(Oid type)
                                    0, 0, 0);
 
    if (HeapTupleIsValid(typeTuple))
-       return ((Oid)
-               ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
+       return ((Oid) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
 
    elog(ERROR, "typtoout: Cache lookup of type %d failed", type);
    return (InvalidOid);
index f096c1b8870b49570de3bf67c9ccf0d6d058a2f5..569fac67101a5c3e4b06cbc8b8e2fa49c531ee81 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.41 1998/07/12 21:29:13 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.42 1998/08/19 02:00:56 momjian Exp $
  *
  * NOTES
  *   some of the executor utility code such as "ExecTypeFromTL" should be
@@ -327,7 +327,8 @@ TupleDescInitEntry(TupleDesc desc,
     *  -cim 6/14/90
     * ----------------
     */
-   tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typeid),
+   tuple = SearchSysCacheTuple(TYPOID,
+                               ObjectIdGetDatum(typeid),
                                0, 0, 0);
    if (!HeapTupleIsValid(tuple))
    {
index 1445ff7f2eb5209c6b236649f947ef3d2df0410a..e61c3ce5dd2c7296b15c8d2e1bc62444902367ab 100644 (file)
@@ -87,7 +87,6 @@ gistbuild(Relation heap,
          PredInfo *predInfo)
 {
    HeapScanDesc scan;
-   Buffer      buffer;
    AttrNumber  i;
    HeapTuple   htup;
    IndexTuple  itup;
@@ -112,14 +111,15 @@ gistbuild(Relation heap,
               *oldPred;
    GISTSTATE   giststate;
    GISTENTRY   tmpcentry;
+   Buffer      buffer = InvalidBuffer;
    bool       *compvec;
 
    /* GiSTs only know how to do stupid locking now */
    RelationSetLockForWrite(index);
 
-   setheapoverride(TRUE);      /* so we can see the new pg_index tuple */
+   setheapoverride(true);      /* so we can see the new pg_index tuple */
    initGISTstate(&giststate, index);
-   setheapoverride(FALSE);
+   setheapoverride(false);
 
    pred = predInfo->pred;
    oldPred = predInfo->oldPred;
@@ -170,15 +170,13 @@ gistbuild(Relation heap,
        econtext = NULL;
    }
 #endif                         /* OMIT_PARTIAL_INDEX */
-   scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
-   htup = heap_getnext(scan, 0, &buffer);
-
    /* int the tuples as we insert them */
    nh = ni = 0;
 
-   for (; HeapTupleIsValid(htup); htup = heap_getnext(scan, 0, &buffer))
-   {
+   scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
 
+   while (HeapTupleIsValid(htup = heap_getnext(scan, 0)))
+   {
        nh++;
 
        /*
@@ -240,8 +238,7 @@ gistbuild(Relation heap,
                                      attoff,
                                      attnum,
                                      finfo,
-                                     &attnull,
-                                     buffer);
+                                     &attnull);
            nulls[attoff] = (attnull ? 'n' : ' ');
        }
 
@@ -302,8 +299,8 @@ gistbuild(Relation heap,
     * flushed.  We close them to guarantee that they will be.
     */
 
-   hrelid = heap->rd_id;
-   irelid = index->rd_id;
+   hrelid = RelationGetRelid(heap);
+   irelid = RelationGetRelid(index);
    heap_close(heap);
    index_close(index);
 
@@ -1165,11 +1162,13 @@ initGISTstate(GISTSTATE *giststate, Relation index)
    fmgr_info(equal_proc, &giststate->equalFn);
 
    /* see if key type is different from type of attribute being indexed */
-   htup = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(index->rd_id),
+   htup = SearchSysCacheTuple(INDEXRELID,
+                              ObjectIdGetDatum(RelationGetRelid(index)),
                               0, 0, 0);
    itupform = (IndexTupleForm) GETSTRUCT(htup);
    if (!HeapTupleIsValid(htup))
-       elog(ERROR, "initGISTstate: index %d not found", index->rd_id);
+       elog(ERROR, "initGISTstate: index %d not found",
+       RelationGetRelid(index));
    giststate->haskeytype = itupform->indhaskeytype;
    if (giststate->haskeytype)
    {
index 7b9d49726bad18824928f91496fb1e6cc05fc222..ee016c1a934a0bdc00e6b316f5c77d37c2def18d 100644 (file)
@@ -284,12 +284,12 @@ gistdropscan(IndexScanDesc s)
 }
 
 void
-gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
+gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum)
 {
    GISTScanList l;
    Oid         relid;
 
-   relid = r->rd_id;
+   relid = RelationGetRelid(rel);
    for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next)
    {
        if (l->gsl_scan->relation->rd_id == relid)
index 6e913e7da49b74148714bef7fa927c03687b1196..4bcc7eab5247c47b9c626d214931ef22422bd778 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.19 1998/07/27 19:37:35 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.20 1998/08/19 02:01:00 momjian Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -53,7 +53,6 @@ hashbuild(Relation heap,
          PredInfo *predInfo)
 {
    HeapScanDesc hscan;
-   Buffer      buffer;
    HeapTuple   htup;
    IndexTuple  itup;
    TupleDesc   htupdesc,
@@ -65,6 +64,7 @@ hashbuild(Relation heap,
                nitups;
    int         i;
    HashItem    hitem;
+   Buffer      buffer = InvalidBuffer;
 
 #ifndef OMIT_PARTIAL_INDEX
    ExprContext *econtext;
@@ -120,14 +120,13 @@ hashbuild(Relation heap,
    }
 #endif                         /* OMIT_PARTIAL_INDEX */
 
-   /* start a heap scan */
-   hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
-   htup = heap_getnext(hscan, 0, &buffer);
-
    /* build the index */
    nhtups = nitups = 0;
 
-   for (; HeapTupleIsValid(htup); htup = heap_getnext(hscan, 0, &buffer))
+   /* start a heap scan */
+   hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
+
+   while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
    {
 
        nhtups++;
@@ -193,8 +192,7 @@ hashbuild(Relation heap,
                                            attoff,
                                            attnum,
                                            finfo,
-                                           &attnull,
-                                           buffer);
+                                           &attnull);
            nulls[attoff] = (attnull ? 'n' : ' ');
        }
 
@@ -248,8 +246,8 @@ hashbuild(Relation heap,
     */
    if (IsNormalProcessingMode())
    {
-       hrelid = heap->rd_id;
-       irelid = index->rd_id;
+       hrelid = RelationGetRelid(heap);
+       irelid = RelationGetRelid(index);
        heap_close(heap);
        index_close(index);
        UpdateStats(hrelid, nhtups, true);
index f5af00fe2b1cda2db670838586eae17ed7201da9..d57c65e4e0705950762b2270ad2eb8e1aecbb873 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.9 1998/04/26 04:05:08 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.10 1998/08/19 02:01:02 momjian Exp $
  *
  * NOTES
  *   These functions are stored in pg_amproc.  For each operator class
@@ -133,6 +133,18 @@ hashoid(Oid key)
    return ((uint32) ~key);
 }
 
+uint32
+hashoid8(Oid key[])
+{
+   int i;
+   uint32 result = 0;
+
+   for (i=0; i < 8; i++)
+       result = result ^ (~(uint32)key[i]);
+   return result;
+}
+
+
 #define PRIME1         37
 #define PRIME2         1048583
 
index 708dc18943ed9019ab313234f54a430383b3f1d1..ebc41220352b942568463cd4de0502c8e3144d37 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.14 1998/06/15 19:27:50 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.15 1998/08/19 02:01:04 momjian Exp $
  *
  * NOTES
  *   Because we can be doing an index scan on a relation while we
@@ -90,7 +90,7 @@ _hash_adjscans(Relation rel, ItemPointer tid)
    HashScanList l;
    Oid         relid;
 
-   relid = rel->rd_id;
+   relid = RelationGetRelid(rel);
    for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next)
    {
        if (relid == l->hashsl_scan->relation->rd_id)
index 75127b027d1cd3c9f48c4c17d247a7d73f100b0a..139db3b5e36dcccb03d2c70650f1feab15fbd5a2 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.31 1998/07/27 19:37:36 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.32 1998/08/19 02:01:05 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -104,11 +104,11 @@ static bool ImmediateInvalidation;
  */
 
 /* ----------------
- *     initsdesc - sdesc code common to heap_beginscan and heap_rescan
+ *     initscan - scan code common to heap_beginscan and heap_rescan
  * ----------------
  */
 static void
-initsdesc(HeapScanDesc sdesc,
+initscan(HeapScanDesc scan,
          Relation relation,
          int atend,
          unsigned nkeys,
@@ -120,8 +120,8 @@ initsdesc(HeapScanDesc sdesc,
         *  relation is empty
         * ----------------
         */
-       sdesc->rs_ntup = sdesc->rs_ctup = sdesc->rs_ptup = NULL;
-       sdesc->rs_nbuf = sdesc->rs_cbuf = sdesc->rs_pbuf = InvalidBuffer;
+       scan->rs_ntup = scan->rs_ctup = scan->rs_ptup = NULL;
+       scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
    }
    else if (atend)
    {
@@ -129,10 +129,10 @@ initsdesc(HeapScanDesc sdesc,
         *  reverse scan
         * ----------------
         */
-       sdesc->rs_ntup = sdesc->rs_ctup = NULL;
-       sdesc->rs_nbuf = sdesc->rs_cbuf = InvalidBuffer;
-       sdesc->rs_ptup = NULL;
-       sdesc->rs_pbuf = UnknownBuffer;
+       scan->rs_ntup = scan->rs_ctup = NULL;
+       scan->rs_nbuf = scan->rs_cbuf = InvalidBuffer;
+       scan->rs_ptup = NULL;
+       scan->rs_pbuf = UnknownBuffer;
    }
    else
    {
@@ -140,35 +140,35 @@ initsdesc(HeapScanDesc sdesc,
         *  forward scan
         * ----------------
         */
-       sdesc->rs_ctup = sdesc->rs_ptup = NULL;
-       sdesc->rs_cbuf = sdesc->rs_pbuf = InvalidBuffer;
-       sdesc->rs_ntup = NULL;
-       sdesc->rs_nbuf = UnknownBuffer;
+       scan->rs_ctup = scan->rs_ptup = NULL;
+       scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
+       scan->rs_ntup = NULL;
+       scan->rs_nbuf = UnknownBuffer;
    }                           /* invalid too */
 
    /* we don't have a marked position... */
-   ItemPointerSetInvalid(&(sdesc->rs_mptid));
-   ItemPointerSetInvalid(&(sdesc->rs_mctid));
-   ItemPointerSetInvalid(&(sdesc->rs_mntid));
-   ItemPointerSetInvalid(&(sdesc->rs_mcd));
+   ItemPointerSetInvalid(&(scan->rs_mptid));
+   ItemPointerSetInvalid(&(scan->rs_mctid));
+   ItemPointerSetInvalid(&(scan->rs_mntid));
+   ItemPointerSetInvalid(&(scan->rs_mcd));
 
    /* ----------------
     *  copy the scan key, if appropriate
     * ----------------
     */
    if (key != NULL)
-       memmove(sdesc->rs_key, key, nkeys * sizeof(ScanKeyData));
+       memmove(scan->rs_key, key, nkeys * sizeof(ScanKeyData));
 }
 
 /* ----------------
- *     unpinsdesc - code common to heap_rescan and heap_endscan
+ *     unpinscan - code common to heap_rescan and heap_endscan
  * ----------------
  */
 static void
-unpinsdesc(HeapScanDesc sdesc)
+unpinscan(HeapScanDesc scan)
 {
-   if (BufferIsValid(sdesc->rs_pbuf))
-       ReleaseBuffer(sdesc->rs_pbuf);
+   if (BufferIsValid(scan->rs_pbuf))
+       ReleaseBuffer(scan->rs_pbuf);
 
    /* ------------------------------------
     *  Scan will pin buffer one for each non-NULL tuple pointer
@@ -176,11 +176,11 @@ unpinsdesc(HeapScanDesc sdesc)
     *  times.
     * ------------------------------------
     */
-   if (BufferIsValid(sdesc->rs_cbuf))
-       ReleaseBuffer(sdesc->rs_cbuf);
+   if (BufferIsValid(scan->rs_cbuf))
+       ReleaseBuffer(scan->rs_cbuf);
 
-   if (BufferIsValid(sdesc->rs_nbuf))
-       ReleaseBuffer(sdesc->rs_nbuf);
+   if (BufferIsValid(scan->rs_nbuf))
+       ReleaseBuffer(scan->rs_nbuf);
 }
 
 /* ------------------------------------------
@@ -202,13 +202,18 @@ nextpage(int page, int dir)
  *
  *     routine used by heap_getnext() which does most of the
  *     real work in scanning tuples.
+ *
+ *     The scan routines handle their own buffer lock/unlocking, so
+ *     there is no reason to request the buffer number unless
+ *     to want to perform some other operation with the result,
+ *     like pass it to another function.
  * ----------------
  */
 static HeapTuple
 heapgettup(Relation relation,
           ItemPointer tid,
           int dir,
-          Buffer *b,
+          Buffer *buf,
           Snapshot snapshot,
           int nkeys,
           ScanKey key)
@@ -248,7 +253,7 @@ heapgettup(Relation relation,
        elog(DEBUG, "heapgettup(%s, tid=0x%x, dir=%d, ...)",
             RelationGetRelationName(relation), tid, dir);
    }
-   elog(DEBUG, "heapgettup(..., b=0x%x, nkeys=%d, key=0x%x", b, nkeys, key);
+   elog(DEBUG, "heapgettup(..., b=0x%x, nkeys=%d, key=0x%x", buf, nkeys, key);
 
    elog(DEBUG, "heapgettup: relation(%c)=`%s', %p",
         relation->rd_rel->relkind, &relation->rd_rel->relname,
@@ -278,19 +283,19 @@ heapgettup(Relation relation,
        /* assume it is a valid TID XXX */
        if (ItemPointerIsValid(tid) == false)
        {
-           *b = InvalidBuffer;
+           *buf= InvalidBuffer;
            return (NULL);
        }
-       *b = RelationGetBufferWithBuffer(relation,
+       *buf = RelationGetBufferWithBuffer(relation,
                                         ItemPointerGetBlockNumber(tid),
-                                        *b);
+                                        *buf);
 
 #ifndef NO_BUFFERISVALID
-       if (!BufferIsValid(*b))
+       if (!BufferIsValid(*buf))
            elog(ERROR, "heapgettup: failed ReadBuffer");
 #endif
 
-       dp = (Page) BufferGetPage(*b);
+       dp = (Page) BufferGetPage(*buf);
        lineoff = ItemPointerGetOffsetNumber(tid);
        lpp = PageGetItemId(dp, lineoff);
 
@@ -316,17 +321,17 @@ heapgettup(Relation relation,
        }
        if (page < 0)
        {
-           *b = InvalidBuffer;
+           *buf = InvalidBuffer;
            return (NULL);
        }
 
-       *b = RelationGetBufferWithBuffer(relation, page, *b);
+       *buf = RelationGetBufferWithBuffer(relation, page, *buf);
 #ifndef NO_BUFFERISVALID
-       if (!BufferIsValid(*b))
+       if (!BufferIsValid(*buf))
            elog(ERROR, "heapgettup: failed ReadBuffer");
 #endif
 
-       dp = (Page) BufferGetPage(*b);
+       dp = (Page) BufferGetPage(*buf);
        lines = PageGetMaxOffsetNumber(dp);
        if (tid == NULL)
        {
@@ -360,18 +365,18 @@ heapgettup(Relation relation,
 
        if (page >= pages)
        {
-           *b = InvalidBuffer;
+           *buf = InvalidBuffer;
            return (NULL);
        }
        /* page and lineoff now reference the physically next tid */
 
-       *b = RelationGetBufferWithBuffer(relation, page, *b);
+       *buf = RelationGetBufferWithBuffer(relation, page, *buf);
 #ifndef NO_BUFFERISVALID
-       if (!BufferIsValid(*b))
+       if (!BufferIsValid(*buf))
            elog(ERROR, "heapgettup: failed ReadBuffer");
 #endif
 
-       dp = (Page) BufferGetPage(*b);
+       dp = (Page) BufferGetPage(*buf);
        lines = PageGetMaxOffsetNumber(dp);
    }
 
@@ -401,7 +406,7 @@ heapgettup(Relation relation,
             *  if current tuple qualifies, return it.
             * ----------------
             */
-           HeapTupleSatisfies(lpp, relation, *b, (PageHeader) dp,
+           HeapTupleSatisfies(lpp, relation, *buf, (PageHeader) dp,
                               snapshot, nkeys, key, rtup);
            if (rtup != NULL)
            {
@@ -409,7 +414,6 @@ heapgettup(Relation relation,
 
                if (ItemPointerGetBlockNumber(iptr) != page)
                {
-
                    /*
                     * set block id to the correct page number --- this is
                     * a hack to support the virtual fragment concept
@@ -448,19 +452,19 @@ heapgettup(Relation relation,
         */
        if (page < 0 || page >= pages)
        {
-           if (BufferIsValid(*b))
-               ReleaseBuffer(*b);
-           *b = InvalidBuffer;
+           if (BufferIsValid(*buf))
+               ReleaseBuffer(*buf);
+           *buf = InvalidBuffer;
            return (NULL);
        }
 
-       *b = ReleaseAndReadBuffer(*b, relation, page);
+       *buf = ReleaseAndReadBuffer(*buf, relation, page);
 
 #ifndef NO_BUFFERISVALID
-       if (!BufferIsValid(*b))
+       if (!BufferIsValid(*buf))
            elog(ERROR, "heapgettup: failed ReadBuffer");
 #endif
-       dp = (Page) BufferGetPage(*b);
+       dp = (Page) BufferGetPage(*buf);
        lines = lineoff = PageGetMaxOffsetNumber((Page) dp);
        linesleft = lines - 1;
        if (dir < 0)
@@ -584,7 +588,7 @@ heap_beginscan(Relation relation,
               unsigned nkeys,
               ScanKey key)
 {
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
 
    /* ----------------
     *  increment access statistics
@@ -620,29 +624,29 @@ heap_beginscan(Relation relation,
     *  allocate and initialize scan descriptor
     * ----------------
     */
-   sdesc = (HeapScanDesc) palloc(sizeof(HeapScanDescData));
+   scan = (HeapScanDesc) palloc(sizeof(HeapScanDescData));
 
    relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation);
-   sdesc->rs_rd = relation;
+   scan->rs_rd = relation;
 
    if (nkeys)
 
        /*
-        * we do this here instead of in initsdesc() because heap_rescan
-        * also calls initsdesc() and we don't want to allocate memory
+        * we do this here instead of in initscan() because heap_rescan
+        * also calls initscan() and we don't want to allocate memory
         * again
         */
-       sdesc->rs_key = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys);
+       scan->rs_key = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys);
    else
-       sdesc->rs_key = NULL;
+       scan->rs_key = NULL;
 
-   initsdesc(sdesc, relation, atend, nkeys, key);
+   initscan(scan, relation, atend, nkeys, key);
 
-   sdesc->rs_atend = atend;
-   sdesc->rs_snapshot = snapshot;
-   sdesc->rs_nkeys = (short) nkeys;
+   scan->rs_atend = atend;
+   scan->rs_snapshot = snapshot;
+   scan->rs_nkeys = (short) nkeys;
 
-   return (sdesc);
+   return (scan);
 }
 
 /* ----------------
@@ -650,7 +654,7 @@ heap_beginscan(Relation relation,
  * ----------------
  */
 void
-heap_rescan(HeapScanDesc sdesc,
+heap_rescan(HeapScanDesc scan,
            bool scanFromEnd,
            ScanKey key)
 {
@@ -667,14 +671,14 @@ heap_rescan(HeapScanDesc sdesc,
     *  unpin scan buffers
     * ----------------
     */
-   unpinsdesc(sdesc);
+   unpinscan(scan);
 
    /* ----------------
     *  reinitialize scan descriptor
     * ----------------
     */
-   initsdesc(sdesc, sdesc->rs_rd, scanFromEnd, sdesc->rs_nkeys, key);
-   sdesc->rs_atend = (bool) scanFromEnd;
+   initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
+   scan->rs_atend = (bool) scanFromEnd;
 }
 
 /* ----------------
@@ -685,7 +689,7 @@ heap_rescan(HeapScanDesc sdesc,
  * ----------------
  */
 void
-heap_endscan(HeapScanDesc sdesc)
+heap_endscan(HeapScanDesc scan)
 {
    /* ----------------
     *  increment access statistics
@@ -700,36 +704,38 @@ heap_endscan(HeapScanDesc sdesc)
     *  unpin scan buffers
     * ----------------
     */
-   unpinsdesc(sdesc);
+   unpinscan(scan);
 
    /* ----------------
     *  decrement relation reference count and free scan descriptor storage
     * ----------------
     */
-   RelationDecrementReferenceCount(sdesc->rs_rd);
+   RelationDecrementReferenceCount(scan->rs_rd);
 
    /* ----------------
     * Non 2-phase read locks on catalog relations
     * ----------------
     */
-   if (IsSystemRelationName(RelationGetRelationName(sdesc->rs_rd)->data))
+   if (IsSystemRelationName(RelationGetRelationName(scan->rs_rd)->data))
 
-       RelationUnsetLockForRead(sdesc->rs_rd);
+       RelationUnsetLockForRead(scan->rs_rd);
 
-   pfree(sdesc);               /* XXX */
+   pfree(scan);                /* XXX */
 }
 
 /* ----------------
  *     heap_getnext    - retrieve next tuple in scan
  *
  *     Fix to work with index relations.
+ *     We don't return the buffer anymore, but you can get it from the
+ *     returned HeapTuple.
  * ----------------
  */
 
 #ifdef HEAPDEBUGALL
 #define HEAPDEBUG_1 \
-elog(DEBUG, "heap_getnext([%s,nkeys=%d],backw=%d,0x%x) called", \
-    sdesc->rs_rd->rd_rel->relname.data, sdesc->rs_nkeys, backw, b)
+elog(DEBUG, "heap_getnext([%s,nkeys=%d],backw=%d) called", \
+    scan->rs_rd->rd_rel->relname.data, scan->rs_nkeys, backw)
 
 #define HEAPDEBUG_2 \
     elog(DEBUG, "heap_getnext called with backw (no tracing yet)")
@@ -760,12 +766,9 @@ elog(DEBUG, "heap_getnext([%s,nkeys=%d],backw=%d,0x%x) called", \
 
 
 HeapTuple
-heap_getnext(HeapScanDesc scandesc,
-            int backw,
-            Buffer *b)
+heap_getnext(HeapScanDesc scandesc, int backw)
 {
-   HeapScanDesc sdesc = scandesc;
-   Buffer      localb;
+   HeapScanDesc scan = scandesc;
 
    /* ----------------
     *  increment access statistics
@@ -780,16 +783,13 @@ heap_getnext(HeapScanDesc scandesc,
     *  argument checks
     * ----------------
     */
-   if (sdesc == NULL)
+   if (scan == NULL)
        elog(ERROR, "heap_getnext: NULL relscan");
 
    /* ----------------
     *  initialize return buffer to InvalidBuffer
     * ----------------
     */
-   if (!PointerIsValid(b))
-       b = &localb;
-   (*b) = InvalidBuffer;
 
    HEAPDEBUG_1;                /* heap_getnext( info ) */
 
@@ -801,11 +801,11 @@ heap_getnext(HeapScanDesc scandesc,
         */
        HEAPDEBUG_2;            /* heap_getnext called with backw */
 
-       if (sdesc->rs_ptup == sdesc->rs_ctup &&
-           BufferIsInvalid(sdesc->rs_pbuf))
+       if (scan->rs_ptup == scan->rs_ctup &&
+           BufferIsInvalid(scan->rs_pbuf))
        {
-           if (BufferIsValid(sdesc->rs_nbuf))
-               ReleaseBuffer(sdesc->rs_nbuf);
+           if (BufferIsValid(scan->rs_nbuf))
+               ReleaseBuffer(scan->rs_nbuf);
            return (NULL);
        }
 
@@ -813,37 +813,37 @@ heap_getnext(HeapScanDesc scandesc,
         * Copy the "current" tuple/buffer to "next". Pin/unpin the
         * buffers accordingly
         */
-       if (sdesc->rs_nbuf != sdesc->rs_cbuf)
+       if (scan->rs_nbuf != scan->rs_cbuf)
        {
-           if (BufferIsValid(sdesc->rs_nbuf))
-               ReleaseBuffer(sdesc->rs_nbuf);
-           if (BufferIsValid(sdesc->rs_cbuf))
-               IncrBufferRefCount(sdesc->rs_cbuf);
+           if (BufferIsValid(scan->rs_nbuf))
+               ReleaseBuffer(scan->rs_nbuf);
+           if (BufferIsValid(scan->rs_cbuf))
+               IncrBufferRefCount(scan->rs_cbuf);
        }
-       sdesc->rs_ntup = sdesc->rs_ctup;
-       sdesc->rs_nbuf = sdesc->rs_cbuf;
+       scan->rs_ntup = scan->rs_ctup;
+       scan->rs_nbuf = scan->rs_cbuf;
 
-       if (sdesc->rs_ptup != NULL)
+       if (scan->rs_ptup != NULL)
        {
-           if (sdesc->rs_cbuf != sdesc->rs_pbuf)
+           if (scan->rs_cbuf != scan->rs_pbuf)
            {
-               if (BufferIsValid(sdesc->rs_cbuf))
-                   ReleaseBuffer(sdesc->rs_cbuf);
-               if (BufferIsValid(sdesc->rs_pbuf))
-                   IncrBufferRefCount(sdesc->rs_pbuf);
+               if (BufferIsValid(scan->rs_cbuf))
+                   ReleaseBuffer(scan->rs_cbuf);
+               if (BufferIsValid(scan->rs_pbuf))
+                   IncrBufferRefCount(scan->rs_pbuf);
            }
-           sdesc->rs_ctup = sdesc->rs_ptup;
-           sdesc->rs_cbuf = sdesc->rs_pbuf;
+           scan->rs_ctup = scan->rs_ptup;
+           scan->rs_cbuf = scan->rs_pbuf;
        }
        else
        {                       /* NONTUP */
            ItemPointer iptr;
 
-           iptr = (sdesc->rs_ctup != NULL) ?
-               &(sdesc->rs_ctup->t_ctid) : (ItemPointer) NULL;
+           iptr = (scan->rs_ctup != NULL) ?
+               &(scan->rs_ctup->t_ctid) : (ItemPointer) NULL;
 
            /*
-            * Don't release sdesc->rs_cbuf at this point, because
+            * Don't release scan->rs_cbuf at this point, because
             * heapgettup doesn't increase PrivateRefCount if it is
             * already set. On a backward scan, both rs_ctup and rs_ntup
             * usually point to the same buffer page, so
@@ -851,33 +851,33 @@ heap_getnext(HeapScanDesc scandesc,
             * instance ctup is stored in a TupleTableSlot).  - 01/09/94
             */
 
-           sdesc->rs_ctup = (HeapTuple)
-               heapgettup(sdesc->rs_rd,
+           scan->rs_ctup = (HeapTuple)
+               heapgettup(scan->rs_rd,
                           iptr,
                           -1,
-                          &(sdesc->rs_cbuf),
-                          sdesc->rs_snapshot,
-                          sdesc->rs_nkeys,
-                          sdesc->rs_key);
+                          &(scan->rs_cbuf),
+                          scan->rs_snapshot,
+                          scan->rs_nkeys,
+                          scan->rs_key);
        }
 
-       if (sdesc->rs_ctup == NULL && !BufferIsValid(sdesc->rs_cbuf))
+       if (scan->rs_ctup == NULL && !BufferIsValid(scan->rs_cbuf))
        {
-           if (BufferIsValid(sdesc->rs_pbuf))
-               ReleaseBuffer(sdesc->rs_pbuf);
-           sdesc->rs_ptup = NULL;
-           sdesc->rs_pbuf = InvalidBuffer;
-           if (BufferIsValid(sdesc->rs_nbuf))
-               ReleaseBuffer(sdesc->rs_nbuf);
-           sdesc->rs_ntup = NULL;
-           sdesc->rs_nbuf = InvalidBuffer;
+           if (BufferIsValid(scan->rs_pbuf))
+               ReleaseBuffer(scan->rs_pbuf);
+           scan->rs_ptup = NULL;
+           scan->rs_pbuf = InvalidBuffer;
+           if (BufferIsValid(scan->rs_nbuf))
+               ReleaseBuffer(scan->rs_nbuf);
+           scan->rs_ntup = NULL;
+           scan->rs_nbuf = InvalidBuffer;
            return (NULL);
        }
 
-       if (BufferIsValid(sdesc->rs_pbuf))
-           ReleaseBuffer(sdesc->rs_pbuf);
-       sdesc->rs_ptup = NULL;
-       sdesc->rs_pbuf = UnknownBuffer;
+       if (BufferIsValid(scan->rs_pbuf))
+           ReleaseBuffer(scan->rs_pbuf);
+       scan->rs_ptup = NULL;
+       scan->rs_pbuf = UnknownBuffer;
 
    }
    else
@@ -886,11 +886,11 @@ heap_getnext(HeapScanDesc scandesc,
         *  handle forward scan
         * ----------------
         */
-       if (sdesc->rs_ctup == sdesc->rs_ntup &&
-           BufferIsInvalid(sdesc->rs_nbuf))
+       if (scan->rs_ctup == scan->rs_ntup &&
+           BufferIsInvalid(scan->rs_nbuf))
        {
-           if (BufferIsValid(sdesc->rs_pbuf))
-               ReleaseBuffer(sdesc->rs_pbuf);
+           if (BufferIsValid(scan->rs_pbuf))
+               ReleaseBuffer(scan->rs_pbuf);
            HEAPDEBUG_3;        /* heap_getnext returns NULL at end */
            return (NULL);
        }
@@ -899,38 +899,38 @@ heap_getnext(HeapScanDesc scandesc,
         * Copy the "current" tuple/buffer to "previous". Pin/unpin the
         * buffers accordingly
         */
-       if (sdesc->rs_pbuf != sdesc->rs_cbuf)
+       if (scan->rs_pbuf != scan->rs_cbuf)
        {
-           if (BufferIsValid(sdesc->rs_pbuf))
-               ReleaseBuffer(sdesc->rs_pbuf);
-           if (BufferIsValid(sdesc->rs_cbuf))
-               IncrBufferRefCount(sdesc->rs_cbuf);
+           if (BufferIsValid(scan->rs_pbuf))
+               ReleaseBuffer(scan->rs_pbuf);
+           if (BufferIsValid(scan->rs_cbuf))
+               IncrBufferRefCount(scan->rs_cbuf);
        }
-       sdesc->rs_ptup = sdesc->rs_ctup;
-       sdesc->rs_pbuf = sdesc->rs_cbuf;
+       scan->rs_ptup = scan->rs_ctup;
+       scan->rs_pbuf = scan->rs_cbuf;
 
-       if (sdesc->rs_ntup != NULL)
+       if (scan->rs_ntup != NULL)
        {
-           if (sdesc->rs_cbuf != sdesc->rs_nbuf)
+           if (scan->rs_cbuf != scan->rs_nbuf)
            {
-               if (BufferIsValid(sdesc->rs_cbuf))
-                   ReleaseBuffer(sdesc->rs_cbuf);
-               if (BufferIsValid(sdesc->rs_nbuf))
-                   IncrBufferRefCount(sdesc->rs_nbuf);
+               if (BufferIsValid(scan->rs_cbuf))
+                   ReleaseBuffer(scan->rs_cbuf);
+               if (BufferIsValid(scan->rs_nbuf))
+                   IncrBufferRefCount(scan->rs_nbuf);
            }
-           sdesc->rs_ctup = sdesc->rs_ntup;
-           sdesc->rs_cbuf = sdesc->rs_nbuf;
+           scan->rs_ctup = scan->rs_ntup;
+           scan->rs_cbuf = scan->rs_nbuf;
            HEAPDEBUG_5;        /* heap_getnext next tuple was cached */
        }
        else
        {                       /* NONTUP */
            ItemPointer iptr;
 
-           iptr = (sdesc->rs_ctup != NULL) ?
-               &sdesc->rs_ctup->t_ctid : (ItemPointer) NULL;
+           iptr = (scan->rs_ctup != NULL) ?
+               &scan->rs_ctup->t_ctid : (ItemPointer) NULL;
 
            /*
-            * Don't release sdesc->rs_cbuf at this point, because
+            * Don't release scan->rs_cbuf at this point, because
             * heapgettup doesn't increase PrivateRefCount if it is
             * already set. On a forward scan, both rs_ctup and rs_ptup
             * usually point to the same buffer page, so
@@ -938,34 +938,34 @@ heap_getnext(HeapScanDesc scandesc,
             * instance ctup is stored in a TupleTableSlot).  - 01/09/93
             */
 
-           sdesc->rs_ctup = (HeapTuple)
-               heapgettup(sdesc->rs_rd,
+           scan->rs_ctup = (HeapTuple)
+               heapgettup(scan->rs_rd,
                           iptr,
                           1,
-                          &sdesc->rs_cbuf,
-                          sdesc->rs_snapshot,
-                          sdesc->rs_nkeys,
-                          sdesc->rs_key);
+                          &scan->rs_cbuf,
+                          scan->rs_snapshot,
+                          scan->rs_nkeys,
+                          scan->rs_key);
        }
 
-       if (sdesc->rs_ctup == NULL && !BufferIsValid(sdesc->rs_cbuf))
+       if (scan->rs_ctup == NULL && !BufferIsValid(scan->rs_cbuf))
        {
-           if (BufferIsValid(sdesc->rs_nbuf))
-               ReleaseBuffer(sdesc->rs_nbuf);
-           sdesc->rs_ntup = NULL;
-           sdesc->rs_nbuf = InvalidBuffer;
-           if (BufferIsValid(sdesc->rs_pbuf))
-               ReleaseBuffer(sdesc->rs_pbuf);
-           sdesc->rs_ptup = NULL;
-           sdesc->rs_pbuf = InvalidBuffer;
+           if (BufferIsValid(scan->rs_nbuf))
+               ReleaseBuffer(scan->rs_nbuf);
+           scan->rs_ntup = NULL;
+           scan->rs_nbuf = InvalidBuffer;
+           if (BufferIsValid(scan->rs_pbuf))
+               ReleaseBuffer(scan->rs_pbuf);
+           scan->rs_ptup = NULL;
+           scan->rs_pbuf = InvalidBuffer;
            HEAPDEBUG_6;        /* heap_getnext returning EOS */
            return (NULL);
        }
 
-       if (BufferIsValid(sdesc->rs_nbuf))
-           ReleaseBuffer(sdesc->rs_nbuf);
-       sdesc->rs_ntup = NULL;
-       sdesc->rs_nbuf = UnknownBuffer;
+       if (BufferIsValid(scan->rs_nbuf))
+           ReleaseBuffer(scan->rs_nbuf);
+       scan->rs_ntup = NULL;
+       scan->rs_nbuf = UnknownBuffer;
    }
 
    /* ----------------
@@ -973,24 +973,31 @@ heap_getnext(HeapScanDesc scandesc,
     *  point to the proper return buffer and return the tuple.
     * ----------------
     */
-   (*b) = sdesc->rs_cbuf;
 
    HEAPDEBUG_7;                /* heap_getnext returning tuple */
 
-   return (sdesc->rs_ctup);
+   return scan->rs_ctup;
 }
 
 /* ----------------
  *     heap_fetch      - retrive tuple with tid
  *
  *     Currently ignores LP_IVALID during processing!
+ *
+ *     Because this is not part of a scan, there is no way to
+ *     automatically lock/unlock the shared buffers.
+ *     For this reason, we require that the user retrieve the buffer
+ *     value, and they are required to BuffferRelease() it when they
+ *     are done.  If they want to make a copy of it before releasing it,
+ *     they can call heap_copytyple().
  * ----------------
  */
 HeapTuple
 heap_fetch(Relation relation,
           Snapshot snapshot,
           ItemPointer tid,
-          Buffer *b)
+          Buffer *userbuf)
 {
    ItemId      lp;
    Buffer      buffer;
@@ -998,6 +1005,8 @@ heap_fetch(Relation relation,
    HeapTuple   tuple;
    OffsetNumber offnum;
 
+   AssertMacro(PointerIsValid(userbuf));   /* see comments above */
+   
    /* ----------------
     *  increment access statistics
     * ----------------
@@ -1061,17 +1070,12 @@ heap_fetch(Relation relation,
    /* ----------------
     *  all checks passed, now either return a copy of the tuple
     *  or pin the buffer page and return a pointer, depending on
-    *  whether caller gave us a valid b.
+    *  whether caller gave us a valid buf.
     * ----------------
     */
 
-   if (PointerIsValid(b))
-       *b = buffer;
-   else
-   {
-       tuple = heap_copytuple(tuple);
-       ReleaseBuffer(buffer);
-   }
+   *userbuf = buffer;  /* user is required to ReleaseBuffer() this */
+
    return (tuple);
 }
 
@@ -1161,7 +1165,7 @@ heap_delete(Relation relation, ItemPointer tid)
    ItemId      lp;
    HeapTuple   tp;
    PageHeader  dp;
-   Buffer      b;
+   Buffer      buf;
 
    /* ----------------
     *  increment access statistics
@@ -1182,16 +1186,16 @@ heap_delete(Relation relation, ItemPointer tid)
     */
    RelationSetLockForWrite(relation);
 
-   b = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
+   buf = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
 
 #ifndef NO_BUFFERISVALID
-   if (!BufferIsValid(b))
+   if (!BufferIsValid(buf))
    {                           /* XXX L_SH better ??? */
        elog(ERROR, "heap_delete: failed ReadBuffer");
    }
 #endif                         /* NO_BUFFERISVALID */
 
-   dp = (PageHeader) BufferGetPage(b);
+   dp = (PageHeader) BufferGetPage(buf);
    lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
 
    /*
@@ -1208,20 +1212,20 @@ heap_delete(Relation relation, ItemPointer tid)
        */
        if (IsSystemRelationName(RelationGetRelationName(relation)->data))
            RelationUnsetLockForWrite(relation);
-       ReleaseBuffer(b);
+       ReleaseBuffer(buf);
        return (1);
    }
    /* ----------------
     *  check that we're deleteing a valid item
     * ----------------
     */
-   HeapTupleSatisfies(lp, relation, b, dp,
+   HeapTupleSatisfies(lp, relation, buf, dp,
                       false, 0, (ScanKey) NULL, tp);
    if (!tp)
    {
 
        /* XXX call something else */
-       ReleaseBuffer(b);
+       ReleaseBuffer(buf);
 
        elog(ERROR, "heap_delete: (am)invalid tid");
    }
@@ -1248,7 +1252,7 @@ heap_delete(Relation relation, ItemPointer tid)
    RelationInvalidateHeapTuple(relation, tp);
    SetRefreshWhenInvalidate((bool) !ImmediateInvalidation);
 
-   WriteBuffer(b);
+   WriteBuffer(buf);
    if (IsSystemRelationName(RelationGetRelationName(relation)->data))
        RelationUnsetLockForWrite(relation);
 
@@ -1426,7 +1430,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
  * ----------------
  */
 void
-heap_markpos(HeapScanDesc sdesc)
+heap_markpos(HeapScanDesc scan)
 {
 
    /* ----------------
@@ -1438,50 +1442,50 @@ heap_markpos(HeapScanDesc sdesc)
 
    /* Note: no locking manipulations needed */
 
-   if (sdesc->rs_ptup == NULL &&
-       BufferIsUnknown(sdesc->rs_pbuf))
+   if (scan->rs_ptup == NULL &&
+       BufferIsUnknown(scan->rs_pbuf))
    {                           /* == NONTUP */
-       sdesc->rs_ptup = (HeapTuple)
-           heapgettup(sdesc->rs_rd,
-                      (sdesc->rs_ctup == NULL) ?
-                      (ItemPointer) NULL : &sdesc->rs_ctup->t_ctid,
+       scan->rs_ptup = (HeapTuple)
+           heapgettup(scan->rs_rd,
+                      (scan->rs_ctup == NULL) ?
+                      (ItemPointer) NULL : &scan->rs_ctup->t_ctid,
                       -1,
-                      &sdesc->rs_pbuf,
-                      sdesc->rs_snapshot,
-                      sdesc->rs_nkeys,
-                      sdesc->rs_key);
+                      &scan->rs_pbuf,
+                      scan->rs_snapshot,
+                      scan->rs_nkeys,
+                      scan->rs_key);
 
    }
-   else if (sdesc->rs_ntup == NULL &&
-            BufferIsUnknown(sdesc->rs_nbuf))
+   else if (scan->rs_ntup == NULL &&
+            BufferIsUnknown(scan->rs_nbuf))
    {                           /* == NONTUP */
-       sdesc->rs_ntup = (HeapTuple)
-           heapgettup(sdesc->rs_rd,
-                      (sdesc->rs_ctup == NULL) ?
-                      (ItemPointer) NULL : &sdesc->rs_ctup->t_ctid,
+       scan->rs_ntup = (HeapTuple)
+           heapgettup(scan->rs_rd,
+                      (scan->rs_ctup == NULL) ?
+                      (ItemPointer) NULL : &scan->rs_ctup->t_ctid,
                       1,
-                      &sdesc->rs_nbuf,
-                      sdesc->rs_snapshot,
-                      sdesc->rs_nkeys,
-                      sdesc->rs_key);
+                      &scan->rs_nbuf,
+                      scan->rs_snapshot,
+                      scan->rs_nkeys,
+                      scan->rs_key);
    }
 
    /* ----------------
     * Should not unpin the buffer pages.  They may still be in use.
     * ----------------
     */
-   if (sdesc->rs_ptup != NULL)
-       sdesc->rs_mptid = sdesc->rs_ptup->t_ctid;
+   if (scan->rs_ptup != NULL)
+       scan->rs_mptid = scan->rs_ptup->t_ctid;
    else
-       ItemPointerSetInvalid(&sdesc->rs_mptid);
-   if (sdesc->rs_ctup != NULL)
-       sdesc->rs_mctid = sdesc->rs_ctup->t_ctid;
+       ItemPointerSetInvalid(&scan->rs_mptid);
+   if (scan->rs_ctup != NULL)
+       scan->rs_mctid = scan->rs_ctup->t_ctid;
    else
-       ItemPointerSetInvalid(&sdesc->rs_mctid);
-   if (sdesc->rs_ntup != NULL)
-       sdesc->rs_mntid = sdesc->rs_ntup->t_ctid;
+       ItemPointerSetInvalid(&scan->rs_mctid);
+   if (scan->rs_ntup != NULL)
+       scan->rs_mntid = scan->rs_ntup->t_ctid;
    else
-       ItemPointerSetInvalid(&sdesc->rs_mntid);
+       ItemPointerSetInvalid(&scan->rs_mntid);
 }
 
 /* ----------------
@@ -1506,7 +1510,7 @@ heap_markpos(HeapScanDesc sdesc)
  * ----------------
  */
 void
-heap_restrpos(HeapScanDesc sdesc)
+heap_restrpos(HeapScanDesc scan)
 {
    /* ----------------
     *  increment access statistics
@@ -1519,50 +1523,50 @@ heap_restrpos(HeapScanDesc sdesc)
 
    /* Note: no locking manipulations needed */
 
-   unpinsdesc(sdesc);
+   unpinscan(scan);
 
    /* force heapgettup to pin buffer for each loaded tuple */
-   sdesc->rs_pbuf = InvalidBuffer;
-   sdesc->rs_cbuf = InvalidBuffer;
-   sdesc->rs_nbuf = InvalidBuffer;
+   scan->rs_pbuf = InvalidBuffer;
+   scan->rs_cbuf = InvalidBuffer;
+   scan->rs_nbuf = InvalidBuffer;
 
-   if (!ItemPointerIsValid(&sdesc->rs_mptid))
-       sdesc->rs_ptup = NULL;
+   if (!ItemPointerIsValid(&scan->rs_mptid))
+       scan->rs_ptup = NULL;
    else
    {
-       sdesc->rs_ptup = (HeapTuple)
-           heapgettup(sdesc->rs_rd,
-                      &sdesc->rs_mptid,
+       scan->rs_ptup = (HeapTuple)
+           heapgettup(scan->rs_rd,
+                      &scan->rs_mptid,
                       0,
-                      &sdesc->rs_pbuf,
+                      &scan->rs_pbuf,
                       false,
                       0,
                       (ScanKey) NULL);
    }
 
-   if (!ItemPointerIsValid(&sdesc->rs_mctid))
-       sdesc->rs_ctup = NULL;
+   if (!ItemPointerIsValid(&scan->rs_mctid))
+       scan->rs_ctup = NULL;
    else
    {
-       sdesc->rs_ctup = (HeapTuple)
-           heapgettup(sdesc->rs_rd,
-                      &sdesc->rs_mctid,
+       scan->rs_ctup = (HeapTuple)
+           heapgettup(scan->rs_rd,
+                      &scan->rs_mctid,
                       0,
-                      &sdesc->rs_cbuf,
+                      &scan->rs_cbuf,
                       false,
                       0,
                       (ScanKey) NULL);
    }
 
-   if (!ItemPointerIsValid(&sdesc->rs_mntid))
-       sdesc->rs_ntup = NULL;
+   if (!ItemPointerIsValid(&scan->rs_mntid))
+       scan->rs_ntup = NULL;
    else
    {
-       sdesc->rs_ntup = (HeapTuple)
-           heapgettup(sdesc->rs_rd,
-                      &sdesc->rs_mntid,
+       scan->rs_ntup = (HeapTuple)
+           heapgettup(scan->rs_rd,
+                      &scan->rs_mntid,
                       0,
-                      &sdesc->rs_nbuf,
+                      &scan->rs_nbuf,
                       false,
                       0,
                       (ScanKey) NULL);
index 229ca5d1a270a0c4b4decd1b09292ca5c8a865ab..59e2cb1b546d6245790009688407121a575c3a66 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.12 1998/06/15 19:27:53 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.13 1998/08/19 02:01:09 momjian Exp $
  *
  * NOTES
  *   many of the old access method routines have been turned into
@@ -216,14 +216,15 @@ IndexScanMarkPosition(IndexScanDesc scan)
 
    if (scan->flags & ScanUncheckedPrevious)
    {
-       result =
-           index_getnext(scan, BackwardScanDirection);
+       result = index_getnext(scan, BackwardScanDirection);
 
        if (result != NULL)
+       {
            scan->previousItemData = result->index_iptr;
+           pfree(result);
+       }
        else
            ItemPointerSetInvalid(&scan->previousItemData);
-
    }
    else if (scan->flags & ScanUncheckedNext)
    {
@@ -231,7 +232,10 @@ IndexScanMarkPosition(IndexScanDesc scan)
            index_getnext(scan, ForwardScanDirection);
 
        if (result != NULL)
+       {
            scan->nextItemData = result->index_iptr;
+           pfree(result);
+       }
        else
            ItemPointerSetInvalid(&scan->nextItemData);
    }
index e6af2ff9e6a536cf2d73f2753c26dd393ed887f6..3f3721341ac5eac5a370f125973d8522b1484343 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.22 1998/06/15 18:39:23 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.23 1998/08/19 02:01:10 momjian Exp $
  *
  * INTERFACE ROUTINES
  *     index_open      - open an index relation by relationId
@@ -331,8 +331,7 @@ index_getnext(IndexScanDesc scan,
     *  have the am's gettuple proc do all the work.
     * ----------------
     */
-   result = (RetrieveIndexResult)
-       fmgr(procedure, scan, direction);
+   result = (RetrieveIndexResult)fmgr(procedure, scan, direction);
 
    return result;
 }
@@ -376,8 +375,7 @@ GetIndexValue(HeapTuple tuple,
              int attOff,
              AttrNumber attrNums[],
              FuncIndexInfo *fInfo,
-             bool *attNull,
-             Buffer buffer)
+             bool *attNull)
 {
    Datum       returnVal;
    bool        isNull;
index 480644857ce56485874bf76eab6fb8d8eb955fbd..b4c6117069a6cfaa041b86f41e040843e8835b78 100644 (file)
@@ -8,13 +8,14 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.25 1998/08/11 22:39:32 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.26 1998/08/19 02:01:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "postgres.h"
 
+#include "miscadmin.h"
 #include "access/heapam.h"
 #include "access/istrat.h"
 #include "catalog/catname.h"
@@ -22,6 +23,7 @@
 #include "catalog/pg_amproc.h"
 #include "catalog/pg_index.h"
 #include "catalog/pg_operator.h"
+#include "utils/syscache.h"
 #include "fmgr.h"
 #include "utils/memutils.h"        /* could have been access/itup.h */
 
@@ -30,8 +32,7 @@ static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation);
 static bool
 StrategyExpressionIsValid(StrategyExpression expression,
                          StrategyNumber maxStrategy);
-static ScanKey
-StrategyMapGetScanKeyEntry(StrategyMap map,
+static ScanKey StrategyMapGetScanKeyEntry(StrategyMap map,
                           StrategyNumber strategyNumber);
 static bool
 StrategyOperatorIsValid(StrategyOperator operator,
@@ -95,8 +96,7 @@ IndexStrategyGetStrategyMap(IndexStrategy indexStrategy,
    Assert(AttributeNumberIsValid(attrNum));
 
    maxStrategyNum = AMStrategies(maxStrategyNum);      /* XXX */
-   return
-       &indexStrategy->strategyMapData[maxStrategyNum * (attrNum - 1)];
+   return &indexStrategy->strategyMapData[maxStrategyNum * (attrNum - 1)];
 }
 
 /*
@@ -108,8 +108,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber,
                                    StrategyNumber maxStrategyNumber)
 {
    maxStrategyNumber = AMStrategies(maxStrategyNumber);        /* XXX */
-   return
-       maxAttributeNumber * maxStrategyNumber * sizeof(ScanKeyData);
+   return maxAttributeNumber * maxStrategyNumber * sizeof(ScanKeyData);
 }
 
 #ifdef USE_ASSERT_CHECKING
@@ -483,39 +482,52 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
                                 Oid operatorObjectId,
                                 ScanKey entry)
 {
-   HeapScanDesc scan;
-   ScanKeyData scanKeyData;
    HeapTuple   tuple;
+   HeapScanDesc scan = NULL;
 
-   ScanKeyEntryInitialize(&scanKeyData, 0,
-                          ObjectIdAttributeNumber,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(operatorObjectId));
+   if (!IsBootstrapProcessingMode())
+   {
+       tuple = SearchSysCacheTuple(OPROID,
+                                   ObjectIdGetDatum(operatorObjectId),
+                                   0, 0, 0);
+   }
+   else
+   {
+       ScanKeyData scanKeyData;
+   
+       ScanKeyEntryInitialize(&scanKeyData, 0,
+                              ObjectIdAttributeNumber,
+                              F_OIDEQ,
+                              ObjectIdGetDatum(operatorObjectId));
 
-   scan = heap_beginscan(operatorRelation, false, SnapshotNow,
-                         1, &scanKeyData);
+       scan = heap_beginscan(operatorRelation, false, SnapshotNow,
+                             1, &scanKeyData);
+   
+       tuple = heap_getnext(scan, 0);
+   }
 
-   tuple = heap_getnext(scan, false, (Buffer *) NULL);
    if (!HeapTupleIsValid(tuple))
    {
+       if (IsBootstrapProcessingMode())
+           heap_endscan(scan);
        elog(ERROR, "OperatorObjectIdFillScanKeyEntry: unknown operator %lu",
             (uint32) operatorObjectId);
    }
 
    entry->sk_flags = 0;
-   entry->sk_procedure =
-       ((OperatorTupleForm) GETSTRUCT(tuple))->oprcode;
+   entry->sk_procedure = ((OperatorTupleForm) GETSTRUCT(tuple))->oprcode;
    fmgr_info(entry->sk_procedure, &entry->sk_func);
    entry->sk_nargs = entry->sk_func.fn_nargs;
 
+   if (IsBootstrapProcessingMode())
+       heap_endscan(scan);
+   
    if (!RegProcedureIsValid(entry->sk_procedure))
    {
        elog(ERROR,
        "OperatorObjectIdFillScanKeyEntry: no procedure for operator %lu",
             (uint32) operatorObjectId);
    }
-
-   heap_endscan(scan);
 }
 
 
@@ -532,28 +544,38 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
                       StrategyNumber maxSupportNumber,
                       AttrNumber maxAttributeNumber)
 {
-   Relation    relation;
+   Relation    relation = NULL;
+   HeapScanDesc scan = NULL;
+   ScanKeyData entry[2];
    Relation    operatorRelation;
-   HeapScanDesc scan;
    HeapTuple   tuple;
-   ScanKeyData entry[2];
    StrategyMap map;
    AttrNumber  attributeNumber;
    int         attributeIndex;
    Oid         operatorClassObjectId[MaxIndexAttributeNumber];
 
-   maxStrategyNumber = AMStrategies(maxStrategyNumber);
-
-   ScanKeyEntryInitialize(&entry[0], 0, Anum_pg_index_indexrelid,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(indexObjectId));
+   if (!IsBootstrapProcessingMode())
+   {
+       tuple = SearchSysCacheTuple(INDEXRELID,
+                                   ObjectIdGetDatum(indexObjectId),
+                                   0, 0, 0);
+   }
+   else
+   {
+       ScanKeyEntryInitialize(&entry[0], 0, Anum_pg_index_indexrelid,
+                              F_OIDEQ,
+                              ObjectIdGetDatum(indexObjectId));
+   
+       relation = heap_openr(IndexRelationName);
+       scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
+       tuple = heap_getnext(scan, 0);
+   }
 
-   relation = heap_openr(IndexRelationName);
-   scan = heap_beginscan(relation, false, SnapshotNow, 1, entry);
-   tuple = heap_getnext(scan, 0, (Buffer *) NULL);
    if (!HeapTupleIsValid(tuple))
        elog(ERROR, "IndexSupportInitialize: corrupted catalogs");
 
+   maxStrategyNumber = AMStrategies(maxStrategyNumber);
+
    /*
     * XXX note that the following assumes the INDEX tuple is well formed
     * and that the key[] and class[] are 0 terminated.
@@ -574,9 +596,12 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
        operatorClassObjectId[attributeIndex] = iform->indclass[attributeIndex];
    }
 
-   heap_endscan(scan);
-   heap_close(relation);
-
+   if (IsBootstrapProcessingMode())
+   {
+       heap_endscan(scan);
+       heap_close(relation);
+   }
+   
    /* if support routines exist for this access method, load them */
    if (maxSupportNumber > 0)
    {
@@ -606,8 +631,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
 
            scan = heap_beginscan(relation, false, SnapshotNow, 2, entry);
 
-           while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
-                  HeapTupleIsValid(tuple))
+           while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
            {
                form = (Form_pg_amproc) GETSTRUCT(tuple);
                loc[(form->amprocnum - 1)] = form->amproc;
@@ -647,8 +671,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
 
        scan = heap_beginscan(relation, false, SnapshotNow, 2, entry);
 
-       while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
-              HeapTupleIsValid(tuple))
+       while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
        {
            Form_pg_amop form;
 
index 43a09be03efae816bc1e485801fd0ef4b7ee3082..45ec7b241deb54ee53ff4af8d7b6a84d8947d031 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.16 1998/04/26 04:05:19 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.17 1998/08/19 02:01:13 momjian Exp $
  *
  * NOTES
  *     These functions are stored in pg_amproc.  For each operator class
 int32
 btint2cmp(int16 a, int16 b)
 {
-   return ((int32) (a - b));
+   return (int32) (a - b);
 }
 
 int32
 btint4cmp(int32 a, int32 b)
 {
-   return (a - b);
+   return a - b;
 }
 
 int32
 btint24cmp(int16 a, int32 b)
 {
-   return (((int32) a) - b);
+   return ((int32) a) - b;
 }
 
 int32
 btint42cmp(int32 a, int16 b)
 {
-   return (a - ((int32) b));
+   return a - ((int32) b);
 }
 
 int32
 btfloat4cmp(float32 a, float32 b)
 {
    if (*a > *b)
-       return (1);
+       return 1;
    else if (*a == *b)
-       return (0);
+       return 0;
    else
-       return (-1);
+       return -1;
 }
 
 int32
 btfloat8cmp(float64 a, float64 b)
 {
    if (*a > *b)
-       return (1);
+       return 1;
    else if (*a == *b)
-       return (0);
+       return 0;
    else
-       return (-1);
+       return -1;
 }
 
 int32
 btoidcmp(Oid a, Oid b)
 {
    if (a > b)
-       return (1);
+       return 1;
    else if (a == b)
-       return (0);
+       return 0;
    else
-       return (-1);
+       return -1;
 }
 
+int32
+btoid8cmp(Oid a[], Oid b[])
+{
+   int i;
+   for (i=0; i < 8; i++)
+       /* we use this because we need the int4gt, etc */
+       if (!int4eq(a[i], b[i])) 
+           if (int4gt(a[i], b[i]))
+               return 1;
+           else
+               return -1;
+   return 0;
+}
+
+
 int32
 btabstimecmp(AbsoluteTime a, AbsoluteTime b)
 {
    if (AbsoluteTimeIsBefore(a, b))
-       return (-1);
+       return -1;
    else if (AbsoluteTimeIsBefore(b, a))
-       return (1);
+       return 1;
    else
-       return (0);
+       return 0;
 }
 
 int32
 btcharcmp(char a, char b)
 {
-   return ((int32) ((uint8) a - (uint8) b));
+   return (int32) ((uint8) a - (uint8) b);
 }
 
 int32
 btnamecmp(NameData *a, NameData *b)
 {
-   return (strncmp(a->data, b->data, NAMEDATALEN));
+   return strncmp(a->data, b->data, NAMEDATALEN);
 }
 
 int32
@@ -162,7 +177,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
 #endif
 
    if (res != 0 || VARSIZE(a) == VARSIZE(b))
-       return (res);
+       return res;
 
    /*
     * The two strings are the same in the first len bytes, and they are
@@ -170,7 +185,7 @@ bttextcmp(struct varlena * a, struct varlena * b)
     */
 
    if (VARSIZE(a) < VARSIZE(b))
-       return (-1);
+       return -1;
    else
-       return (1);
+       return 1;
 }
index 046cce37a0cec6cc69728c799c63b289e656a0e1..b575476ba8a66a62d8477b386d4c415e60ba3f65 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.27 1998/07/27 19:37:39 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.28 1998/08/19 02:01:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,7 +53,8 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
    BlockNumber blkno;
    int         natts = rel->rd_rel->relnatts;
    InsertIndexResult res;
-
+   Buffer      buffer;
+   
    itup = &(btitem->bti_itup);
 
    /* we need a scan key to do our search, so build one */
@@ -120,11 +121,12 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
            {                   /* they're equal */
                btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
                itup = &(btitem->bti_itup);
-               htup = heap_fetch(heapRel, SnapshotSelf, &(itup->t_tid), NULL);
+               htup = heap_fetch(heapRel, SnapshotSelf, &(itup->t_tid), &buffer);
                if (htup != (HeapTuple) NULL)
                {               /* it is a duplicate */
                    elog(ERROR, "Cannot insert a duplicate key into a unique index");
                }
+               /* htup null so no buffer to release */
                /* get next offnum */
                if (offset < maxoff)
                    offset = OffsetNumberNext(offset);
index c30d7d56acaaeeb5bdec771fb3056763f5a48557..406cd4677351e31a6da80a069c9f135f20346bba 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.28 1998/07/30 05:04:49 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.29 1998/08/19 02:01:16 momjian Exp $
  *
  * NOTES
  *   This file contains only the public interface routines.
@@ -66,7 +66,6 @@ btbuild(Relation heap,
        PredInfo *predInfo)
 {
    HeapScanDesc hscan;
-   Buffer      buffer;
    HeapTuple   htup;
    IndexTuple  itup;
    TupleDesc   htupdesc,
@@ -113,7 +112,7 @@ btbuild(Relation heap,
 #endif
 
    /* see if index is unique */
-   isunique = IndexIsUniqueNoCache(RelationGetRelationId(index));
+   isunique = IndexIsUniqueNoCache(RelationGetRelid(index));
 
    /* initialize the btree index metadata page (if this is a new index) */
    if (oldPred == NULL)
@@ -155,9 +154,6 @@ btbuild(Relation heap,
 #endif                         /* OMIT_PARTIAL_INDEX */
 
    /* start a heap scan */
-   hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
-   htup = heap_getnext(hscan, 0, &buffer);
-
    /* build the index */
    nhtups = nitups = 0;
 
@@ -167,9 +163,10 @@ btbuild(Relation heap,
        res = (InsertIndexResult) NULL;
    }
 
-   for (; HeapTupleIsValid(htup); htup = heap_getnext(hscan, 0, &buffer))
-   {
+   hscan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
 
+   while (HeapTupleIsValid(htup = heap_getnext(hscan, 0)))
+   {
        nhtups++;
 
        /*
@@ -228,8 +225,7 @@ btbuild(Relation heap,
                                            attoff,
                                            attnum,
                                            finfo,
-                                           &attnull,
-                                           buffer);
+                                           &attnull);
            nulls[attoff] = (attnull ? 'n' : ' ');
        }
 
@@ -323,8 +319,8 @@ btbuild(Relation heap,
     */
    if (IsNormalProcessingMode())
    {
-       hrelid = heap->rd_id;
-       irelid = index->rd_id;
+       hrelid = RelationGetRelid(heap);
+       irelid = RelationGetRelid(index);
        heap_close(heap);
        index_close(index);
        UpdateStats(hrelid, nhtups, true);
@@ -371,7 +367,7 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
    btitem = _bt_formitem(itup);
 
    res = _bt_doinsert(rel, btitem,
-                    IndexIsUnique(RelationGetRelationId(rel)), heapRel);
+                    IndexIsUnique(RelationGetRelid(rel)), heapRel);
 
    pfree(btitem);
    pfree(itup);
index 7aa9d2ac5716da481ae5eba41062021e5b8e45ed..b6566e936a9a023599a5afbc16115951836899ca 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.15 1998/07/30 05:04:50 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.16 1998/08/19 02:01:17 momjian Exp $
  *
  *
  * NOTES
@@ -96,10 +96,10 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op)
    BTScanList  l;
    Oid         relid;
 
-   relid = rel->rd_id;
+   relid = RelationGetRelid(rel);
    for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next)
    {
-       if (relid == l->btsl_scan->relation->rd_id)
+       if (relid == RelationGetRelid(l->btsl_scan->relation))
            _bt_scandel(l->btsl_scan, op,
                        ItemPointerGetBlockNumber(tid),
                        ItemPointerGetOffsetNumber(tid));
index f4fd602898c899c19e08c08575024ffe5e31eded..f8a8e860dc3a064b685efcb55a791cd4ece3005d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.20 1998/06/15 19:27:59 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.21 1998/08/19 02:01:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,8 +61,7 @@ _bt_mkscankey(Relation rel, IndexTuple itup)
            proc = index_getprocid(rel, i + 1, BTORDER_PROC);
            flag = 0x0;
        }
-       ScanKeyEntryInitialize(&skey[i],
-                              flag, (AttrNumber) (i + 1), proc, arg);
+       ScanKeyEntryInitialize(&skey[i], flag, (AttrNumber) (i + 1), proc, arg);
    }
 
    return (skey);
index f8ea84a6d0cd585226041927bf6b5917d0515787..c86fec6c3a8405861ada2cc86957dbe0ef38df9b 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.25 1998/07/27 19:37:41 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.26 1998/08/19 02:01:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,7 +86,6 @@ rtbuild(Relation heap,
        PredInfo *predInfo)
 {
    HeapScanDesc scan;
-   Buffer      buffer;
    AttrNumber  i;
    HeapTuple   htup;
    IndexTuple  itup;
@@ -95,6 +94,7 @@ rtbuild(Relation heap,
    InsertIndexResult res;
    Datum      *d;
    bool       *nulls;
+   Buffer      buffer = InvalidBuffer;
    int         nb,
                nh,
                ni;
@@ -164,15 +164,14 @@ rtbuild(Relation heap,
        slot = NULL;
    }
 #endif                         /* OMIT_PARTIAL_INDEX */
-   scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
-   htup = heap_getnext(scan, 0, &buffer);
 
    /* count the tuples as we insert them */
    nh = ni = 0;
 
-   for (; HeapTupleIsValid(htup); htup = heap_getnext(scan, 0, &buffer))
-   {
+   scan = heap_beginscan(heap, 0, SnapshotNow, 0, (ScanKey) NULL);
 
+   while (HeapTupleIsValid(htup = heap_getnext(scan, 0)))
+   {
        nh++;
 
        /*
@@ -234,8 +233,7 @@ rtbuild(Relation heap,
                                      attoff,
                                      attnum,
                                      finfo,
-                                     &attnull,
-                                     buffer);
+                                     &attnull);
            nulls[attoff] = (attnull ? 'n' : ' ');
        }
 
@@ -278,8 +276,8 @@ rtbuild(Relation heap,
     * flushed.  We close them to guarantee that they will be.
     */
 
-   hrelid = heap->rd_id;
-   irelid = index->rd_id;
+   hrelid = RelationGetRelid(heap);
+   irelid = RelationGetRelid(index);
    heap_close(heap);
    index_close(index);
 
index 672d0e2005fa8c30c314b2d0b3fffb3b8e9105f8..2c14968d4eff25f6e111f84de7b3c27587836c8f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.16 1998/06/15 19:28:01 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.17 1998/08/19 02:01:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -290,10 +290,10 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum)
    RTScanList  l;
    Oid         relid;
 
-   relid = r->rd_id;
+   relid = RelationGetRelid(r);
    for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next)
    {
-       if (l->rtsl_scan->relation->rd_id == relid)
+       if (RelationGetRelid(l->rtsl_scan->relation) == relid)
            rtadjone(l->rtsl_scan, op, blkno, offnum);
    }
 }
index 3e16196d33ced3bfbc3a4029b69f55c3a8c2f02f..393434ebc4d30780ac886016307ff225902bed8b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.19 1998/08/06 05:12:16 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.20 1998/08/19 02:01:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,8 +78,8 @@ static Oid objectid;
    int         ival;
 }
 
-%type   boot_arg_list
-%type  boot_index_params boot_index_on
+%type   boot_index_params
+%type  boot_index_param
 %type  boot_const boot_ident
 %type  optbootstrap optoideq boot_tuple boot_tuplelist
 
@@ -225,15 +225,12 @@ Boot_InsertStmt:
 Boot_DeclareIndexStmt:
          XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
                {
-                   List *params;
-
                    DO_START;
 
-                   params = lappend(NIL, (List*)$9);
                    DefineIndex(LexIDStr($5),
                                LexIDStr($3),
                                LexIDStr($7),
-                               params, NIL, 0, 0, NIL);
+                               $9, NIL, 0, 0, NIL);
                    DO_END;
                }
        ;
@@ -241,39 +238,21 @@ Boot_DeclareIndexStmt:
 Boot_BuildIndsStmt:
          XBUILD INDICES        { build_indices(); }
 
+
 boot_index_params:
-       boot_index_on boot_ident
-               {
-                   IndexElem *n = (IndexElem*)$1;
-                   n->class = LexIDStr($2);
-                   $$ = n;
-               }
+       boot_index_params COMMA boot_index_param    { $$ = lappend($1, $3); }
+       | boot_index_param                          { $$ = lcons($1, NIL); }
+       ;
 
-boot_index_on:
-         boot_ident
-               {
-                   IndexElem *n = makeNode(IndexElem);
-                   n->name = LexIDStr($1);
-                   $$ = n;
-               }
-       | boot_ident LPAREN boot_arg_list RPAREN
+boot_index_param:
+       boot_ident boot_ident
                {
                    IndexElem *n = makeNode(IndexElem);
                    n->name = LexIDStr($1);
-                   n->args = (List*)$3;
+                   n->class = LexIDStr($2);
                    $$ = n;
                }
 
-boot_arg_list:
-         boot_ident
-               {
-                   $$ = lappend(NIL, makeString(LexIDStr($1)));
-               }
-       | boot_arg_list COMMA boot_ident
-               {
-                   $$ = lappend((List*)$1, makeString(LexIDStr($3)));
-               }
-
 optbootstrap:
            XBOOTSTRAP  { $$ = 1; }
        |               { $$ = 0; }
index aab6a82f78c96219531f701d9cccab23429cb78b..bab7d219db9f89c9ba169c607fb0cd0d3e119f2b 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.47 1998/07/27 19:37:43 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.48 1998/08/19 02:01:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -448,8 +448,8 @@ boot_openrel(char *relname)
 {
    int         i;
    struct typmap **app;
-   Relation    rdesc;
-   HeapScanDesc sdesc;
+   Relation    rel;
+   HeapScanDesc scan;
    HeapTuple   tup;
 
    if (strlen(relname) >= NAMEDATALEN - 1)
@@ -458,25 +458,27 @@ boot_openrel(char *relname)
    if (Typ == (struct typmap **) NULL)
    {
        StartPortalAllocMode(DefaultAllocMode, 0);
-       rdesc = heap_openr(TypeRelationName);
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL);
-       for (i = 0; PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL)); ++i);
-       heap_endscan(sdesc);
+       rel = heap_openr(TypeRelationName);
+       scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
+       i = 0;
+       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+           ++i;
+       heap_endscan(scan);
        app = Typ = ALLOC(struct typmap *, i + 1);
        while (i-- > 0)
            *app++ = ALLOC(struct typmap, 1);
        *app = (struct typmap *) NULL;
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL);
+       scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
        app = Typ;
-       while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL)))
+       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
        {
            (*app)->am_oid = tup->t_oid;
            memmove((char *) &(*app++)->am_typ,
                    (char *) GETSTRUCT(tup),
                    sizeof((*app)->am_typ));
        }
-       heap_endscan(sdesc);
-       heap_close(rdesc);
+       heap_endscan(scan);
+       heap_close(rel);
        EndPortalAllocMode();
    }
 
@@ -505,7 +507,7 @@ boot_openrel(char *relname)
         * defined yet.
         */
        if (namestrcmp(&attrtypes[i]->attname, "attisset") == 0)
-           attrtypes[i]->attisset = get_attisset(reldesc->rd_id,
+           attrtypes[i]->attisset = get_attisset(RelationGetRelid(reldesc),
                                             attrtypes[i]->attname.data);
        else
            attrtypes[i]->attisset = false;
@@ -786,8 +788,8 @@ static int
 gettype(char *type)
 {
    int         i;
-   Relation    rdesc;
-   HeapScanDesc sdesc;
+   Relation    rel;
+   HeapScanDesc scan;
    HeapTuple   tup;
    struct typmap **app;
 
@@ -811,27 +813,27 @@ gettype(char *type)
        }
        if (DebugMode)
            printf("bootstrap.c: External Type: %s\n", type);
-       rdesc = heap_openr(TypeRelationName);
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL);
+       rel = heap_openr(TypeRelationName);
+       scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
        i = 0;
-       while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL)))
+       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
            ++i;
-       heap_endscan(sdesc);
+       heap_endscan(scan);
        app = Typ = ALLOC(struct typmap *, i + 1);
        while (i-- > 0)
            *app++ = ALLOC(struct typmap, 1);
        *app = (struct typmap *) NULL;
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 0, (ScanKey) NULL);
+       scan = heap_beginscan(rel, 0, SnapshotNow, 0, (ScanKey) NULL);
        app = Typ;
-       while (PointerIsValid(tup = heap_getnext(sdesc, 0, (Buffer *) NULL)))
+       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
        {
            (*app)->am_oid = tup->t_oid;
            memmove((char *) &(*app++)->am_typ,
                    (char *) GETSTRUCT(tup),
                    sizeof((*app)->am_typ));
        }
-       heap_endscan(sdesc);
-       heap_close(rdesc);
+       heap_endscan(scan);
+       heap_close(rel);
        return (gettype(type));
    }
    elog(ERROR, "Error: unknown type '%s'.\n", type);
@@ -1167,7 +1169,7 @@ build_indices()
         */
        heap = heap_openr(ILHead->il_heap);
 
-       if (!BootstrapAlreadySeen(heap->rd_id))
-           UpdateStats(heap->rd_id, 0, true);
+       if (!BootstrapAlreadySeen(RelationGetRelid(heap)))
+           UpdateStats(RelationGetRelid(heap), 0, true);
    }
 }
index 322e65bb8e00ca206f42076aad7e26834863a2bb..45772f5e0483e998f342ff4f284c3767da0f0ac1 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.13 1998/08/11 18:28:11 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.14 1998/08/19 02:01:27 momjian Exp $
  *
  * NOTES
  *   See acl.h.
@@ -33,6 +33,7 @@
 #include "fmgr.h"
 #include "parser/parse_agg.h"
 #include "parser/parse_func.h"
+#include "storage/bufmgr.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
 #include "utils/syscache.h"
@@ -97,16 +98,10 @@ ChangeAcl(char *relname,
    Acl        *old_acl = (Acl *) NULL,
               *new_acl;
    Relation    relation;
-   static ScanKeyData relkey[1] = {
-       {0, Anum_pg_class_relname, F_NAMEEQ}
-   };
-   HeapScanDesc hsdp;
-   HeapTuple   htp;
-   Buffer      buffer;
+   HeapTuple   tuple;
    Datum       values[Natts_pg_class];
    char        nulls[Natts_pg_class];
    char        replaces[Natts_pg_class];
-   ItemPointerData tmp_ipd;
    Relation    idescs[Num_pg_class_indices];
    int         free_old_acl = 0;
 
@@ -115,40 +110,34 @@ ChangeAcl(char *relname,
     * there's no ACL, create a default using the pg_class.relowner field.
     *
     * We can't use the syscache here, since we need to do a heap_replace on
-    * the tuple we find.  Feh.
+    * the tuple we find.
     */
    relation = heap_openr(RelationRelationName);
    if (!RelationIsValid(relation))
        elog(ERROR, "ChangeAcl: could not open '%s'??",
             RelationRelationName);
-   fmgr_info(F_NAMEEQ, &relkey[0].sk_func);
-   relkey[0].sk_nargs = relkey[0].sk_func.fn_nargs;
-   relkey[0].sk_argument = NameGetDatum(relname);
-   hsdp = heap_beginscan(relation,
-                         0,
-                         SnapshotNow,
-                         (unsigned) 1,
-                         relkey);
-   htp = heap_getnext(hsdp, 0, &buffer);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(RELNAME,
+                               PointerGetDatum(relname),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
    {
-       heap_endscan(hsdp);
        heap_close(relation);
        elog(ERROR, "ChangeAcl: class \"%s\" not found",
             relname);
        return;
    }
-   if (!heap_attisnull(htp, Anum_pg_class_relacl))
-       old_acl = (Acl *) heap_getattr(htp,
+
+   if (!heap_attisnull(tuple, Anum_pg_class_relacl))
+       old_acl = (Acl *) heap_getattr(tuple,
                                       Anum_pg_class_relacl,
-                                   RelationGetTupleDescriptor(relation),
+                                      RelationGetTupleDescriptor(relation),
                                       (bool *) NULL);
    if (!old_acl || ACL_NUM(old_acl) < 1)
    {
 #ifdef ACLDEBUG_TRACE
        elog(DEBUG, "ChangeAcl: using default ACL");
 #endif
-/*     old_acl = acldefault(((Form_pg_class) GETSTRUCT(htp))->relowner); */
+/*     old_acl = acldefault(((Form_pg_class) GETSTRUCT(tuple))->relowner); */
        old_acl = acldefault(relname);
        free_old_acl = 1;
    }
@@ -170,19 +159,16 @@ ChangeAcl(char *relname,
    }
    replaces[Anum_pg_class_relacl - 1] = 'r';
    values[Anum_pg_class_relacl - 1] = (Datum) new_acl;
-   htp = heap_modifytuple(htp, buffer, relation, values, nulls, replaces);
-   /* XXX is this necessary? */
-   ItemPointerCopy(&htp->t_ctid, &tmp_ipd);
+   tuple = heap_modifytuple(tuple, relation, values, nulls, replaces);
    /* XXX handle index on pg_class? */
    setheapoverride(true);
-   heap_replace(relation, &tmp_ipd, htp);
+   heap_replace(relation, &tuple->t_ctid, tuple);
    setheapoverride(false);
-   heap_endscan(hsdp);
 
    /* keep the catalog indices up to date */
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices,
                       idescs);
-   CatalogIndexInsert(idescs, Num_pg_class_indices, relation, htp);
+   CatalogIndexInsert(idescs, Num_pg_class_indices, relation, tuple);
    CatalogCloseIndices(Num_pg_class_indices, idescs);
 
    heap_close(relation);
@@ -194,13 +180,14 @@ ChangeAcl(char *relname,
 AclId
 get_grosysid(char *groname)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    AclId       id = 0;
 
-   htp = SearchSysCacheTuple(GRONAME, PointerGetDatum(groname),
-                             0, 0, 0);
-   if (HeapTupleIsValid(htp))
-       id = ((Form_pg_group) GETSTRUCT(htp))->grosysid;
+   tuple = SearchSysCacheTuple(GRONAME,
+                               PointerGetDatum(groname),
+                               0, 0, 0);
+   if (HeapTupleIsValid(tuple))
+       id = ((Form_pg_group) GETSTRUCT(tuple))->grosysid;
    else
        elog(ERROR, "non-existent group \"%s\"", groname);
    return (id);
@@ -209,13 +196,14 @@ get_grosysid(char *groname)
 char *
 get_groname(AclId grosysid)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    char       *name = NULL;
 
-   htp = SearchSysCacheTuple(GROSYSID, PointerGetDatum(grosysid),
-                             0, 0, 0);
-   if (HeapTupleIsValid(htp))
-       name = (((Form_pg_group) GETSTRUCT(htp))->groname).data;
+   tuple = SearchSysCacheTuple(GROSYSID,
+                               ObjectIdGetDatum(grosysid),
+                               0, 0, 0);
+   if (HeapTupleIsValid(tuple))
+       name = (((Form_pg_group) GETSTRUCT(tuple))->groname).data;
    else
        elog(NOTICE, "get_groname: group %d not found", grosysid);
    return (name);
@@ -225,7 +213,7 @@ static int32
 in_group(AclId uid, AclId gid)
 {
    Relation    relation;
-   HeapTuple   htp;
+   HeapTuple   tuple;
    Acl        *tmp;
    unsigned    i,
                num;
@@ -239,12 +227,13 @@ in_group(AclId uid, AclId gid)
             GroupRelationName);
        return (0);
    }
-   htp = SearchSysCacheTuple(GROSYSID, ObjectIdGetDatum(gid),
-                             0, 0, 0);
-   if (HeapTupleIsValid(htp) &&
-       !heap_attisnull(htp, Anum_pg_group_grolist))
+   tuple = SearchSysCacheTuple(GROSYSID,
+                               ObjectIdGetDatum(gid),
+                               0, 0, 0);
+   if (HeapTupleIsValid(tuple) &&
+       !heap_attisnull(tuple, Anum_pg_group_grolist))
    {
-       tmp = (IdList *) heap_getattr(htp,
+       tmp = (IdList *) heap_getattr(tuple,
                                      Anum_pg_group_grolist,
                                    RelationGetTupleDescriptor(relation),
                                      (bool *) NULL);
@@ -371,26 +360,27 @@ aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
 int32
 pg_aclcheck(char *relname, char *usename, AclMode mode)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    AclId       id;
    Acl        *acl = (Acl *) NULL,
               *tmp;
    int32       result;
    Relation    relation;
 
-   htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(usename),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "pg_aclcheck: user \"%s\" not found",
             usename);
-   id = (AclId) ((Form_pg_shadow) GETSTRUCT(htp))->usesysid;
+   id = (AclId) ((Form_pg_shadow) GETSTRUCT(tuple))->usesysid;
 
    /*
     * for the 'pg_database' relation, check the usecreatedb field before
     * checking normal permissions
     */
    if (strcmp(DatabaseRelationName, relname) == 0 &&
-       (((Form_pg_shadow) GETSTRUCT(htp))->usecreatedb))
+       (((Form_pg_shadow) GETSTRUCT(tuple))->usecreatedb))
    {
 
        /*
@@ -409,7 +399,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
     */
    if (((mode & ACL_WR) || (mode & ACL_AP)) &&
        IsSystemRelationName(relname) &&
-       !((Form_pg_shadow) GETSTRUCT(htp))->usecatupd)
+       !((Form_pg_shadow) GETSTRUCT(tuple))->usecatupd)
    {
        elog(DEBUG, "pg_aclcheck: catalog update to \"%s\": permission denied",
             relname);
@@ -419,7 +409,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
    /*
     * Otherwise, superusers bypass all permission-checking.
     */
-   if (((Form_pg_shadow) GETSTRUCT(htp))->usesuper)
+   if (((Form_pg_shadow) GETSTRUCT(tuple))->usesuper)
    {
 #ifdef ACLDEBUG_TRACE
        elog(DEBUG, "pg_aclcheck: \"%s\" is superuser",
@@ -429,18 +419,19 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
    }
 
 #ifndef ACLDEBUG
-   htp = SearchSysCacheTuple(RELNAME, PointerGetDatum(relname),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(RELNAME,
+                              PointerGetDatum(relname),
+                              0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
    {
        elog(ERROR, "pg_aclcheck: class \"%s\" not found",
             relname);
        /* an elog(ERROR) kills us, so no need to return anything. */
    }
-   if (!heap_attisnull(htp, Anum_pg_class_relacl))
+   if (!heap_attisnull(tuple, Anum_pg_class_relacl))
    {
        relation = heap_openr(RelationRelationName);
-       tmp = (Acl *) heap_getattr(htp,
+       tmp = (Acl *) heap_getattr(tuple,
                                   Anum_pg_class_relacl,
                                   RelationGetTupleDescriptor(relation),
                                   (bool *) NULL);
@@ -458,7 +449,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
        int4        ownerId;
 
        relation = heap_openr(RelationRelationName);
-       ownerId = (int4) heap_getattr(htp,
+       ownerId = (int4) heap_getattr(tuple,
                                     Anum_pg_class_relowner,
                                     RelationGetTupleDescriptor(relation),
                                     (bool *) NULL);
@@ -469,7 +460,6 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
        static ScanKeyData relkey[1] = {
            {0, Anum_pg_class_relname, F_NAMEEQ}
        };
-       HeapScanDesc hsdp;
 
        relation = heap_openr(RelationRelationName);
        if (!RelationIsValid(relation))
@@ -478,23 +468,19 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
                 RelationRelationName);
            return ACLCHECK_NO_CLASS;
        }
-       fmgr_info(F_NAMEEQ,
-                 &relkey[0].sk_func,
-                 &relkey[0].sk_nargs);
-       relkey[0].sk_argument = NameGetDatum(relname);
-       hsdp = heap_beginscan(relation, 0, SnapshotNow, 1, relkey);
-       htp = heap_getnext(hsdp, 0, (Buffer *) 0);
-       if (HeapTupleIsValid(htp) &&
-           !heap_attisnull(htp, Anum_pg_class_relacl))
+       tuple = SearchSysCacheTuple(RELNAME,
+                                  PointerGetDatum(relname),
+                                  0, 0, 0);
+       if (HeapTupleIsValid(tuple) &&
+           !heap_attisnull(tuple, Anum_pg_class_relacl))
        {
-           tmp = (Acl *) heap_getattr(htp,
+           tmp = (Acl *) heap_getattr(tuple,
                                       Anum_pg_class_relacl,
-                                   RelationGetTupleDescriptor(relation),
+                                       RelationGetTupleDescriptor(relation),
                                       (bool *) NULL);
            acl = makeacl(ACL_NUM(tmp));
            memmove((char *) acl, (char *) tmp, ACL_SIZE(tmp));
        }
-       heap_endscan(hsdp);
        heap_close(relation);
    }
 #endif
@@ -509,21 +495,22 @@ pg_ownercheck(char *usename,
              char *value,
              int cacheid)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    AclId       user_id,
                owner_id = 0;
 
-   htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(usename),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "pg_ownercheck: user \"%s\" not found",
             usename);
-   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(htp))->usesysid;
+   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(tuple))->usesysid;
 
    /*
     * Superusers bypass all permission-checking.
     */
-   if (((Form_pg_shadow) GETSTRUCT(htp))->usesuper)
+   if (((Form_pg_shadow) GETSTRUCT(tuple))->usesuper)
    {
 #ifdef ACLDEBUG_TRACE
        elog(DEBUG, "pg_ownercheck: user \"%s\" is superuser",
@@ -532,33 +519,33 @@ pg_ownercheck(char *usename,
        return (1);
    }
 
-   htp = SearchSysCacheTuple(cacheid, PointerGetDatum(value),
+   tuple = SearchSysCacheTuple(cacheid, PointerGetDatum(value),
                              0, 0, 0);
    switch (cacheid)
    {
        case OPROID:
-           if (!HeapTupleIsValid(htp))
+           if (!HeapTupleIsValid(tuple))
                elog(ERROR, "pg_ownercheck: operator %ld not found",
                     PointerGetDatum(value));
-           owner_id = ((OperatorTupleForm) GETSTRUCT(htp))->oprowner;
+           owner_id = ((OperatorTupleForm) GETSTRUCT(tuple))->oprowner;
            break;
        case PRONAME:
-           if (!HeapTupleIsValid(htp))
+           if (!HeapTupleIsValid(tuple))
                elog(ERROR, "pg_ownercheck: function \"%s\" not found",
                     value);
-           owner_id = ((Form_pg_proc) GETSTRUCT(htp))->proowner;
+           owner_id = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
            break;
        case RELNAME:
-           if (!HeapTupleIsValid(htp))
+           if (!HeapTupleIsValid(tuple))
                elog(ERROR, "pg_ownercheck: class \"%s\" not found",
                     value);
-           owner_id = ((Form_pg_class) GETSTRUCT(htp))->relowner;
+           owner_id = ((Form_pg_class) GETSTRUCT(tuple))->relowner;
            break;
        case TYPNAME:
-           if (!HeapTupleIsValid(htp))
+           if (!HeapTupleIsValid(tuple))
                elog(ERROR, "pg_ownercheck: type \"%s\" not found",
                     value);
-           owner_id = ((TypeTupleForm) GETSTRUCT(htp))->typowner;
+           owner_id = ((TypeTupleForm) GETSTRUCT(tuple))->typowner;
            break;
        default:
            elog(ERROR, "pg_ownercheck: invalid cache id: %d",
@@ -575,21 +562,22 @@ pg_func_ownercheck(char *usename,
                   int nargs,
                   Oid *arglist)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    AclId       user_id,
                owner_id;
 
-   htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(usename),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "pg_func_ownercheck: user \"%s\" not found",
             usename);
-   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(htp))->usesysid;
+   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(tuple))->usesysid;
 
    /*
     * Superusers bypass all permission-checking.
     */
-   if (((Form_pg_shadow) GETSTRUCT(htp))->usesuper)
+   if (((Form_pg_shadow) GETSTRUCT(tuple))->usesuper)
    {
 #ifdef ACLDEBUG_TRACE
        elog(DEBUG, "pg_ownercheck: user \"%s\" is superuser",
@@ -598,15 +586,15 @@ pg_func_ownercheck(char *usename,
        return (1);
    }
 
-   htp = SearchSysCacheTuple(PRONAME,
+   tuple = SearchSysCacheTuple(PRONAME,
                              PointerGetDatum(funcname),
-                             PointerGetDatum(nargs),
+                             Int32GetDatum(nargs),
                              PointerGetDatum(arglist),
                              0);
-   if (!HeapTupleIsValid(htp))
+   if (!HeapTupleIsValid(tuple))
        func_error("pg_func_ownercheck", funcname, nargs, arglist, NULL);
 
-   owner_id = ((Form_pg_proc) GETSTRUCT(htp))->proowner;
+   owner_id = ((Form_pg_proc) GETSTRUCT(tuple))->proowner;
 
    return (user_id == owner_id);
 }
@@ -616,21 +604,22 @@ pg_aggr_ownercheck(char *usename,
                   char *aggname,
                   Oid basetypeID)
 {
-   HeapTuple   htp;
+   HeapTuple   tuple;
    AclId       user_id,
                owner_id;
 
-   htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(usename),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "pg_aggr_ownercheck: user \"%s\" not found",
             usename);
-   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(htp))->usesysid;
+   user_id = (AclId) ((Form_pg_shadow) GETSTRUCT(tuple))->usesysid;
 
    /*
     * Superusers bypass all permission-checking.
     */
-   if (((Form_pg_shadow) GETSTRUCT(htp))->usesuper)
+   if (((Form_pg_shadow) GETSTRUCT(tuple))->usesuper)
    {
 #ifdef ACLDEBUG_TRACE
        elog(DEBUG, "pg_aggr_ownercheck: user \"%s\" is superuser",
@@ -639,16 +628,15 @@ pg_aggr_ownercheck(char *usename,
        return (1);
    }
 
-   htp = SearchSysCacheTuple(AGGNAME,
+   tuple = SearchSysCacheTuple(AGGNAME,
                              PointerGetDatum(aggname),
-                             PointerGetDatum(basetypeID),
-                             0,
-                             0);
+                             ObjectIdGetDatum(basetypeID),
+                             0, 0);
 
-   if (!HeapTupleIsValid(htp))
+   if (!HeapTupleIsValid(tuple))
        agg_error("pg_aggr_ownercheck", aggname, basetypeID);
 
-   owner_id = ((Form_pg_aggregate) GETSTRUCT(htp))->aggowner;
+   owner_id = ((Form_pg_aggregate) GETSTRUCT(tuple))->aggowner;
 
    return (user_id == owner_id);
 }
index 844c1502f6718cc30033e9b1a6fbbc8bf0bc2f43..76dfa70630e751d737fa7b5de3ed55817c669883 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.15 1998/02/26 04:30:31 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.16 1998/08/19 02:01:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -174,7 +174,7 @@ fillatt(TupleDesc tupleDesc)
    for (i = 0; i < natts;)
    {
        tuple = SearchSysCacheTuple(TYPOID,
-                                 Int32GetDatum((*attributeP)->atttypid),
+                                   ObjectIdGetDatum((*attributeP)->atttypid),
                                    0, 0, 0);
        if (!HeapTupleIsValid(tuple))
        {
index 1d6708a076d487867ddb6a0c6a66e2fccb77b773..7d70b7a453d17809b5a44c3b6a500a03a2c7a7f4 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.57 1998/08/17 16:03:31 thomas Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.58 1998/08/19 02:01:30 momjian Exp $
  *
  * INTERFACE ROUTINES
  *     heap_create()           - Create an uncataloged heap relation
@@ -56,6 +56,7 @@
 #include "utils/builtins.h"
 #include "utils/mcxt.h"
 #include "utils/relcache.h"
+#include "utils/syscache.h"
 #include "utils/tqual.h"
 
 #ifndef HAVE_MEMMOVE
@@ -69,9 +70,9 @@ AddPgRelationTuple(Relation pg_class_desc,
                 Relation new_rel_desc, Oid new_rel_oid, unsigned natts,
                 char relkind);
 static void AddToTempRelList(Relation r);
-static void DeletePgAttributeTuples(Relation rdesc);
-static void DeletePgRelationTuple(Relation rdesc);
-static void DeletePgTypeTuple(Relation rdesc);
+static void DeletePgAttributeTuples(Relation rel);
+static void DeletePgRelationTuple(Relation rel);
+static void DeletePgTypeTuple(Relation rel);
 static int RelationAlreadyExists(Relation pg_class_desc, char relname[]);
 static void RelationRemoveIndexes(Relation relation);
 static void RelationRemoveInheritance(Relation relation);
@@ -157,7 +158,7 @@ static TempRelList *tempRels = NULL;
  *     heap_create     - Create an uncataloged heap relation
  *
  *     Fields relpages, reltuples, reltuples, relkeys, relhistory,
- *     relisindexed, and relkind of rdesc->rd_rel are initialized
+ *     relisindexed, and relkind of rel->rd_rel are initialized
  *     to all zeros, as are rd_last and rd_hook.  Rd_refcnt is set to 1.
  *
  *     Remove the system relation specific code to elsewhere eventually.
@@ -176,7 +177,7 @@ heap_create(char *name,
 {
    unsigned    i;
    Oid         relid;
-   Relation    rdesc;
+   Relation    rel;
    int         len;
    bool        nailme = false;
    char       *relname = name;
@@ -259,13 +260,13 @@ heap_create(char *name,
     */
    len = sizeof(RelationData);
 
-   rdesc = (Relation) palloc(len);
-   MemSet((char *) rdesc, 0, len);
+   rel = (Relation) palloc(len);
+   MemSet((char *) rel, 0, len);
 
    /* ----------
       create a new tuple descriptor from the one passed in
    */
-   rdesc->rd_att = CreateTupleDescCopyConstr(tupDesc);
+   rel->rd_att = CreateTupleDescCopyConstr(tupDesc);
 
    /* ----------------
     *  initialize the fields of our new relation descriptor
@@ -279,29 +280,29 @@ heap_create(char *name,
     * ----------------
     */
    if (nailme)
-       rdesc->rd_isnailed = true;
+       rel->rd_isnailed = true;
 
-   RelationSetReferenceCount(rdesc, 1);
+   RelationSetReferenceCount(rel, 1);
 
-   rdesc->rd_rel = (Form_pg_class) palloc(sizeof *rdesc->rd_rel);
+   rel->rd_rel = (Form_pg_class) palloc(sizeof *rel->rd_rel);
 
-   MemSet((char *) rdesc->rd_rel, 0,
-          sizeof *rdesc->rd_rel);
-   namestrcpy(&(rdesc->rd_rel->relname), relname);
-   rdesc->rd_rel->relkind = RELKIND_UNCATALOGED;
-   rdesc->rd_rel->relnatts = natts;
+   MemSet((char *) rel->rd_rel, 0,
+          sizeof *rel->rd_rel);
+   namestrcpy(&(rel->rd_rel->relname), relname);
+   rel->rd_rel->relkind = RELKIND_UNCATALOGED;
+   rel->rd_rel->relnatts = natts;
    if (tupDesc->constr)
-       rdesc->rd_rel->relchecks = tupDesc->constr->num_check;
+       rel->rd_rel->relchecks = tupDesc->constr->num_check;
 
    for (i = 0; i < natts; i++)
-       rdesc->rd_att->attrs[i]->attrelid = relid;
+       rel->rd_att->attrs[i]->attrelid = relid;
 
-   rdesc->rd_id = relid;
+   RelationGetRelid(rel) = relid;
 
    if (nailme)
    {
        /* for system relations, set the reltype field here */
-       rdesc->rd_rel->reltype = relid;
+       rel->rd_rel->reltype = relid;
    }
 
    /* ----------------
@@ -309,18 +310,18 @@ heap_create(char *name,
     * ----------------
     */
 
-   rdesc->rd_istemp = isTemp;
+   rel->rd_istemp = isTemp;
 
    /* ----------------
     *  have the storage manager create the relation.
     * ----------------
     */
 
-   rdesc->rd_tmpunlinked = TRUE;       /* change once table is created */
-   rdesc->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rdesc);
-   rdesc->rd_tmpunlinked = FALSE;
+   rel->rd_tmpunlinked = TRUE;     /* change once table is created */
+   rel->rd_fd = (File) smgrcreate(DEFAULT_SMGR, rel);
+   rel->rd_tmpunlinked = FALSE;
 
-   RelationRegisterRelation(rdesc);
+   RelationRegisterRelation(rel);
 
    MemoryContextSwitchTo(oldcxt);
 
@@ -329,9 +330,9 @@ heap_create(char *name,
     * properly disposed of at the end of transaction
     */
    if (isTemp)
-       AddToTempRelList(rdesc);
+       AddToTempRelList(rel);
 
-   return (rdesc);
+   return (rel);
 }
 
 
@@ -477,14 +478,13 @@ RelationAlreadyExists(Relation pg_class_desc, char relname[])
 
    if (!IsBootstrapProcessingMode())
    {
-       tup = ClassNameIndexScan(pg_class_desc, relname);
+       tup = SearchSysCacheTuple(RELNAME,
+                                   PointerGetDatum(relname),
+                                   0, 0, 0);
        if (HeapTupleIsValid(tup))
-       {
-           pfree(tup);
-           return ((int) true);
-       }
+           return true;
        else
-           return ((int) false);
+           return false;
    }
 
    /* ----------------
@@ -513,7 +513,7 @@ RelationAlreadyExists(Relation pg_class_desc, char relname[])
     *  didn't find an existing relation.
     * ----------------
     */
-   tup = heap_getnext(pg_class_scan, 0, (Buffer *) NULL);
+   tup = heap_getnext(pg_class_scan, 0);
 
    /* ----------------
     *  end the scan and return existance of relation.
@@ -521,8 +521,7 @@ RelationAlreadyExists(Relation pg_class_desc, char relname[])
     */
    heap_endscan(pg_class_scan);
 
-   return
-       (PointerIsValid(tup) == true);
+   return HeapTupleIsValid(tup);
 }
 
 /* --------------------------------
@@ -539,7 +538,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
    AttributeTupleForm *dpp;
    unsigned    i;
    HeapTuple   tup;
-   Relation    rdesc;
+   Relation    rel;
    bool        hasindex;
    Relation    idescs[Num_pg_attr_indices];
    int         natts = tupdesc->natts;
@@ -548,15 +547,15 @@ AddNewAttributeTuples(Oid new_rel_oid,
     *  open pg_attribute
     * ----------------
     */
-   rdesc = heap_openr(AttributeRelationName);
+   rel = heap_openr(AttributeRelationName);
 
    /* -----------------
     * Check if we have any indices defined on pg_attribute.
     * -----------------
     */
-   Assert(rdesc);
-   Assert(rdesc->rd_rel);
-   hasindex = RelationGetRelationTupleForm(rdesc)->relhasindex;
+   Assert(rel);
+   Assert(rel->rd_rel);
+   hasindex = RelationGetRelationTupleForm(rel)->relhasindex;
    if (hasindex)
        CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
 
@@ -584,9 +583,9 @@ AddNewAttributeTuples(Oid new_rel_oid,
                             ATTRIBUTE_TUPLE_SIZE,
                             (char *) *dpp);
 
-       heap_insert(rdesc, tup);
+       heap_insert(rel, tup);
        if (hasindex)
-           CatalogIndexInsert(idescs, Num_pg_attr_indices, rdesc, tup);
+           CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
 
        pfree(tup);
        dpp++;
@@ -606,16 +605,16 @@ AddNewAttributeTuples(Oid new_rel_oid,
                             ATTRIBUTE_TUPLE_SIZE,
                             (char *) *dpp);
 
-       heap_insert(rdesc, tup);
+       heap_insert(rel, tup);
 
        if (hasindex)
-           CatalogIndexInsert(idescs, Num_pg_attr_indices, rdesc, tup);
+           CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
 
        pfree(tup);
        dpp++;
    }
 
-   heap_close(rdesc);
+   heap_close(rel);
 
    /*
     * close pg_attribute indices
@@ -878,7 +877,8 @@ RelationRemoveInheritance(Relation relation)
    HeapTuple   tuple;
    HeapScanDesc scan;
    ScanKeyData entry;
-
+   bool        found = false;
+   
    /* ----------------
     *  open pg_inherits
     * ----------------
@@ -892,7 +892,7 @@ RelationRemoveInheritance(Relation relation)
     */
    ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_inherits_inhparent,
                           F_OIDEQ,
-                     ObjectIdGetDatum(RelationGetRelationId(relation)));
+                     ObjectIdGetDatum(RelationGetRelid(relation)));
 
    scan = heap_beginscan(catalogRelation,
                          false,
@@ -904,7 +904,7 @@ RelationRemoveInheritance(Relation relation)
     *  if any subclasses exist, then we disallow the deletion.
     * ----------------
     */
-   tuple = heap_getnext(scan, 0, (Buffer *) NULL);
+   tuple = heap_getnext(scan, 0);
    if (HeapTupleIsValid(tuple))
    {
        heap_endscan(scan);
@@ -928,12 +928,10 @@ RelationRemoveInheritance(Relation relation)
                          1,
                          &entry);
 
-   for (;;)
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
    {
-       tuple = heap_getnext(scan, 0, (Buffer *) NULL);
-       if (!HeapTupleIsValid(tuple))
-           break;
        heap_delete(catalogRelation, &tuple->t_ctid);
+       found = true;
    }
 
    heap_endscan(scan);
@@ -943,8 +941,7 @@ RelationRemoveInheritance(Relation relation)
     *  now remove dead IPL tuples
     * ----------------
     */
-   catalogRelation =
-       heap_openr(InheritancePrecidenceListRelationName);
+   catalogRelation = heap_openr(InheritancePrecidenceListRelationName);
 
    entry.sk_attno = Anum_pg_ipl_iplrel;
 
@@ -954,13 +951,8 @@ RelationRemoveInheritance(Relation relation)
                          1,
                          &entry);
 
-   for (;;)
-   {
-       tuple = heap_getnext(scan, 0, (Buffer *) NULL);
-       if (!HeapTupleIsValid(tuple))
-           break;
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
        heap_delete(catalogRelation, &tuple->t_ctid);
-   }
 
    heap_endscan(scan);
    heap_close(catalogRelation);
@@ -980,10 +972,10 @@ RelationRemoveIndexes(Relation relation)
    ScanKeyData entry;
 
    indexRelation = heap_openr(IndexRelationName);
-
+   
    ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_index_indrelid,
                           F_OIDEQ,
-                     ObjectIdGetDatum(RelationGetRelationId(relation)));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    scan = heap_beginscan(indexRelation,
                          false,
@@ -991,14 +983,8 @@ RelationRemoveIndexes(Relation relation)
                          1,
                          &entry);
 
-   for (;;)
-   {
-       tuple = heap_getnext(scan, 0, (Buffer *) NULL);
-       if (!HeapTupleIsValid(tuple))
-           break;
-
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
        index_destroy(((IndexTupleForm) GETSTRUCT(tuple))->indexrelid);
-   }
 
    heap_endscan(scan);
    heap_close(indexRelation);
@@ -1010,11 +996,9 @@ RelationRemoveIndexes(Relation relation)
  * --------------------------------
  */
 static void
-DeletePgRelationTuple(Relation rdesc)
+DeletePgRelationTuple(Relation rel)
 {
    Relation    pg_class_desc;
-   HeapScanDesc pg_class_scan;
-   ScanKeyData key;
    HeapTuple   tup;
 
    /* ----------------
@@ -1023,42 +1007,23 @@ DeletePgRelationTuple(Relation rdesc)
     */
    pg_class_desc = heap_openr(RelationRelationName);
 
-   /* ----------------
-    *  create a scan key to locate the relation oid of the
-    *  relation to delete
-    * ----------------
-    */
-   ScanKeyEntryInitialize(&key, 0, ObjectIdAttributeNumber,
-                          F_INT4EQ, rdesc->rd_att->attrs[0]->attrelid);
-
-   pg_class_scan = heap_beginscan(pg_class_desc,
-                                  0,
-                                  SnapshotNow,
-                                  1,
-                                  &key);
-
-   /* ----------------
-    *  use heap_getnext() to fetch the pg_class tuple.  If this
-    *  tuple is not valid then something's wrong.
-    * ----------------
-    */
-   tup = heap_getnext(pg_class_scan, 0, (Buffer *) NULL);
-
-   if (!PointerIsValid(tup))
+   tup = SearchSysCacheTupleCopy(RELOID,
+                                   ObjectIdGetDatum(rel->rd_att->attrs[0]->attrelid),
+                                   0, 0, 0);
+   if (!HeapTupleIsValid(tup))
    {
-       heap_endscan(pg_class_scan);
        heap_close(pg_class_desc);
        elog(ERROR, "DeletePgRelationTuple: %s relation nonexistent",
-            &rdesc->rd_rel->relname);
+            &rel->rd_rel->relname);
    }
 
    /* ----------------
     *  delete the relation tuple from pg_class, and finish up.
     * ----------------
     */
-   heap_endscan(pg_class_scan);
    heap_delete(pg_class_desc, &tup->t_ctid);
-
+   pfree(tup);
+   
    heap_close(pg_class_desc);
 }
 
@@ -1068,57 +1033,36 @@ DeletePgRelationTuple(Relation rdesc)
  * --------------------------------
  */
 static void
-DeletePgAttributeTuples(Relation rdesc)
+DeletePgAttributeTuples(Relation rel)
 {
    Relation    pg_attribute_desc;
-   HeapScanDesc pg_attribute_scan;
-   ScanKeyData key;
    HeapTuple   tup;
-
+   int2        attnum;
+   
    /* ----------------
     *  open pg_attribute
     * ----------------
     */
    pg_attribute_desc = heap_openr(AttributeRelationName);
 
-   /* ----------------
-    *  create a scan key to locate the attribute tuples to delete
-    *  and begin the scan.
-    * ----------------
-    */
-   ScanKeyEntryInitialize(&key, 0, Anum_pg_attribute_attrelid,
-                          F_INT4EQ, rdesc->rd_att->attrs[0]->attrelid);
-
    /* -----------------
     * Get a write lock _before_ getting the read lock in the scan
     * ----------------
     */
    RelationSetLockForWrite(pg_attribute_desc);
 
-   pg_attribute_scan = heap_beginscan(pg_attribute_desc,
-                                      0,
-                                      SnapshotNow,
-                                      1,
-                                      &key);
+   attnum = FirstLowInvalidHeapAttributeNumber + 1; /* cmax */
 
-   /* ----------------
-    *  use heap_getnext() / amdelete() until all attribute tuples
-    *  have been deleted.
-    * ----------------
-    */
-   while (tup = heap_getnext(pg_attribute_scan, 0, (Buffer *) NULL),
-          PointerIsValid(tup))
+   while (HeapTupleIsValid(tup = SearchSysCacheTupleCopy(ATTNUM,
+                                   ObjectIdGetDatum(rel->rd_att->attrs[0]->attrelid),
+                                   Int16GetDatum(attnum),
+                                   0, 0)))
    {
-
        heap_delete(pg_attribute_desc, &tup->t_ctid);
+       pfree(tup);
+       attnum++;
    }
 
-   /* ----------------
-    *  finish up.
-    * ----------------
-    */
-   heap_endscan(pg_attribute_scan);
-
    /* ----------------
     * Release the write lock
     * ----------------
@@ -1127,7 +1071,6 @@ DeletePgAttributeTuples(Relation rdesc)
    heap_close(pg_attribute_desc);
 }
 
-
 /* --------------------------------
  *     DeletePgTypeTuple
  *
@@ -1138,7 +1081,7 @@ DeletePgAttributeTuples(Relation rdesc)
  * --------------------------------
  */
 static void
-DeletePgTypeTuple(Relation rdesc)
+DeletePgTypeTuple(Relation rel)
 {
    Relation    pg_type_desc;
    HeapScanDesc pg_type_scan;
@@ -1162,7 +1105,7 @@ DeletePgTypeTuple(Relation rdesc)
     * ----------------
     */
    ScanKeyEntryInitialize(&key, 0, Anum_pg_type_typrelid, F_INT4EQ,
-                          rdesc->rd_att->attrs[0]->attrelid);
+                          rel->rd_att->attrs[0]->attrelid);
 
    pg_type_scan = heap_beginscan(pg_type_desc,
                                  0,
@@ -1175,14 +1118,14 @@ DeletePgTypeTuple(Relation rdesc)
     *  tuple is not valid then something's wrong.
     * ----------------
     */
-   tup = heap_getnext(pg_type_scan, 0, (Buffer *) NULL);
+   tup = heap_getnext(pg_type_scan, 0);
 
-   if (!PointerIsValid(tup))
+   if (!HeapTupleIsValid(tup))
    {
        heap_endscan(pg_type_scan);
        heap_close(pg_type_desc);
        elog(ERROR, "DeletePgTypeTuple: %s type nonexistent",
-            &rdesc->rd_rel->relname);
+            &rel->rd_rel->relname);
    }
 
    /* ----------------
@@ -1212,7 +1155,7 @@ DeletePgTypeTuple(Relation rdesc)
     *  the schema.
     * ----------------
     */
-   atttup = heap_getnext(pg_attribute_scan, 0, (Buffer *) NULL);
+   atttup = heap_getnext(pg_attribute_scan, 0);
 
    if (PointerIsValid(atttup))
    {
@@ -1224,7 +1167,7 @@ DeletePgTypeTuple(Relation rdesc)
        heap_close(pg_attribute_desc);
 
        elog(ERROR, "DeletePgTypeTuple: att of type %s exists in relation %d",
-            &rdesc->rd_rel->relname, relid);
+            &rel->rd_rel->relname, relid);
    }
    heap_endscan(pg_attribute_scan);
    heap_close(pg_attribute_desc);
@@ -1235,9 +1178,9 @@ DeletePgTypeTuple(Relation rdesc)
     *  we release the read lock on pg_type.  -mer 13 Aug 1991
     * ----------------
     */
-   heap_endscan(pg_type_scan);
    heap_delete(pg_type_desc, &tup->t_ctid);
 
+   heap_endscan(pg_type_scan);
    heap_close(pg_type_desc);
 }
 
@@ -1249,7 +1192,7 @@ DeletePgTypeTuple(Relation rdesc)
 void
 heap_destroy_with_catalog(char *relname)
 {
-   Relation    rdesc;
+   Relation    rel;
    Oid         rid;
 
    /* ----------------
@@ -1257,50 +1200,50 @@ heap_destroy_with_catalog(char *relname)
     *  heap_openr() returns NULL.
     * ----------------
     */
-   rdesc = heap_openr(relname);
-   if (rdesc == NULL)
+   rel = heap_openr(relname);
+   if (rel == NULL)
        elog(ERROR, "Relation %s Does Not Exist!", relname);
 
-   RelationSetLockForWrite(rdesc);
-   rid = rdesc->rd_id;
+   RelationSetLockForWrite(rel);
+   rid = rel->rd_id;
 
    /* ----------------
     *  prevent deletion of system relations
     * ----------------
     */
-   if (IsSystemRelationName(RelationGetRelationName(rdesc)->data))
+   if (IsSystemRelationName(RelationGetRelationName(rel)->data))
        elog(ERROR, "amdestroy: cannot destroy %s relation",
-            &rdesc->rd_rel->relname);
+            &rel->rd_rel->relname);
 
    /* ----------------
     *  remove inheritance information
     * ----------------
     */
-   RelationRemoveInheritance(rdesc);
+   RelationRemoveInheritance(rel);
 
    /* ----------------
     *  remove indexes if necessary
     * ----------------
     */
-   if (rdesc->rd_rel->relhasindex)
-       RelationRemoveIndexes(rdesc);
+   if (rel->rd_rel->relhasindex)
+       RelationRemoveIndexes(rel);
 
    /* ----------------
     *  remove rules if necessary
     * ----------------
     */
-   if (rdesc->rd_rules != NULL)
+   if (rel->rd_rules != NULL)
        RelationRemoveRules(rid);
 
    /* triggers */
-   if (rdesc->rd_rel->reltriggers > 0)
-       RelationRemoveTriggers(rdesc);
+   if (rel->rd_rel->reltriggers > 0)
+       RelationRemoveTriggers(rel);
 
    /* ----------------
     *  delete attribute tuples
     * ----------------
     */
-   DeletePgAttributeTuples(rdesc);
+   DeletePgAttributeTuples(rel);
 
    /* ----------------
     *  delete type tuple.  here we want to see the effects
@@ -1308,41 +1251,41 @@ heap_destroy_with_catalog(char *relname)
     * ----------------
     */
    setheapoverride(true);
-   DeletePgTypeTuple(rdesc);
+   DeletePgTypeTuple(rel);
    setheapoverride(false);
 
    /* ----------------
     *  delete relation tuple
     * ----------------
     */
-   DeletePgRelationTuple(rdesc);
+   DeletePgRelationTuple(rel);
 
    /*
     * release dirty buffers of this relation
     */
-   ReleaseRelationBuffers(rdesc);
+   ReleaseRelationBuffers(rel);
 
    /* ----------------
     *  flush the relation from the relcache
     * ----------------
     * Does nothing!!! Flushing moved below.    - vadim 06/04/97
-   RelationIdInvalidateRelationCacheByRelationId(rdesc->rd_id);
+   RelationIdInvalidateRelationCacheByRelationId(rel->rd_id);
     */
 
-   RemoveConstraints(rdesc);
+   RemoveConstraints(rel);
 
    /* ----------------
     *  unlink the relation and finish up.
     * ----------------
     */
-   if (!(rdesc->rd_istemp) || !(rdesc->rd_tmpunlinked))
-       smgrunlink(DEFAULT_SMGR, rdesc);
+   if (!(rel->rd_istemp) || !(rel->rd_tmpunlinked))
+       smgrunlink(DEFAULT_SMGR, rel);
 
-   rdesc->rd_tmpunlinked = TRUE;
+   rel->rd_tmpunlinked = TRUE;
 
-   RelationUnsetLockForWrite(rdesc);
+   RelationUnsetLockForWrite(rel);
 
-   heap_close(rdesc);
+   heap_close(rel);
 
    /* ok - flush the relation from the relcache */
    RelationForgetRelation(rid);
@@ -1355,14 +1298,14 @@ heap_destroy_with_catalog(char *relname)
  */
 
 void
-heap_destroy(Relation rdesc)
+heap_destroy(Relation rel)
 {
-   ReleaseRelationBuffers(rdesc);
-   if (!(rdesc->rd_istemp) || !(rdesc->rd_tmpunlinked))
-       smgrunlink(DEFAULT_SMGR, rdesc);
-   rdesc->rd_tmpunlinked = TRUE;
-   heap_close(rdesc);
-   RemoveFromTempRelList(rdesc);
+   ReleaseRelationBuffers(rel);
+   if (!(rel->rd_istemp) || !(rel->rd_tmpunlinked))
+       smgrunlink(DEFAULT_SMGR, rel);
+   rel->rd_tmpunlinked = TRUE;
+   heap_close(rel);
+   RemoveFromTempRelList(rel);
 }
 
 
@@ -1456,17 +1399,17 @@ void
 DestroyTempRels(void)
 {
    int         i;
-   Relation    rdesc;
+   Relation    rel;
 
    if (!tempRels)
        return;
 
    for (i = 0; i < tempRels->num; i++)
    {
-       rdesc = tempRels->rels[i];
-       /* rdesc may be NULL if it has been removed from the list already */
-       if (rdesc)
-           heap_destroy(rdesc);
+       rel = tempRels->rels[i];
+       /* rel may be NULL if it has been removed from the list already */
+       if (rel)
+           heap_destroy(rel);
    }
    free(tempRels->rels);
    free(tempRels);
@@ -1649,7 +1592,7 @@ RemoveAttrDefault(Relation rel)
 
    adscan = heap_beginscan(adrel, 0, SnapshotNow, 1, &key);
 
-   while (tup = heap_getnext(adscan, 0, (Buffer *) NULL), PointerIsValid(tup))
+   while (HeapTupleIsValid(tup = heap_getnext(adscan, 0)))
        heap_delete(adrel, &tup->t_ctid);
 
    heap_endscan(adscan);
@@ -1676,7 +1619,7 @@ RemoveRelCheck(Relation rel)
 
    rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 1, &key);
 
-   while (tup = heap_getnext(rcscan, 0, (Buffer *) NULL), PointerIsValid(tup))
+   while (HeapTupleIsValid(tup = heap_getnext(rcscan, 0)))
        heap_delete(rcrel, &tup->t_ctid);
 
    heap_endscan(rcscan);
index 00eccbac6228951379e33db0fffcb6ebb92f644c..05b7df73800b6fef80530de796f6f6525934755d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.47 1998/07/27 19:37:47 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.48 1998/08/19 02:01:32 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -65,8 +65,7 @@
 
 /* non-export function prototypes */
 static Oid
-RelationNameGetObjectId(char *relationName, Relation pg_class,
-                       bool setHasIndexAttribute);
+RelationNameGetObjectId(char *relationName, Relation pg_class);
 static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
 static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
 static TupleDesc
@@ -130,26 +129,15 @@ static FormData_pg_attribute sysatts[] = {
  * RelationNameGetObjectId --
  *     Returns the object identifier for a relation given its name.
  *
- * >   The HASINDEX attribute for the relation with this name will
- * >   be set if it exists and if it is indicated by the call argument.
- * What a load of bull.  This setHasIndexAttribute is totally ignored.
- * This is yet another silly routine to scan the catalogs which should
- * probably be replaced by SearchSysCacheTuple. -cim 1/19/91
- *
- * Note:
- *     Assumes relation name is valid.
- *     Assumes relation descriptor is valid.
  * ----------------------------------------------------------------
  */
 static Oid
 RelationNameGetObjectId(char *relationName,
-                       Relation pg_class,
-                       bool setHasIndexAttribute)
+                       Relation pg_class)
 {
    HeapScanDesc pg_class_scan;
    HeapTuple   pg_class_tuple;
    Oid         relationObjectId;
-   Buffer      buffer;
    ScanKeyData key;
 
    /*
@@ -159,20 +147,20 @@ RelationNameGetObjectId(char *relationName,
 
    if (!IsBootstrapProcessingMode())
    {
-       pg_class_tuple = ClassNameIndexScan(pg_class, relationName);
-       if (HeapTupleIsValid(pg_class_tuple))
-       {
-           relationObjectId = pg_class_tuple->t_oid;
-           pfree(pg_class_tuple);
-       }
+       HeapTuple   tuple;
+   
+       tuple = SearchSysCacheTuple(RELNAME,
+                                   PointerGetDatum(relationName),
+                                   0, 0, 0);
+   
+       if (HeapTupleIsValid(tuple))
+           return tuple->t_oid;
        else
-           relationObjectId = InvalidOid;
-
-       return (relationObjectId);
+           return InvalidOid;
    }
 
    /* ----------------
-    *  Bootstrap time, do this the hard way.
+    *  BOOTSTRAP TIME, do this the hard way.
     *  begin a scan of pg_class for the named relation
     * ----------------
     */
@@ -187,15 +175,12 @@ RelationNameGetObjectId(char *relationName,
     *  (the oid of the tuple we found).
     * ----------------
     */
-   pg_class_tuple = heap_getnext(pg_class_scan, 0, &buffer);
+   pg_class_tuple = heap_getnext(pg_class_scan, 0);
 
    if (!HeapTupleIsValid(pg_class_tuple))
        relationObjectId = InvalidOid;
    else
-   {
        relationObjectId = pg_class_tuple->t_oid;
-       ReleaseBuffer(buffer);
-   }
 
    /* ----------------
     *  cleanup and return results
@@ -203,8 +188,7 @@ RelationNameGetObjectId(char *relationName,
     */
    heap_endscan(pg_class_scan);
 
-   return
-       relationObjectId;
+   return relationObjectId;
 }
 
 
@@ -219,10 +203,6 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName)
    Oid         indoid;
    Oid         heapoid;
 
-   /* ----------------
-    *  XXX ADD INDEXING HERE
-    * ----------------
-    */
    /* ----------------
     *  open pg_class and get the oid of the relation
     *  corresponding to the name of the index relation.
@@ -230,34 +210,18 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName)
     */
    pg_class = heap_openr(RelationRelationName);
 
-   indoid = RelationNameGetObjectId(indexRelationName,
-                                    pg_class,
-                                    false);
+   indoid = RelationNameGetObjectId(indexRelationName, pg_class);
 
    if (OidIsValid(indoid))
        elog(ERROR, "Cannot create index: '%s' already exists",
             indexRelationName);
 
-   /* ----------------
-    *  get the object id of the heap relation
-    * ----------------
-    */
-   heapoid = RelationNameGetObjectId(heapRelationName,
-                                     pg_class,
-                                     true);
+   heapoid = RelationNameGetObjectId(heapRelationName, pg_class);
 
-   /* ----------------
-    *    check that the heap relation exists..
-    * ----------------
-    */
    if (!OidIsValid(heapoid))
        elog(ERROR, "Cannot create index on '%s': relation does not exist",
             heapRelationName);
 
-   /* ----------------
-    *    close pg_class and return the heap relation oid
-    * ----------------
-    */
    heap_close(pg_class);
 
    return heapoid;
@@ -508,7 +472,7 @@ AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId)
    pg_am_desc = heap_openr(AccessMethodRelationName);
    pg_am_scan = heap_beginscan(pg_am_desc, 0, SnapshotNow, 1, &key);
 
-   pg_am_tuple = heap_getnext(pg_am_scan, 0, (Buffer *) NULL);
+   pg_am_tuple = heap_getnext(pg_am_scan, 0);
 
    /* ----------------
     *  return NULL if not found
@@ -597,7 +561,7 @@ UpdateRelationRelation(Relation indexRelation)
     *  company.
     * ----------------
     */
-   tuple->t_oid = indexRelation->rd_id;
+   tuple->t_oid = RelationGetRelid(indexRelation);
    heap_insert(pg_class, tuple);
 
    /*
@@ -649,8 +613,7 @@ static void
 AppendAttributeTuples(Relation indexRelation, int numatts)
 {
    Relation    pg_attribute;
-   HeapTuple   tuple;
-   HeapTuple   newtuple;
+   HeapTuple   init_tuple, cur_tuple = NULL, new_tuple;
    bool        hasind;
    Relation    idescs[Num_pg_attr_indices];
 
@@ -686,7 +649,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
    value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(1);
    value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
 
-   tuple = heap_addheader(Natts_pg_attribute,
+   init_tuple = heap_addheader(Natts_pg_attribute,
                           sizeof *(indexRelation->rd_att->attrs[0]),
                           (char *) (indexRelation->rd_att->attrs[0]));
 
@@ -701,19 +664,19 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
     *  insert the first attribute tuple.
     * ----------------
     */
-   tuple = heap_modifytuple(tuple,
-                            InvalidBuffer,
+   cur_tuple = heap_modifytuple(init_tuple,
                             pg_attribute,
                             value,
                             nullv,
                             replace);
-
-   heap_insert(pg_attribute, tuple);
+   pfree(init_tuple);
+   
+   heap_insert(pg_attribute, cur_tuple);
    if (hasind)
-       CatalogIndexInsert(idescs, Num_pg_attr_indices, pg_attribute, tuple);
+       CatalogIndexInsert(idescs, Num_pg_attr_indices, pg_attribute, cur_tuple);
 
    /* ----------------
-    *  now we use the information in the index tuple
+    *  now we use the information in the index cur_tuple
     *  descriptor to form the remaining attribute tuples.
     * ----------------
     */
@@ -725,42 +688,37 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
         *  process the remaining attributes...
         * ----------------
         */
-       memmove(GETSTRUCT(tuple),
+       memmove(GETSTRUCT(cur_tuple),
                (char *) indexTupDesc->attrs[i],
                sizeof(FormData_pg_attribute));
 
        value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1);
 
-       newtuple = heap_modifytuple(tuple,
-                                   InvalidBuffer,
+       new_tuple = heap_modifytuple(cur_tuple,
                                    pg_attribute,
                                    value,
                                    nullv,
                                    replace);
+       pfree(cur_tuple);
 
-       heap_insert(pg_attribute, newtuple);
+       heap_insert(pg_attribute,new_tuple);
        if (hasind)
-           CatalogIndexInsert(idescs, Num_pg_attr_indices, pg_attribute, newtuple);
+           CatalogIndexInsert(idescs, Num_pg_attr_indices, pg_attribute, new_tuple);
 
        /* ----------------
-        *  ModifyHeapTuple returns a new copy of a tuple
+        *  ModifyHeapTuple returns a new copy of a cur_tuple
         *  so we free the original and use the copy..
         * ----------------
         */
-       pfree(tuple);
-       tuple = newtuple;
+        cur_tuple = new_tuple;
    }
 
-   /* ----------------
-    *  close the attribute relation and free the tuple
-    * ----------------
-    */
+   if (cur_tuple)
+       pfree(cur_tuple);
    heap_close(pg_attribute);
-
    if (hasind)
        CatalogCloseIndices(Num_pg_attr_indices, idescs);
 
-   pfree(tuple);
 }
 
 /* ----------------------------------------------------------------
@@ -899,9 +857,6 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
    Relation    pg_index;
    HeapTuple   tuple;
    HeapTuple   newtup;
-   ScanKeyData entry;
-   HeapScanDesc scan;
-   Buffer      buffer;
    int         i;
    Datum       values[Natts_pg_index];
    char        nulls[Natts_pg_index];
@@ -941,14 +896,11 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
    /* open the index system catalog relation */
    pg_index = heap_openr(IndexRelationName);
 
-   ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_index_indexrelid,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(indexoid));
-
-   scan = heap_beginscan(pg_index, 0, SnapshotNow, 1, &entry);
-   tuple = heap_getnext(scan, 0, &buffer);
-   heap_endscan(scan);
-
+   tuple = SearchSysCacheTuple(INDEXRELID,
+                                 ObjectIdGetDatum(indexoid),
+                                 0, 0, 0);
+   Assert(HeapTupleIsValid(tuple));
+   
    for (i = 0; i < Natts_pg_index; i++)
    {
        nulls[i] = heap_attisnull(tuple, i + 1) ? 'n' : ' ';
@@ -959,10 +911,11 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
    replace[Anum_pg_index_indpred - 1] = 'r';
    values[Anum_pg_index_indpred - 1] = (Datum) predText;
 
-   newtup = heap_modifytuple(tuple, buffer, pg_index, values, nulls, replace);
+   newtup = heap_modifytuple(tuple, pg_index, values, nulls, replace);
 
-   heap_replace(pg_index, &(newtup->t_ctid), newtup);
+   heap_replace(pg_index, &newtup->t_ctid, newtup);
 
+   pfree(newtup);
    heap_close(pg_index);
    pfree(predText);
 }
@@ -1028,13 +981,13 @@ InitIndexStrategy(int numatts,
     *  catalogs, even though our transaction has not yet committed.
     * ----------------
     */
-   setheapoverride(1);
+   setheapoverride(true);
 
    IndexSupportInitialize(strategy, support,
                           attrelid, accessMethodObjectId,
                           amstrategies, amsupport, numatts);
 
-   setheapoverride(0);
+   setheapoverride(false);
 
    /* ----------------
     *  store the strategy information in the index reldesc
@@ -1221,9 +1174,8 @@ index_destroy(Oid indexId)
    Relation    indexRelation;
    Relation    catalogRelation;
    HeapTuple   tuple;
-   HeapScanDesc scan;
-   ScanKeyData entry;
-
+   int16       attnum;
+   
    Assert(OidIsValid(indexId));
 
    indexRelation = index_open(indexId);
@@ -1234,17 +1186,14 @@ index_destroy(Oid indexId)
     */
    catalogRelation = heap_openr(RelationRelationName);
 
-   ScanKeyEntryInitialize(&entry, 0x0, ObjectIdAttributeNumber,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(indexId));;
-
-   scan = heap_beginscan(catalogRelation, 0, SnapshotNow, 1, &entry);
-   tuple = heap_getnext(scan, 0, (Buffer *) NULL);
+   tuple = SearchSysCacheTupleCopy(RELOID,
+                                   ObjectIdGetDatum(indexId),
+                                   0, 0, 0);
 
    AssertState(HeapTupleIsValid(tuple));
 
    heap_delete(catalogRelation, &tuple->t_ctid);
-   heap_endscan(scan);
+   pfree(tuple);
    heap_close(catalogRelation);
 
    /* ----------------
@@ -1253,33 +1202,35 @@ index_destroy(Oid indexId)
     */
    catalogRelation = heap_openr(AttributeRelationName);
 
-   entry.sk_attno = Anum_pg_attribute_attrelid;
-
-   scan = heap_beginscan(catalogRelation, 0, SnapshotNow, 1, &entry);
+   attnum = 1; /* indexes start at 1 */
 
-   while (tuple = heap_getnext(scan, 0, (Buffer *) NULL),
-          HeapTupleIsValid(tuple))
+   while (HeapTupleIsValid(tuple = SearchSysCacheTupleCopy(ATTNUM,
+                                   ObjectIdGetDatum(indexId),
+                                   Int16GetDatum(attnum),
+                                   0, 0)))
+   {
        heap_delete(catalogRelation, &tuple->t_ctid);
-   heap_endscan(scan);
+       pfree(tuple);
+       attnum++;
+   }
+
    heap_close(catalogRelation);
 
    /* ----------------
     * fix INDEX relation
     * ----------------
     */
-   catalogRelation = heap_openr(IndexRelationName);
-
-   entry.sk_attno = Anum_pg_index_indexrelid;
+   tuple = SearchSysCacheTupleCopy(INDEXRELID,
+                                 ObjectIdGetDatum(indexId),
+                                 0, 0, 0);
 
-   scan = heap_beginscan(catalogRelation, 0, SnapshotNow, 1, &entry);
-   tuple = heap_getnext(scan, 0, (Buffer *) NULL);
    if (!HeapTupleIsValid(tuple))
    {
        elog(NOTICE, "IndexRelationDestroy: %s's INDEX tuple missing",
             RelationGetRelationName(indexRelation));
    }
    heap_delete(catalogRelation, &tuple->t_ctid);
-   heap_endscan(scan);
+   pfree(tuple);
    heap_close(catalogRelation);
 
    /*
@@ -1291,7 +1242,7 @@ index_destroy(Oid indexId)
        elog(ERROR, "amdestroyr: unlink: %m");
 
    index_close(indexRelation);
-   RelationForgetRelation(indexRelation->rd_id);
+   RelationForgetRelation(RelationGetRelid(indexRelation));
 }
 
 /* ----------------------------------------------------------------
@@ -1307,7 +1258,6 @@ FormIndexDatum(int numberOfAttributes,
               AttrNumber attributeNumber[],
               HeapTuple heapTuple,
               TupleDesc heapDescriptor,
-              Buffer buffer,
               Datum *datum,
               char *nullv,
               FuncIndexInfoPtr fInfo)
@@ -1333,8 +1283,7 @@ FormIndexDatum(int numberOfAttributes,
                                          offset,
                                          attributeNumber,
                                          fInfo,
-                                         &isNull,
-                                         buffer));
+                                         &isNull));
 
        nullv[offset] = (isNull) ? 'n' : ' ';
    }
@@ -1350,25 +1299,16 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
 {
    Relation    whichRel;
    Relation    pg_class;
-   HeapScanDesc pg_class_scan;
-   HeapTuple   htup;
+   HeapTuple   tuple;
    HeapTuple   newtup;
    long        relpages;
-   Buffer      buffer;
    int         i;
    Form_pg_class rd_rel;
    Relation    idescs[Num_pg_class_indices];
-
-   static ScanKeyData key[1] = {
-       {0, ObjectIdAttributeNumber, F_OIDEQ}
-   };
    Datum       values[Natts_pg_class];
    char        nulls[Natts_pg_class];
    char        replace[Natts_pg_class];
 
-   fmgr_info(F_OIDEQ, &key[0].sk_func);
-   key[0].sk_nargs = key[0].sk_func.fn_nargs;
-
    /* ----------------
     * This routine handles updates for both the heap and index relation
     * statistics.  In order to guarantee that we're able to *see* the index
@@ -1399,21 +1339,16 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
    pg_class = heap_openr(RelationRelationName);
    if (!RelationIsValid(pg_class))
        elog(ERROR, "UpdateStats: could not open RELATION relation");
-   key[0].sk_argument = ObjectIdGetDatum(relid);
 
-   pg_class_scan =
-       heap_beginscan(pg_class, 0, SnapshotNow, 1, key);
-
-   if (!HeapScanIsValid(pg_class_scan))
+   tuple = SearchSysCacheTupleCopy(RELOID,
+                                   ObjectIdGetDatum(relid),
+                                   0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
    {
        heap_close(pg_class);
        elog(ERROR, "UpdateStats: cannot scan RELATION relation");
    }
 
-   /* if the heap_open above succeeded, then so will this heap_getnext() */
-   htup = heap_getnext(pg_class_scan, 0, &buffer);
-   heap_endscan(pg_class_scan);
-
    /* ----------------
     *  update statistics
     * ----------------
@@ -1432,7 +1367,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
 
    for (i = 0; i < Natts_pg_class; i++)
    {
-       nulls[i] = heap_attisnull(htup, i + 1) ? 'n' : ' ';
+       nulls[i] = heap_attisnull(tuple, i + 1) ? 'n' : ' ';
        replace[i] = ' ';
        values[i] = (Datum) NULL;
    }
@@ -1451,7 +1386,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
         * visibility of changes, so we cheat.
         */
 
-       rd_rel = (Form_pg_class) GETSTRUCT(htup);
+       rd_rel = (Form_pg_class) GETSTRUCT(tuple);
        rd_rel->relpages = relpages;
        rd_rel->reltuples = reltuples;
        rd_rel->relhasindex = hasindex;
@@ -1466,14 +1401,15 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
        replace[Anum_pg_class_relhasindex - 1] = 'r';
        values[Anum_pg_class_relhasindex - 1] = CharGetDatum(hasindex);
 
-       newtup = heap_modifytuple(htup, buffer, pg_class, values,
-                                 nulls, replace);
-       heap_replace(pg_class, &(newtup->t_ctid), newtup);
+       newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace);
+       heap_replace(pg_class, &newtup->t_ctid, newtup);
+       pfree(newtup);
        CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
        CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup);
        CatalogCloseIndices(Num_pg_class_indices, idescs);
    }
 
+   pfree(tuple);
    heap_close(pg_class);
    heap_close(whichRel);
 }
@@ -1521,8 +1457,6 @@ DefaultBuild(Relation heapRelation,
 {
    HeapScanDesc scan;
    HeapTuple   heapTuple;
-   Buffer      buffer;
-
    IndexTuple  indexTuple;
    TupleDesc   heapDescriptor;
    TupleDesc   indexDescriptor;
@@ -1582,7 +1516,8 @@ DefaultBuild(Relation heapRelation,
        tupleTable = ExecCreateTupleTable(1);
        slot = ExecAllocTableSlot(tupleTable);
        econtext = makeNode(ExprContext);
-       FillDummyExprContext(econtext, slot, heapDescriptor, buffer);
+                   /* last parameter was junk being sent bjm 1998/08/17 */
+       FillDummyExprContext(econtext, slot, heapDescriptor, InvalidBuffer);
    }
    else
    {
@@ -1611,10 +1546,8 @@ DefaultBuild(Relation heapRelation,
     *  with correct statistics when we're done building the index.
     * ----------------
     */
-   while (heapTuple = heap_getnext(scan, 0, &buffer),
-          HeapTupleIsValid(heapTuple))
+   while (HeapTupleIsValid(heapTuple = heap_getnext(scan, 0)))
    {
-
        reltuples++;
 
        /*
@@ -1659,7 +1592,6 @@ DefaultBuild(Relation heapRelation,
                       attributeNumber, /* array of att nums to extract */
                       heapTuple,       /* tuple from base relation */
                       heapDescriptor,  /* heap tuple's descriptor */
-                      buffer,  /* buffer used in the scan */
                       datum,   /* return: array of attributes */
                       nullv,   /* return: array of char's */
                       funcInfo);
@@ -1697,13 +1629,14 @@ DefaultBuild(Relation heapRelation,
     * the vacuum daemon, but we update them here to make the index useful
     * as soon as possible.
     */
-   UpdateStats(heapRelation->rd_id, reltuples, true);
-   UpdateStats(indexRelation->rd_id, indtuples, false);
+   UpdateStats(RelationGetRelid(heapRelation), reltuples, true);
+   UpdateStats(RelationGetRelid(indexRelation), indtuples, false);
    if (oldPred != NULL)
    {
        if (indtuples == reltuples)
            predicate = NULL;
-       UpdateIndexPredicate(indexRelation->rd_id, oldPred, predicate);
+       UpdateIndexPredicate(RelationGetRelid(indexRelation),
+                            oldPred, predicate);
    }
 }
 
@@ -1814,12 +1747,11 @@ IndexIsUniqueNoCache(Oid indexId)
 
    scandesc = heap_beginscan(pg_index, 0, SnapshotSelf, 1, skey);
 
-   tuple = heap_getnext(scandesc, 0, NULL);
+   /* NO CACHE */
+   tuple = heap_getnext(scandesc, 0);
    if (!HeapTupleIsValid(tuple))
-   {
-       elog(ERROR, "IndexIsUniqueNoCache: can't find index id %d",
-            indexId);
-   }
+       elog(ERROR, "IndexIsUniqueNoCache: can't find index id %d", indexId);
+
    index = (IndexTupleForm) GETSTRUCT(tuple);
    Assert(index->indexrelid == indexId);
    isunique = index->indisunique;
index ae4846cb05fdf2b773b9d68a03430936c025a632..5a4ab5ff03ecc860d142a1063676d3d618970db0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.19 1998/07/27 19:37:48 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.20 1998/08/19 02:01:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,7 +29,6 @@
 #include "nodes/execnodes.h"
 #include "storage/bufmgr.h"
 #include "utils/builtins.h"
-#include "utils/oidcompos.h"
 #include "utils/syscache.h"
 
 /*
@@ -62,10 +61,10 @@ char       *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex};
 char      *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex};
 
 
-static HeapTuple
-CatalogIndexFetchTuple(Relation heapRelation,
+static HeapTuple CatalogIndexFetchTuple(Relation heapRelation,
                       Relation idesc,
-                      ScanKey skey);
+                      ScanKey skey,
+                      int16 num_keys);
 
 
 /*
@@ -127,7 +126,7 @@ CatalogIndexInsert(Relation *idescs,
 
        indexDescriptor = RelationGetTupleDescriptor(idescs[i]);
        pgIndexTup = SearchSysCacheTuple(INDEXRELID,
-                                        Int32GetDatum(idescs[i]->rd_id),
+                                        ObjectIdGetDatum(idescs[i]->rd_id),
                                         0, 0, 0);
        Assert(pgIndexTup);
        pgIndexP = (IndexTupleForm) GETSTRUCT(pgIndexTup);
@@ -156,13 +155,12 @@ CatalogIndexInsert(Relation *idescs,
                       (AttrNumber *) &pgIndexP->indkey[0],
                       heapTuple,
                       heapDescriptor,
-                      InvalidBuffer,
                       &datum,
                       nulls,
                       finfoP);
 
        indexRes = index_insert(idescs[i], &datum, nulls,
-                               &(heapTuple->t_ctid), heapRelation);
+                               &heapTuple->t_ctid, heapRelation);
        if (indexRes)
            pfree(indexRes);
    }
@@ -223,16 +221,16 @@ CatalogHasIndex(char *catName, Oid catId)
 static HeapTuple
 CatalogIndexFetchTuple(Relation heapRelation,
                       Relation idesc,
-                      ScanKey skey)
+                      ScanKey skey,
+                      int16 num_keys)
 {
    IndexScanDesc sd;
    RetrieveIndexResult indexRes;
    HeapTuple   tuple;
    Buffer      buffer;
-
-   sd = index_beginscan(idesc, false, 1, skey);
+   
+   sd = index_beginscan(idesc, false, num_keys, skey);
    tuple = (HeapTuple) NULL;
-
    do
    {
        indexRes = index_getnext(sd, ForwardScanDirection);
@@ -249,10 +247,10 @@ CatalogIndexFetchTuple(Relation heapRelation,
    } while (!HeapTupleIsValid(tuple));
 
    if (HeapTupleIsValid(tuple))
-   {
        tuple = heap_copytuple(tuple);
+
+   if (BufferIsValid(buffer))
        ReleaseBuffer(buffer);
-   }
 
    index_endscan(sd);
    pfree(sd);
@@ -271,22 +269,25 @@ AttributeNameIndexScan(Relation heapRelation,
                       char *attname)
 {
    Relation    idesc;
-   ScanKeyData skey;
-   OidName     keyarg;
+   ScanKeyData skey[2];
    HeapTuple   tuple;
 
-   keyarg = mkoidname(relid, attname);
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
-                          (RegProcedure) F_OIDNAMEEQ,
-                          (Datum) keyarg);
+                          (RegProcedure)F_OIDEQ,
+                          Int32GetDatum(relid));
+
+   ScanKeyEntryInitialize(&skey[1],
+                          (bits16) 0x0,
+                          (AttrNumber) 2,
+                          (RegProcedure)F_NAMEEQ,
+                          NameGetDatum(attname));
 
    idesc = index_openr(AttributeNameIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
 
    index_close(idesc);
-   pfree(keyarg);
 
    return tuple;
 }
@@ -297,22 +298,25 @@ AttributeNumIndexScan(Relation heapRelation,
                      AttrNumber attnum)
 {
    Relation    idesc;
-   ScanKeyData skey;
-   OidInt2     keyarg;
+   ScanKeyData skey[2];
    HeapTuple   tuple;
 
-   keyarg = mkoidint2(relid, (uint16) attnum);
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
-                          (RegProcedure) F_OIDINT2EQ,
-                          (Datum) keyarg);
+                          (RegProcedure)F_OIDEQ,
+                          Int32GetDatum(relid));
+
+   ScanKeyEntryInitialize(&skey[1],
+                          (bits16) 0x0,
+                          (AttrNumber) 2,
+                          (RegProcedure)F_INT2EQ,
+                          Int16GetDatum(attnum));
 
    idesc = index_openr(AttributeNumIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 2);
 
    index_close(idesc);
-   pfree(keyarg);
 
    return tuple;
 }
@@ -321,17 +325,17 @@ HeapTuple
 ProcedureOidIndexScan(Relation heapRelation, Oid procId)
 {
    Relation    idesc;
-   ScanKeyData skey;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
                           (Datum) procId);
 
    idesc = index_openr(ProcedureOidIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
    index_close(idesc);
 
@@ -343,92 +347,37 @@ ProcedureOidIndexScan(Relation heapRelation, Oid procId)
 HeapTuple
 ProcedureNameIndexScan(Relation heapRelation,
                       char *procName,
-                      int nargs,
+                      int2 nargs,
                       Oid *argTypes)
 {
    Relation    idesc;
-   ScanKeyData skey;
-   HeapTuple   tuple;          /* tuple being tested */
-   HeapTuple   return_tuple;   /* The tuple pointer we eventually return */
-   IndexScanDesc sd;
-   RetrieveIndexResult indexRes;
-   Buffer      buffer;
-   Form_pg_proc pgProcP;
-   bool        ScanComplete;
-
-   /*
-    * The index scan is complete, i.e. we've scanned everything there is
-    * to scan.
-    */
-   bool        FoundMatch;
-
-   /*
-    * In scanning pg_proc, we have found a row that meets our search
-    * criteria.
-    */
+   ScanKeyData skey[3];
+   HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_NAMEEQ,
                           (Datum) procName);
 
-   idesc = index_openr(ProcedureNameIndex);
-
-   sd = index_beginscan(idesc, false, 1, &skey);
-
-   /*
-    * for now, we do the work usually done by CatalogIndexFetchTuple by
-    * hand, so that we can check that the other keys match.  when
-    * multi-key indices are added, they will be used here.
-    */
-   tuple = (HeapTuple) NULL;   /* initial value */
-   ScanComplete = false;       /* Scan hasn't begun yet */
-   FoundMatch = false;         /* No match yet; haven't even looked. */
-   while (!FoundMatch && !ScanComplete)
-   {
-       indexRes = index_getnext(sd, ForwardScanDirection);
-       if (indexRes)
-       {
-           ItemPointer iptr;
+   ScanKeyEntryInitialize(&skey[1],
+                          (bits16) 0x0,
+                          (AttrNumber) 2,
+                          (RegProcedure) F_INT2EQ,
+                          Int16GetDatum(nargs));
 
-           iptr = &indexRes->heap_iptr;
-           tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
-           pfree(indexRes);
-           if (HeapTupleIsValid(tuple))
-           {
-
-               /*
-                * Here's a row for a procedure that has the sought
-                * procedure name.  To be a match, though, we need it to
-                * have the right number and type of arguments too, so we
-                * check that now.
-                */
-               pgProcP = (Form_pg_proc) GETSTRUCT(tuple);
-               if (pgProcP->pronargs == nargs &&
-                   oid8eq(&(pgProcP->proargtypes[0]), argTypes))
-                   FoundMatch = true;
-               else
-                   ReleaseBuffer(buffer);
-           }
-       }
-       else
-           ScanComplete = true;
-   }
+   ScanKeyEntryInitialize(&skey[2],
+                          (bits16) 0x0,
+                          (AttrNumber) 3,
+                          (RegProcedure) F_OID8EQ,
+                          (Datum) argTypes);
 
-   if (FoundMatch)
-   {
-       Assert(HeapTupleIsValid(tuple));
-       return_tuple = heap_copytuple(tuple);
-       ReleaseBuffer(buffer);
-   }
-   else
-       return_tuple = (HeapTuple) NULL;
+   idesc = index_openr(ProcedureNameIndex);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 3);
 
-   index_endscan(sd);
    index_close(idesc);
 
-   return return_tuple;
+   return tuple;
 }
 
 
@@ -437,40 +386,19 @@ HeapTuple
 ProcedureSrcIndexScan(Relation heapRelation, text *procSrc)
 {
    Relation    idesc;
-   IndexScanDesc sd;
-   ScanKeyData skey;
-   RetrieveIndexResult indexRes;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
-   Buffer      buffer;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
-                          (AttrNumber) Anum_pg_proc_prosrc,
+                          (AttrNumber) 1,
                           (RegProcedure) F_TEXTEQ,
                           (Datum) procSrc);
 
    idesc = index_openr(ProcedureSrcIndex);
-   sd = index_beginscan(idesc, false, 1, &skey);
-
-   indexRes = index_getnext(sd, ForwardScanDirection);
-   if (indexRes)
-   {
-       ItemPointer iptr;
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
-       iptr = &indexRes->heap_iptr;
-       tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
-       pfree(indexRes);
-   }
-   else
-       tuple = (HeapTuple) NULL;
-
-   if (HeapTupleIsValid(tuple))
-   {
-       tuple = heap_copytuple(tuple);
-       ReleaseBuffer(buffer);
-   }
-
-   index_endscan(sd);
+   index_close(idesc);
 
    return tuple;
 }
@@ -479,17 +407,17 @@ HeapTuple
 TypeOidIndexScan(Relation heapRelation, Oid typeId)
 {
    Relation    idesc;
-   ScanKeyData skey;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
                           (Datum) typeId);
 
    idesc = index_openr(TypeOidIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
    index_close(idesc);
 
@@ -500,17 +428,17 @@ HeapTuple
 TypeNameIndexScan(Relation heapRelation, char *typeName)
 {
    Relation    idesc;
-   ScanKeyData skey;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_NAMEEQ,
                           (Datum) typeName);
 
    idesc = index_openr(TypeNameIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
    index_close(idesc);
 
@@ -521,18 +449,17 @@ HeapTuple
 ClassNameIndexScan(Relation heapRelation, char *relName)
 {
    Relation    idesc;
-   ScanKeyData skey;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_NAMEEQ,
                           (Datum) relName);
 
    idesc = index_openr(ClassNameIndex);
-
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
    index_close(idesc);
    return tuple;
@@ -542,17 +469,17 @@ HeapTuple
 ClassOidIndexScan(Relation heapRelation, Oid relId)
 {
    Relation    idesc;
-   ScanKeyData skey;
+   ScanKeyData skey[1];
    HeapTuple   tuple;
 
-   ScanKeyEntryInitialize(&skey,
+   ScanKeyEntryInitialize(&skey[0],
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
                           (Datum) relId);
 
    idesc = index_openr(ClassOidIndex);
-   tuple = CatalogIndexFetchTuple(heapRelation, idesc, &skey);
+   tuple = CatalogIndexFetchTuple(heapRelation, idesc, skey, 1);
 
    index_close(idesc);
 
index 1a650b3d971342f9b0eebe307b0e7ca12a91f301..045bdd002f72378c1ca7dc5917713e1382a4be8e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.14 1998/04/01 15:35:01 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.15 1998/08/19 02:01:34 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -155,7 +155,8 @@ AggregateCreate(char *aggName,
            elog(ERROR, "AggregateCreate: bogus function '%s'", aggfinalfnName);
    }
 
-   tup = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggName),
+   tup = SearchSysCacheTuple(AGGNAME,
+                             PointerGetDatum(aggName),
                              ObjectIdGetDatum(xbase),
                              0, 0);
    if (HeapTupleIsValid(tup))
@@ -286,7 +287,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
 
    tup = SearchSysCacheTuple(AGGNAME,
                              PointerGetDatum(aggName),
-                             PointerGetDatum(basetype),
+                             ObjectIdGetDatum(basetype),
                              0, 0);
    if (!HeapTupleIsValid(tup))
        elog(ERROR, "AggNameGetInitVal: cache lookup failed for aggregate '%s'",
@@ -325,7 +326,8 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool *isNull)
    strInitVal = textout(textInitVal);
    heap_close(aggRel);
 
-   tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(transtype),
+   tup = SearchSysCacheTuple(TYPOID,
+                             ObjectIdGetDatum(transtype),
                              0, 0, 0);
    if (!HeapTupleIsValid(tup))
    {
index 80ffcb7d7da6c846ee528db4a2829b39c3812e33..22209ec1f3973d5b31eda9a613c1fea9a69248d9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.26 1998/07/27 19:37:49 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.27 1998/08/19 02:01:36 momjian Exp $
  *
  * NOTES
  *   these routines moved here from commands/define.c and somewhat cleaned up.
@@ -120,7 +120,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
     */
    pg_operator_scan = heap_beginscan(pg_operator_desc,
                                      0,
-                                     SnapshotSelf,
+                                     SnapshotSelf, /* no cache? */
                                      3,
                                      opKey);
 
@@ -129,7 +129,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
     *  the proper return oid value.
     * ----------------
     */
-   tup = heap_getnext(pg_operator_scan, 0, (Buffer *) 0);
+   tup = heap_getnext(pg_operator_scan, 0);
    operatorObjectId = HeapTupleIsValid(tup) ? tup->t_oid : InvalidOid;
 
    /* ----------------
@@ -138,8 +138,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
     */
    heap_endscan(pg_operator_scan);
 
-   return
-       operatorObjectId;
+   return operatorObjectId;
 }
 
 /* ----------------------------------------------------------------
@@ -462,8 +461,6 @@ OperatorDef(char *operatorName,
 
    HeapScanDesc pg_operator_scan;
    HeapTuple   tup;
-   Buffer      buffer;
-   ItemPointerData itemPointerData;
    char        nulls[Natts_pg_operator];
    char        replaces[Natts_pg_operator];
    Datum       values[Natts_pg_operator];
@@ -549,7 +546,7 @@ OperatorDef(char *operatorName,
                              PointerGetDatum(typeId),
                              0);
 
-   if (!PointerIsValid(tup))
+   if (!HeapTupleIsValid(tup))
        func_error("OperatorDef", procedureName, nargs, typeId, NULL);
 
    values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_oid);
@@ -693,7 +690,7 @@ OperatorDef(char *operatorName,
    /* last three fields were filled in first */
 
    /*
-    * If we are adding to an operator shell, get its t_ctid and a buffer.
+    * If we are adding to an operator shell, get its t_ctid
     */
    pg_operator_desc = heap_openr(OperatorRelationName);
 
@@ -705,30 +702,27 @@ OperatorDef(char *operatorName,
 
        pg_operator_scan = heap_beginscan(pg_operator_desc,
                                          0,
-                                         SnapshotSelf,
+                                         SnapshotSelf, /* no cache? */
                                          3,
                                          opKey);
 
-       tup = heap_getnext(pg_operator_scan, 0, &buffer);
+       tup = heap_getnext(pg_operator_scan, 0);
        if (HeapTupleIsValid(tup))
        {
            tup = heap_modifytuple(tup,
-                                  buffer,
                                   pg_operator_desc,
                                   values,
                                   nulls,
                                   replaces);
 
-           ItemPointerCopy(&tup->t_ctid, &itemPointerData);
            setheapoverride(true);
-           heap_replace(pg_operator_desc, &itemPointerData, tup);
+           heap_replace(pg_operator_desc, &tup->t_ctid, tup);
            setheapoverride(false);
        }
        else
            elog(ERROR, "OperatorDef: no operator %d", other_oid);
 
        heap_endscan(pg_operator_scan);
-
    }
    else
    {
@@ -777,8 +771,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
    Relation    pg_operator_desc;
    HeapScanDesc pg_operator_scan;
    HeapTuple   tup;
-   Buffer      buffer;
-   ItemPointerData itemPointerData;
    char        nulls[Natts_pg_operator];
    char        replaces[Natts_pg_operator];
    Datum       values[Natts_pg_operator];
@@ -804,11 +796,11 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 
    pg_operator_scan = heap_beginscan(pg_operator_desc,
                                      0,
-                                     SnapshotSelf,
+                                     SnapshotSelf, /* no cache? */
                                      1,
                                      opKey);
 
-   tup = heap_getnext(pg_operator_scan, 0, &buffer);
+   tup = heap_getnext(pg_operator_scan, 0);
 
    /* if the commutator and negator are the same operator, do one update */
    if (commId == negId)
@@ -837,16 +829,13 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                }
 
                tup = heap_modifytuple(tup,
-                                      buffer,
                                       pg_operator_desc,
                                       values,
                                       nulls,
                                       replaces);
 
-               ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-
                setheapoverride(true);
-               heap_replace(pg_operator_desc, &itemPointerData, tup);
+               heap_replace(pg_operator_desc, &tup->t_ctid, tup);
                setheapoverride(false);
 
            }
@@ -855,10 +844,6 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 
        heap_close(pg_operator_desc);
 
-       /* release the buffer properly */
-       if (BufferIsValid(buffer))
-           ReleaseBuffer(buffer);
-
        return;
    }
 
@@ -869,24 +854,17 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
        values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(baseId);
        replaces[Anum_pg_operator_oprcom - 1] = 'r';
        tup = heap_modifytuple(tup,
-                              buffer,
                               pg_operator_desc,
                               values,
                               nulls,
                               replaces);
 
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
        setheapoverride(true);
-       heap_replace(pg_operator_desc, &itemPointerData, tup);
+       heap_replace(pg_operator_desc, &tup->t_ctid, tup);
        setheapoverride(false);
 
        values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
        replaces[Anum_pg_operator_oprcom - 1] = ' ';
-
-       /* release the buffer properly */
-       if (BufferIsValid(buffer))
-           ReleaseBuffer(buffer);
-
    }
 
    /* check and update the negator, if necessary */
@@ -894,34 +872,27 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 
    pg_operator_scan = heap_beginscan(pg_operator_desc,
                                      0,
-                                     SnapshotSelf,
+                                     SnapshotSelf, /* no cache? */
                                      1,
                                      opKey);
 
-   tup = heap_getnext(pg_operator_scan, 0, &buffer);
+   tup = heap_getnext(pg_operator_scan, 0);
    if (HeapTupleIsValid(tup) &&
        !(OidIsValid(((OperatorTupleForm) GETSTRUCT(tup))->oprnegate)))
    {
        values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(baseId);
        replaces[Anum_pg_operator_oprnegate - 1] = 'r';
        tup = heap_modifytuple(tup,
-                              buffer,
                               pg_operator_desc,
                               values,
                               nulls,
                               replaces);
 
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-
        setheapoverride(true);
-       heap_replace(pg_operator_desc, &itemPointerData, tup);
+       heap_replace(pg_operator_desc, &tup->t_ctid, tup);
        setheapoverride(false);
    }
 
-   /* release the buffer properly */
-   if (BufferIsValid(buffer))
-       ReleaseBuffer(buffer);
-
    heap_endscan(pg_operator_scan);
 
    heap_close(pg_operator_desc);
index 44506a35c44e09cf22aac13a15b2dbf9f405b3d8..ecebeb84d19957c2866e5b0077f0c87c8e55b958 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.18 1998/06/15 19:28:10 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.19 1998/08/19 02:01:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -57,7 +57,7 @@ ProcedureCreate(char *procedureName,
                CommandDest dest)
 {
    int         i;
-   Relation    rdesc;
+   Relation    rel;
    HeapTuple   tup;
    bool        defined;
    uint16      parameterCount;
@@ -258,23 +258,23 @@ ProcedureCreate(char *procedureName,
    values[i++] = (Datum) fmgr(F_TEXTIN, prosrc);       /* prosrc */
    values[i++] = (Datum) fmgr(F_TEXTIN, probin);       /* probin */
 
-   rdesc = heap_openr(ProcedureRelationName);
+   rel = heap_openr(ProcedureRelationName);
 
-   tupDesc = rdesc->rd_att;
+   tupDesc = rel->rd_att;
    tup = heap_formtuple(tupDesc,
                         values,
                         nulls);
 
-   heap_insert(rdesc, tup);
+   heap_insert(rel, tup);
 
-   if (RelationGetRelationTupleForm(rdesc)->relhasindex)
+   if (RelationGetRelationTupleForm(rel)->relhasindex)
    {
        Relation    idescs[Num_pg_proc_indices];
 
        CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs);
-       CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup);
+       CatalogIndexInsert(idescs, Num_pg_proc_indices, rel, tup);
        CatalogCloseIndices(Num_pg_proc_indices, idescs);
    }
-   heap_close(rdesc);
+   heap_close(rel);
    return tup->t_oid;
 }
index a9ad27a3b2d1e71e70dfe1b979f935198edf811d..a23e73893f825dc1aab9ae3fd0a2a17c85250a28 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.26 1998/07/27 19:37:49 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.27 1998/08/19 02:01:38 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,6 +21,7 @@
 #include "fmgr.h"
 #include "miscadmin.h"
 #include "parser/parse_func.h"
+#include "storage/bufmgr.h"
 #include "storage/lmgr.h"
 #include "utils/builtins.h"
 #include "utils/syscache.h"
@@ -68,7 +69,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
 
    scan = heap_beginscan(pg_type_desc,
                          0,
-                         SnapshotSelf,
+                         SnapshotSelf, /* cache? */
                          1,
                          typeKey);
 
@@ -76,7 +77,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
     *  get the type tuple, if it exists.
     * ----------------
     */
-   tup = heap_getnext(scan, 0, (Buffer *) 0);
+   tup = heap_getnext(scan, 0);
 
    /* ----------------
     *  if no type tuple exists for the given type name, then
@@ -99,8 +100,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
    heap_endscan(scan);
    *defined = (bool) ((TypeTupleForm) GETSTRUCT(tup))->typisdefined;
 
-   return
-       tup->t_oid;
+   return tup->t_oid;
 }
 
 /* ----------------------------------------------------------------
@@ -143,8 +143,7 @@ TypeGet(char *typeName,         /* name of type to be fetched */
     */
    heap_close(pg_type_desc);
 
-   return
-       typeoid;
+   return typeoid;
 }
 
 /* ----------------------------------------------------------------
@@ -312,11 +311,9 @@ TypeCreate(char *typeName,
    char        replaces[Natts_pg_type];
    Datum       values[Natts_pg_type];
 
-   Buffer      buffer;
    char       *procname;
    char       *procs[4];
    bool        defined;
-   ItemPointerData itemPointerData;
    NameData    name;
    TupleDesc   tupDesc;
    Oid         argList[8];
@@ -353,9 +350,7 @@ TypeCreate(char *typeName,
     * ----------------
     */
    if (externalSize == 0)
-   {
        externalSize = -1;      /* variable length */
-   }
 
    /* ----------------
     *  initialize arrays needed by FormHeapTuple
@@ -470,7 +465,7 @@ TypeCreate(char *typeName,
    typeKey[0].sk_argument = PointerGetDatum(typeName);
    pg_type_scan = heap_beginscan(pg_type_desc,
                                  0,
-                                 SnapshotSelf,
+                                 SnapshotSelf, /* cache? */
                                  1,
                                  typeKey);
 
@@ -480,21 +475,17 @@ TypeCreate(char *typeName,
     *  already there.
     * ----------------
     */
-   tup = heap_getnext(pg_type_scan, 0, &buffer);
+   tup = heap_getnext(pg_type_scan, 0);
    if (HeapTupleIsValid(tup))
    {
        tup = heap_modifytuple(tup,
-                              buffer,
                               pg_type_desc,
                               values,
                               nulls,
                               replaces);
 
-       /* XXX may not be necessary */
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-
        setheapoverride(true);
-       heap_replace(pg_type_desc, &itemPointerData, tup);
+       heap_replace(pg_type_desc, &tup->t_ctid, tup);
        setheapoverride(false);
 
        typeObjectId = tup->t_oid;
@@ -529,9 +520,7 @@ TypeCreate(char *typeName,
    RelationUnsetLockForWrite(pg_type_desc);
    heap_close(pg_type_desc);
 
-
-   return
-       typeObjectId;
+   return typeObjectId;
 }
 
 /* ----------------------------------------------------------------
@@ -545,48 +534,42 @@ TypeRename(char *oldTypeName, char *newTypeName)
 {
    Relation    pg_type_desc;
    Relation    idescs[Num_pg_type_indices];
-   Oid         type_oid;
-   HeapTuple   tup;
-   bool        defined;
-   ItemPointerData itemPointerData;
-
-   /* check that that the new type is not already defined */
-   type_oid = TypeGet(newTypeName, &defined);
-   if (OidIsValid(type_oid) && defined)
-       elog(ERROR, "TypeRename: type %s already defined", newTypeName);
-
-   /* get the type tuple from the catalog index scan manager */
+   HeapTuple   oldtup, newtup;
+   
    pg_type_desc = heap_openr(TypeRelationName);
-   tup = TypeNameIndexScan(pg_type_desc, oldTypeName);
-
-   /* ----------------
-    *  change the name of the type
-    * ----------------
-    */
-   if (HeapTupleIsValid(tup))
-   {
-
-       namestrcpy(&(((TypeTupleForm) GETSTRUCT(tup))->typname), newTypeName);
-
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
 
-       setheapoverride(true);
-       heap_replace(pg_type_desc, &itemPointerData, tup);
-       setheapoverride(false);
+   oldtup = SearchSysCacheTupleCopy(TYPNAME,
+                                    PointerGetDatum(oldTypeName),
+                                    0, 0, 0);
 
-       /* update the system catalog indices */
-       CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
-       CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
-       CatalogCloseIndices(Num_pg_type_indices, idescs);
+   if (!HeapTupleIsValid(oldtup))
+   {
+       heap_close(pg_type_desc);
+       elog(ERROR, "TypeRename: type %s not defined", oldTypeName);
+   }
+   
+   newtup = SearchSysCacheTuple(TYPNAME,
+                                PointerGetDatum(newTypeName),
+                                0, 0, 0);
+   if (HeapTupleIsValid(newtup))
+   {
+       pfree(oldtup);
+       heap_close(pg_type_desc);
+       elog(ERROR, "TypeRename: type %s already defined", newTypeName);
+   }
+   
+   namestrcpy(&(((TypeTupleForm) GETSTRUCT(oldtup))->typname), newTypeName);
 
-       /* all done */
-       pfree(tup);
+   setheapoverride(true);
+   heap_replace(pg_type_desc, &oldtup->t_ctid, oldtup);
+   setheapoverride(false);
 
-   }
-   else
-       elog(ERROR, "TypeRename: type %s not defined", oldTypeName);
+   /* update the system catalog indices */
+   CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
+   CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, oldtup);
+   CatalogCloseIndices(Num_pg_type_indices, idescs);
 
-   /* finish up */
+   pfree(oldtup);
    heap_close(pg_type_desc);
 }
 
index 8f07001440a511c0d3353815e55d04d0f948e7c4..063b8f2f63172ff254bb9f230f5979f97e93cb33 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.13 1998/06/15 19:28:17 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.14 1998/08/19 02:01:58 momjian Exp $
  *
  * NOTES
  *   At the point the version is defined, 2 physical relations are created
@@ -185,26 +185,26 @@ VersionCreate(char *vname, char *bname)
 static void
 setAttrList(char *bname)
 {
-   Relation    rdesc;
+   Relation    rel;
    int         i = 0;
    int         maxattrs = 0;
    char       *attrname;
    char        temp_buf[512];
    int         notfirst = 0;
 
-   rdesc = heap_openr(bname);
-   if (rdesc == NULL)
+   rel = heap_openr(bname);
+   if (rel == NULL)
    {
        elog(ERROR, "Unable to expand all -- amopenr failed ");
        return;
    }
-   maxattrs = RelationGetNumberOfAttributes(rdesc);
+   maxattrs = RelationGetNumberOfAttributes(rel);
 
    attr_list[0] = '\0';
 
    for (i = maxattrs - 1; i > -1; --i)
    {
-       attrname = (rdesc->rd_att->attrs[i]->attname).data;
+       attrname = (rel->rd_att->attrs[i]->attname).data;
 
        if (notfirst == 1)
            sprintf(temp_buf, ", %s = new.%s", attrname, attrname);
@@ -216,7 +216,7 @@ setAttrList(char *bname)
        strcat(attr_list, temp_buf);
    }
 
-   heap_close(rdesc);
+   heap_close(rel);
 
    return;
 }
index 04d8103ee32f46f4641a93f4b756e24143f6a24b..75d0e9d4a0940314b498cc62e6ddaab9acbbc42d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.36 1998/07/27 19:37:50 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.37 1998/08/19 02:01:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -172,7 +172,6 @@ Async_Notify(char *relname)
    HeapScanDesc sRel;
    TupleDesc   tdesc;
    ScanKeyData key;
-   Buffer      b;
    Datum       d,
                value[3];
    bool        isnull;
@@ -211,16 +210,14 @@ Async_Notify(char *relname)
    value[0] = value[1] = value[2] = (Datum) 0;
    value[Anum_pg_listener_notify - 1] = Int32GetDatum(1);
 
-   while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
+   while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
    {
-       d = heap_getattr(lTuple, Anum_pg_listener_notify,
-                        tdesc, &isnull);
+       d = heap_getattr(lTuple, Anum_pg_listener_notify, tdesc, &isnull);
        if (!DatumGetInt32(d))
        {
-           rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl);
+           rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
            heap_replace(lRel, &lTuple->t_ctid, rTuple);
        }
-       ReleaseBuffer(b);
    }
    heap_endscan(sRel);
    RelationUnsetLockForWrite(lRel);
@@ -260,7 +257,6 @@ Async_NotifyAtCommit()
    ScanKeyData key;
    Datum       d;
    bool        isnull;
-   Buffer      b;
    extern TransactionState CurrentTransactionState;
 
    if (!pendingNotifies)
@@ -286,7 +282,7 @@ Async_NotifyAtCommit()
            sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, &key);
            tdesc = RelationGetTupleDescriptor(lRel);
 
-           while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
+           while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
            {
                d = heap_getattr(lTuple, Anum_pg_listener_relname,
                                 tdesc, &isnull);
@@ -317,7 +313,6 @@ Async_NotifyAtCommit()
 #endif
                    }
                }
-               ReleaseBuffer(b);
            }
            heap_endscan(sRel);
            RelationUnsetLockForWrite(lRel);
@@ -400,11 +395,10 @@ Async_Listen(char *relname, int pid)
    Datum       values[Natts_pg_listener];
    char        nulls[Natts_pg_listener];
    TupleDesc   tdesc;
-   HeapScanDesc s;
-   HeapTuple   htup,
-               tup;
+   HeapScanDesc scan;
+   HeapTuple   tuple,
+               newtup;
    Relation    lDesc;
-   Buffer      b;
    Datum       d;
    int         i;
    bool        isnull;
@@ -431,22 +425,21 @@ Async_Listen(char *relname, int pid)
 
    /* is someone already listening.  One listener per relation */
    tdesc = RelationGetTupleDescriptor(lDesc);
-   s = heap_beginscan(lDesc, 0, SnapshotNow, 0, (ScanKey) NULL);
-   while (HeapTupleIsValid(htup = heap_getnext(s, 0, &b)))
+   scan = heap_beginscan(lDesc, 0, SnapshotNow, 0, (ScanKey) NULL);
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
    {
-       d = heap_getattr(htup, Anum_pg_listener_relname, tdesc,
+       d = heap_getattr(tuple, Anum_pg_listener_relname, tdesc,
                         &isnull);
        relnamei = DatumGetPointer(d);
        if (!strncmp(relnamei, relname, NAMEDATALEN))
        {
-           d = heap_getattr(htup, Anum_pg_listener_pid, tdesc, &isnull);
+           d = heap_getattr(tuple, Anum_pg_listener_pid, tdesc, &isnull);
            pid = DatumGetInt32(d);
            if (pid == MyProcPid)
                alreadyListener = 1;
        }
-       ReleaseBuffer(b);
    }
-   heap_endscan(s);
+   heap_endscan(scan);
 
    if (alreadyListener)
    {
@@ -456,12 +449,12 @@ Async_Listen(char *relname, int pid)
    }
 
    tupDesc = lDesc->rd_att;
-   tup = heap_formtuple(tupDesc,
+   newtup = heap_formtuple(tupDesc,
                         values,
                         nulls);
-   heap_insert(lDesc, tup);
+   heap_insert(lDesc, newtup);
 
-   pfree(tup);
+   pfree(newtup);
 
    /*
     * if (alreadyListener) { elog(NOTICE,"Async_Listen: already one
@@ -504,7 +497,8 @@ Async_Unlisten(char *relname, int pid)
    Relation    lDesc;
    HeapTuple   lTuple;
 
-   lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname),
+   lTuple = SearchSysCacheTuple(LISTENREL,
+                                PointerGetDatum(relname),
                                 Int32GetDatum(pid),
                                 0, 0);
    lDesc = heap_openr(ListenerRelationName);
@@ -556,7 +550,6 @@ Async_NotifyFrontEnd()
                value[3];
    char        repl[3],
                nulls[3];
-   Buffer      b;
    bool        isnull;
 
    notifyFrontEndPending = 0;
@@ -585,11 +578,10 @@ Async_NotifyFrontEnd()
    value[0] = value[1] = value[2] = (Datum) 0;
    value[Anum_pg_listener_notify - 1] = Int32GetDatum(0);
 
-   while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
+   while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
    {
-       d = heap_getattr(lTuple, Anum_pg_listener_relname,
-                        tdesc, &isnull);
-       rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl);
+       d = heap_getattr(lTuple, Anum_pg_listener_relname, tdesc, &isnull);
+       rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
        heap_replace(lRel, &lTuple->t_ctid, rTuple);
 
        /* notifying the front end */
@@ -603,8 +595,9 @@ Async_NotifyFrontEnd()
        }
        else
            elog(NOTICE, "Async_NotifyFrontEnd: no asynchronous notification to frontend on interactive sessions");
-       ReleaseBuffer(b);
    }
+   heap_endscan(sRel);
+   heap_close(lRel);
    CommitTransactionCommand();
 }
 
index b31ee63e201ab131861798caf222b1ed841edf0a..6f291cf7a3867d1360dcd89f7401944d9b5483e1 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.27 1998/08/06 05:12:22 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.28 1998/08/19 02:01:41 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,7 +128,7 @@ cluster(char oldrelname[], char oldindexname[])
        elog(ERROR, "cluster: unknown relation: \"%s\"",
             oldrelname);
    }
-   OIDOldHeap = OldHeap->rd_id;/* Get OID for the index scan   */
+   OIDOldHeap = RelationGetRelid(OldHeap);/* Get OID for the index scan    */
 
    OldIndex = index_openr(oldindexname);       /* Open old index relation  */
    if (!RelationIsValid(OldIndex))
@@ -136,7 +136,7 @@ cluster(char oldrelname[], char oldindexname[])
        elog(ERROR, "cluster: unknown index: \"%s\"",
             oldindexname);
    }
-   OIDOldIndex = OldIndex->rd_id;      /* OID for the index scan         */
+   OIDOldIndex = RelationGetRelid(OldIndex);       /* OID for the index scan         */
 
    heap_close(OldHeap);
    index_close(OldIndex);
@@ -150,7 +150,7 @@ cluster(char oldrelname[], char oldindexname[])
     * with a pg_vlock.
     */
    NewHeap = copy_heap(OIDOldHeap);
-   OIDNewHeap = NewHeap->rd_id;
+   OIDNewHeap = RelationGetRelid(NewHeap);
    strcpy(NewHeapName, NewHeap->rd_rel->relname.data);
 
 
@@ -257,7 +257,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
     */
    Old_pg_index_Tuple =
        SearchSysCacheTuple(INDEXRELID,
-                           ObjectIdGetDatum(OldIndex->rd_id),
+                           ObjectIdGetDatum(RelationGetRelid(OldIndex)),
                            0, 0, 0);
 
    Assert(Old_pg_index_Tuple);
@@ -265,7 +265,7 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
 
    Old_pg_index_relation_Tuple =
        SearchSysCacheTuple(RELOID,
-                           ObjectIdGetDatum(OldIndex->rd_id),
+                           ObjectIdGetDatum(RelationGetRelid(OldIndex)),
                            0, 0, 0);
 
    Assert(Old_pg_index_relation_Tuple);
index c279d2fb62356711a0c5cc0d9e036b2fdfea8941..de6cbceb8cc96b2423dbbf4a28c243fc77828dfd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.29 1998/07/27 19:37:51 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.30 1998/08/19 02:01:42 momjian Exp $
  *
  * NOTES
  *   The PortalExecutorHeapMemory crap needs to be eliminated
@@ -272,7 +272,6 @@ PerformAddAttribute(char *relationName,
 {
    Relation    relrdesc,
                attrdesc;
-   HeapScanDesc attsdesc;
    HeapTuple   reltup;
    HeapTuple   attributeTuple;
    AttributeTupleForm attribute;
@@ -281,8 +280,6 @@ PerformAddAttribute(char *relationName,
    int         minattnum,
                maxatts;
    HeapTuple   tup;
-   ScanKeyData key[2];
-   ItemPointerData oldTID;
    Relation    idescs[Num_pg_attr_indices];
    Relation    ridescs[Num_pg_class_indices];
    bool        hasindex;
@@ -334,7 +331,7 @@ PerformAddAttribute(char *relationName,
                elog(ERROR, "PerformAddAttribute: unknown relation: \"%s\"",
                     relationName);
            }
-           myrelid = relrdesc->rd_id;
+           myrelid = RelationGetRelid(relrdesc);
            heap_close(relrdesc);
 
            /* this routine is actually in the planner */
@@ -364,9 +361,12 @@ PerformAddAttribute(char *relationName,
    }
 
    relrdesc = heap_openr(RelationRelationName);
-   reltup = ClassNameIndexScan(relrdesc, relationName);
 
-   if (!PointerIsValid(reltup))
+   reltup = SearchSysCacheTupleCopy(RELNAME,
+                                    PointerGetDatum(relationName),
+                                    0, 0, 0);
+
+   if (!HeapTupleIsValid(reltup))
    {
        heap_close(relrdesc);
        elog(ERROR, "PerformAddAttribute: relation \"%s\" not found",
@@ -387,11 +387,10 @@ PerformAddAttribute(char *relationName,
    maxatts = minattnum + 1;
    if (maxatts > MaxHeapAttributeNumber)
    {
-       pfree(reltup);          /* XXX temp */
-       heap_close(relrdesc);   /* XXX temp */
+       pfree(reltup);
+       heap_close(relrdesc);
        elog(ERROR, "PerformAddAttribute: relations limited to %d attributes",
             MaxHeapAttributeNumber);
-       return;
    }
 
    attrdesc = heap_openr(AttributeRelationName);
@@ -406,18 +405,6 @@ PerformAddAttribute(char *relationName,
    if (hasindex)
        CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
 
-   ScanKeyEntryInitialize(&key[0],
-                          (bits16) NULL,
-                          (AttrNumber) Anum_pg_attribute_attrelid,
-                          (RegProcedure) F_OIDEQ,
-                          (Datum) reltup->t_oid);
-
-   ScanKeyEntryInitialize(&key[1],
-                          (bits16) NULL,
-                          (AttrNumber) Anum_pg_attribute_attname,
-                          (RegProcedure) F_NAMEEQ,
-                          (Datum) NULL);
-
    attributeD.attrelid = reltup->t_oid;
 
    attributeTuple = heap_addheader(Natts_pg_attribute,
@@ -431,53 +418,44 @@ PerformAddAttribute(char *relationName,
    {
        HeapTuple   typeTuple;
        TypeTupleForm form;
-       char       *p;
+       char       *typename;
        int         attnelems;
 
-       /*
-        * XXX use syscache here as an optimization
-        */
-       key[1].sk_argument = (Datum) colDef->colname;
-       attsdesc = heap_beginscan(attrdesc, 0, SnapshotNow, 2, key);
-
+       tup = SearchSysCacheTuple(ATTNAME,
+                                   ObjectIdGetDatum(reltup->t_oid),
+                                   PointerGetDatum(colDef->colname),
+                                   0, 0);
 
-       tup = heap_getnext(attsdesc, 0, (Buffer *) NULL);
        if (HeapTupleIsValid(tup))
        {
-           pfree(reltup);      /* XXX temp */
-           heap_endscan(attsdesc);     /* XXX temp */
-           heap_close(attrdesc);       /* XXX temp */
-           heap_close(relrdesc);       /* XXX temp */
+           heap_close(attrdesc);
+           heap_close(relrdesc);
            elog(ERROR, "PerformAddAttribute: attribute \"%s\" already exists in class \"%s\"",
-                key[1].sk_argument,
-                relationName);
-           return;
+               colDef->colname, relationName);
        }
-       heap_endscan(attsdesc);
 
        /*
         * check to see if it is an array attribute.
         */
 
-       p = colDef->typename->name;
+       typename = colDef->typename->name;
 
        if (colDef->typename->arrayBounds)
        {
            attnelems = length(colDef->typename->arrayBounds);
-           p = makeArrayTypeName(colDef->typename->name);
+           typename = makeArrayTypeName(colDef->typename->name);
        }
        else
            attnelems = 0;
 
        typeTuple = SearchSysCacheTuple(TYPNAME,
-                                       PointerGetDatum(p),
+                                       PointerGetDatum(typename),
                                        0, 0, 0);
        form = (TypeTupleForm) GETSTRUCT(typeTuple);
 
        if (!HeapTupleIsValid(typeTuple))
-           elog(ERROR, "Add: type \"%s\" nonexistent", p);
-       namestrcpy(&(attribute->attname), (char *) key[1].sk_argument);
-
+           elog(ERROR, "Add: type \"%s\" nonexistent", typename);
+       namestrcpy(&(attribute->attname), colDef->colname);
        attribute->atttypid = typeTuple->t_oid;
        attribute->attlen = form->typlen;
        attributeD.attdisbursion = 0;
@@ -504,8 +482,7 @@ PerformAddAttribute(char *relationName,
    heap_close(attrdesc);
 
    ((Form_pg_class) GETSTRUCT(reltup))->relnatts = maxatts;
-   oldTID = reltup->t_ctid;
-   heap_replace(relrdesc, &oldTID, reltup);
+   heap_replace(relrdesc, &reltup->t_ctid, reltup);
 
    /* keep catalog indices current */
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
index 4265cdf5c02b4c66c7f28133859aae5c2dc36dc1..34372db2a7d8114dcefe039e569812357366b970 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.52 1998/07/27 19:37:51 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.53 1998/08/19 02:01:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -257,9 +257,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
        fwrite(&ntuples, sizeof(int32), 1, fp);
    }
 
-   for (tuple = heap_getnext(scandesc, 0, NULL);
-        tuple != NULL;
-        tuple = heap_getnext(scandesc, 0, NULL))
+   while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
    {
 
        if (oids && !binary)
@@ -417,7 +415,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 
    if (rel->rd_rel->relhasindex)
    {
-       GetIndexRelations(rel->rd_id, &n_indices, &index_rels);
+       GetIndexRelations(RelationGetRelid(rel), &n_indices, &index_rels);
        if (n_indices > 0)
        {
            has_index = true;
@@ -435,7 +433,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                itupdescArr[i] = RelationGetTupleDescriptor(index_rels[i]);
                pgIndexTup =
                    SearchSysCacheTuple(INDEXRELID,
-                                 ObjectIdGetDatum(index_rels[i]->rd_id),
+                                 ObjectIdGetDatum(RelationGetRelid(index_rels[i])),
                                        0, 0, 0);
                Assert(pgIndexTup);
                pgIndexP[i] = (IndexTupleForm) GETSTRUCT(pgIndexTup);
@@ -758,7 +756,6 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                                (AttrNumber *) &(pgIndexP[i]->indkey[0]),
                                   tuple,
                                   tupDesc,
-                                  InvalidBuffer,
                                   idatum,
                                   index_nulls,
                                   finfoP[i]);
@@ -833,7 +830,6 @@ GetTypeElement(Oid type)
                                    ObjectIdGetDatum(type),
                                    0, 0, 0);
 
-
    if (HeapTupleIsValid(typeTuple))
        return ((int) ((TypeTupleForm) GETSTRUCT(typeTuple))->typelem);
 
@@ -913,9 +909,7 @@ GetIndexRelations(Oid main_relation_oid,
    scan = head;
    head->next = NULL;
 
-   for (tuple = heap_getnext(scandesc, 0, NULL);
-        tuple != NULL;
-        tuple = heap_getnext(scandesc, 0, NULL))
+   while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
    {
 
        index_relation_oid =
@@ -1168,10 +1162,9 @@ CountTuples(Relation relation)
 
    scandesc = heap_beginscan(relation, 0, SnapshotNow, 0, NULL);
 
-   for (tuple = heap_getnext(scandesc, 0, NULL), i = 0;
-        tuple != NULL;
-        tuple = heap_getnext(scandesc, 0, NULL), i++)
-       ;
+   i = 0;
+   while (HeapTupleIsValid(tuple = heap_getnext(scandesc, 0)))
+       i++;
    heap_endscan(scandesc);
    return (i);
 }
index 1221fd8e50f97b180769d3f02d6de829ef24d59e..9ca0f0e722719f5760cd13e30cc9bb3c7aabf16e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.31 1998/08/06 05:12:24 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.32 1998/08/19 02:01:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -404,7 +404,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
        char        nullarr[Natts_pg_inherits];
 
        tuple = SearchSysCacheTuple(RELNAME,
-                                 PointerGetDatum(strVal(lfirst(entry))),
+                                   PointerGetDatum(strVal(lfirst(entry))),
                                    0, 0, 0);
        AssertArg(HeapTupleIsValid(tuple));
 
index d202388c6859c06ccc906b6e682ccf0a2e23428c..a0438129dff95b7f8431816ed80c3bc13e721350 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.19 1998/08/11 18:28:13 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.20 1998/08/19 02:01:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -148,7 +148,6 @@ get_pg_dbtup(char *command, char *dbname, Relation dbrel)
 {
    HeapTuple   dbtup;
    HeapTuple   tup;
-   Buffer      buf;
    HeapScanDesc scan;
    ScanKeyData scanKey;
 
@@ -163,13 +162,10 @@ get_pg_dbtup(char *command, char *dbname, Relation dbrel)
     * since we want to return the tuple out of this proc, and we're going
     * to close the relation, copy the tuple and return the copy.
     */
-   tup = heap_getnext(scan, 0, &buf);
+   tup = heap_getnext(scan, 0);
 
    if (HeapTupleIsValid(tup))
-   {
        dbtup = heap_copytuple(tup);
-       ReleaseBuffer(buf);
-   }
    else
        dbtup = tup;
 
@@ -205,8 +201,9 @@ check_permissions(char *command,
    char        path[MAXPGPATH + 1];
 
    userName = GetPgUserName();
-   utup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName),
-                              0, 0, 0);
+   utup = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(userName),
+                               0, 0, 0);
    *userIdP = ((Form_pg_shadow) GETSTRUCT(utup))->usesysid;
    use_super = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
    use_createdb = ((Form_pg_shadow) GETSTRUCT(utup))->usecreatedb;
index 5afe352b0fbc36a1b8110c68a359eb6bb4b82521..7a0676a773881f845661f83df1627ed9a28f283f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.21 1998/06/15 19:28:15 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.22 1998/08/19 02:01:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -118,7 +118,8 @@ DefineIndex(char *heapRelationName,
    /*
     * compute access method id
     */
-   tuple = SearchSysCacheTuple(AMNAME, PointerGetDatum(accessMethodName),
+   tuple = SearchSysCacheTuple(AMNAME,
+                               PointerGetDatum(accessMethodName),
                                0, 0, 0);
    if (!HeapTupleIsValid(tuple))
    {
@@ -244,7 +245,8 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
    /*
     * compute index relation id and access method id
     */
-   tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(indexRelationName),
+   tuple = SearchSysCacheTuple(RELNAME,
+                               PointerGetDatum(indexRelationName),
                                0, 0, 0);
    if (!HeapTupleIsValid(tuple))
    {
index 1abcdae87244b98fa8ec521ac8ef8bb223f4d0cf..f3c4d4b6e1b04f80ea7374ba98ec64c9c8a17721 100644 (file)
@@ -53,7 +53,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
    Oid         typev[8];
    char        nulls[Natts_pg_language];
    Datum       values[Natts_pg_language];
-   Relation    rdesc;
+   Relation    rel;
    HeapTuple   tup;
    TupleDesc   tupDesc;
 
@@ -90,7 +90,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
    memset(typev, 0, sizeof(typev));
    procTup = SearchSysCacheTuple(PRONAME,
                                  PointerGetDatum(stmt->plhandler),
-                                 UInt16GetDatum(0),
+                                 Int32GetDatum(0),
                                  PointerGetDatum(typev),
                                  0);
    if (!HeapTupleIsValid(procTup))
@@ -121,14 +121,14 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
    values[i++] = ObjectIdGetDatum(procTup->t_oid);
    values[i++] = (Datum) fmgr(F_TEXTIN, stmt->plcompiler);
 
-   rdesc = heap_openr(LanguageRelationName);
+   rel = heap_openr(LanguageRelationName);
 
-   tupDesc = rdesc->rd_att;
+   tupDesc = rel->rd_att;
    tup = heap_formtuple(tupDesc, values, nulls);
 
-   heap_insert(rdesc, tup);
+   heap_insert(rel, tup);
 
-   heap_close(rdesc);
+   heap_close(rel);
    return;
 }
 
@@ -142,11 +142,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
 {
    char        languageName[NAMEDATALEN];
    HeapTuple   langTup;
-
-   Relation    rdesc;
-   HeapScanDesc scanDesc;
-   ScanKeyData scanKeyData;
-   HeapTuple   tup;
+   Relation    rel;
 
    /* ----------------
     * Check permission
@@ -165,7 +161,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
     */
    case_translate_language_name(stmt->plname, languageName);
 
-   langTup = SearchSysCacheTuple(LANNAME,
+   langTup = SearchSysCacheTupleCopy(LANNAME,
                                  PointerGetDatum(languageName),
                                  0, 0, 0);
    if (!HeapTupleIsValid(langTup))
@@ -177,24 +173,9 @@ DropProceduralLanguage(DropPLangStmt *stmt)
             languageName);
    }
 
-   /* ----------------
-    * Now scan pg_language and delete the PL tuple
-    * ----------------
-    */
-   rdesc = heap_openr(LanguageRelationName);
-
-   ScanKeyEntryInitialize(&scanKeyData, 0, Anum_pg_language_lanname,
-                          F_NAMEEQ, PointerGetDatum(languageName));
-
-   scanDesc = heap_beginscan(rdesc, 0, SnapshotNow, 1, &scanKeyData);
-
-   tup = heap_getnext(scanDesc, 0, (Buffer *) NULL);
-
-   if (!HeapTupleIsValid(tup))
-       elog(ERROR, "Language with name '%s' not found", languageName);
-
-   heap_delete(rdesc, &(tup->t_ctid));
+   rel = heap_openr(LanguageRelationName);
+   heap_delete(rel, &langTup->t_ctid);
 
-   heap_endscan(scanDesc);
-   heap_close(rdesc);
+   pfree(langTup);
+   heap_close(rel);
 }
index 8da3f9195870d7d180c6024b4eaff76cd9665f3e..014ddc6e19b3551c1abe04fd1bb944e7d57ff02d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.26 1998/07/27 19:37:53 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.27 1998/08/19 02:01:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,16 +51,13 @@ RemoveOperator(char *operatorName,      /* operator name */
               char *typeName2) /* optional second type name */
 {
    Relation    relation;
-   HeapScanDesc scan;
    HeapTuple   tup;
    Oid         typeId1 = InvalidOid;
    Oid         typeId2 = InvalidOid;
    bool        defined;
-   ItemPointerData itemPointerData;
-   Buffer      buffer;
-   ScanKeyData operatorKey[3];
    char       *userName;
-
+   char        oprtype;
+   
    if (typeName1)
    {
        typeId1 = TypeGet(typeName1, &defined);
@@ -81,24 +78,20 @@ RemoveOperator(char *operatorName,      /* operator name */
        }
    }
 
-   ScanKeyEntryInitialize(&operatorKey[0], 0x0,
-                          Anum_pg_operator_oprname,
-                          F_NAMEEQ,
-                          PointerGetDatum(operatorName));
-
-   ScanKeyEntryInitialize(&operatorKey[1], 0x0,
-                          Anum_pg_operator_oprleft,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(typeId1));
-
-   ScanKeyEntryInitialize(&operatorKey[2], 0x0,
-                          Anum_pg_operator_oprright,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(typeId2));
-
+   if (OidIsValid(typeId1) && OidIsValid(typeId2))
+       oprtype = 'b';
+   else if (OidIsValid(typeId1))
+       oprtype = 'l';
+   else
+       oprtype = 'r';
+
+   tup = SearchSysCacheTupleCopy(OPRNAME,
+                               PointerGetDatum(operatorName),
+                               ObjectIdGetDatum(typeId1),
+                               ObjectIdGetDatum(typeId2),
+                               CharGetDatum(oprtype));
+                          
    relation = heap_openr(OperatorRelationName);
-   scan = heap_beginscan(relation, 0, SnapshotNow, 3, operatorKey);
-   tup = heap_getnext(scan, 0, &buffer);
    if (HeapTupleIsValid(tup))
    {
 #ifndef NO_SECURITY
@@ -109,8 +102,7 @@ RemoveOperator(char *operatorName,      /* operator name */
            elog(ERROR, "RemoveOperator: operator '%s': permission denied",
                 operatorName);
 #endif
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-       heap_delete(relation, &itemPointerData);
+       heap_delete(relation, &tup->t_ctid);
    }
    else
    {
@@ -134,7 +126,7 @@ RemoveOperator(char *operatorName,      /* operator name */
                 typeName2);
        }
    }
-   heap_endscan(scan);
+   pfree(tup);
    heap_close(relation);
 }
 
@@ -150,31 +142,25 @@ RemoveOperator(char *operatorName,        /* operator name */
 static void
 SingleOpOperatorRemove(Oid typeOid)
 {
-   Relation    rdesc;
+   Relation    rel;
    ScanKeyData key[3];
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
    HeapTuple   tup;
-   ItemPointerData itemPointerData;
-   Buffer      buffer;
    static      attnums[3] = {7, 8, 9}; /* left, right, return */
    int         i;
 
    ScanKeyEntryInitialize(&key[0],
                       0, 0, F_OIDEQ, (Datum) typeOid);
-   rdesc = heap_openr(OperatorRelationName);
+   rel = heap_openr(OperatorRelationName);
    for (i = 0; i < 3; ++i)
    {
        key[0].sk_attno = attnums[i];
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 1, key);
-       while (PointerIsValid(tup = heap_getnext(sdesc, 0, &buffer)))
-       {
-           ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-           /* XXX LOCK not being passed */
-           heap_delete(rdesc, &itemPointerData);
-       }
-       heap_endscan(sdesc);
+       scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
+       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
+           heap_delete(rel, &tup->t_ctid);
+       heap_endscan(scan);
    }
-   heap_close(rdesc);
+   heap_close(rel);
 }
 
 /*
@@ -193,12 +179,10 @@ AttributeAndRelationRemove(Oid typeOid)
    };
    struct oidlist *oidptr,
               *optr;
-   Relation    rdesc;
+   Relation    rel;
    ScanKeyData key[1];
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
    HeapTuple   tup;
-   ItemPointerData itemPointerData;
-   Buffer      buffer;
 
    /*
     * Get the oid's of the relations to be removed by scanning the entire
@@ -213,31 +197,30 @@ AttributeAndRelationRemove(Oid typeOid)
    oidptr = (struct oidlist *) palloc(sizeof(*oidptr));
    oidptr->next = NULL;
    optr = oidptr;
-   rdesc = heap_openr(AttributeRelationName);
-   sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 1, key);
-   while (PointerIsValid(tup = heap_getnext(sdesc, 0, &buffer)))
+   rel = heap_openr(AttributeRelationName);
+   scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
+   while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
    {
-       ItemPointerCopy(&tup->t_ctid, &itemPointerData);
        optr->reloid = ((AttributeTupleForm) GETSTRUCT(tup))->attrelid;
        optr->next = (struct oidlist *) palloc(sizeof(*oidptr));
        optr = optr->next;
    }
    optr->next = NULL;
-   heap_endscan(sdesc);
-   heap_close(rdesc);
+   heap_endscan(scan);
+   heap_close(rel);
 
 
    ScanKeyEntryInitialize(&key[0], 0,
                           ObjectIdAttributeNumber,
                           F_OIDEQ, (Datum) 0);
    optr = oidptr;
-   rdesc = heap_openr(RelationRelationName);
+   rel = heap_openr(RelationRelationName);
    while (PointerIsValid((char *) optr->next))
    {
        key[0].sk_argument = (Datum) (optr++)->reloid;
-       sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 1, key);
-       tup = heap_getnext(sdesc, 0, &buffer);
-       if (PointerIsValid(tup))
+       scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
+       tup = heap_getnext(scan, 0);
+       if (HeapTupleIsValid(tup))
        {
            char       *name;
 
@@ -245,11 +228,11 @@ AttributeAndRelationRemove(Oid typeOid)
            heap_destroy_with_catalog(name);
        }
    }
-   heap_endscan(sdesc);
-   heap_close(rdesc);
+   heap_endscan(scan);
+   heap_close(rel);
 }
 
-#endif                         /* NOTYET */
+#endif /* NOTYET */
 
 /*
  * TypeRemove
@@ -260,13 +243,8 @@ void
 RemoveType(char *typeName)     /* type name to be removed */
 {
    Relation    relation;
-   HeapScanDesc scan;
    HeapTuple   tup;
    Oid         typeOid;
-   ItemPointerData itemPointerData;
-   static ScanKeyData typeKey[1] = {
-       {0, Anum_pg_type_typname, F_NAMEEQ}
-   };
    char       *shadow_type;
    char       *userName;
 
@@ -278,44 +256,33 @@ RemoveType(char *typeName)        /* type name to be removed */
 #endif
 
    relation = heap_openr(TypeRelationName);
-   fmgr_info(typeKey[0].sk_procedure, &typeKey[0].sk_func);
-   typeKey[0].sk_nargs = typeKey[0].sk_func.fn_nargs;
-
-   /* Delete the primary type */
+   tup = SearchSysCacheTuple(TYPNAME,
+                               PointerGetDatum(typeName),
+                               0, 0, 0);
 
-   typeKey[0].sk_argument = PointerGetDatum(typeName);
-
-   scan = heap_beginscan(relation, 0, SnapshotNow, 1, typeKey);
-   tup = heap_getnext(scan, 0, (Buffer *) 0);
    if (!HeapTupleIsValid(tup))
    {
-       heap_endscan(scan);
        heap_close(relation);
-       elog(ERROR, "RemoveType: type '%s' does not exist",
-            typeName);
+       elog(ERROR, "RemoveType: type '%s' does not exist", typeName);
    }
+   
+   relation = heap_openr(TypeRelationName);
    typeOid = tup->t_oid;
-   ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-   heap_delete(relation, &itemPointerData);
-   heap_endscan(scan);
+   heap_delete(relation, &tup->t_ctid);
 
    /* Now, Delete the "array of" that type */
    shadow_type = makeArrayTypeName(typeName);
-   typeKey[0].sk_argument = NameGetDatum(shadow_type);
-
-   scan = heap_beginscan(relation, 0, SnapshotNow,
-                         1, (ScanKey) typeKey);
-   tup = heap_getnext(scan, 0, (Buffer *) 0);
-
+   tup = SearchSysCacheTuple(TYPNAME,
+                               PointerGetDatum(shadow_type),
+                               0, 0, 0);
    if (!HeapTupleIsValid(tup))
    {
-       elog(ERROR, "RemoveType: type '%s': array stub not found",
-            typeName);
+       heap_close(relation);
+       elog(ERROR, "RemoveType: type '%s' does not exist", typeName);
    }
+
    typeOid = tup->t_oid;
-   ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-   heap_delete(relation, &itemPointerData);
-   heap_endscan(scan);
+   heap_delete(relation, &tup->t_ctid);
 
    heap_close(relation);
 }
@@ -335,24 +302,16 @@ RemoveFunction(char *functionName,        /* function name to be removed */
               List *argNameList /* list of TypeNames */ )
 {
    Relation    relation;
-   HeapScanDesc scan;
    HeapTuple   tup;
-   Buffer      buffer = InvalidBuffer;
-   bool        bufferUsed = FALSE;
    Oid         argList[8];
-   Form_pg_proc the_proc = NULL;
-   ItemPointerData itemPointerData;
-   static ScanKeyData key[3] = {
-       {0, Anum_pg_proc_proname, F_NAMEEQ}
-   };
    char       *userName;
    char       *typename;
    int         i;
 
+   
    MemSet(argList, 0, 8 * sizeof(Oid));
    for (i = 0; i < nargs; i++)
    {
-/*     typename = ((TypeName*)(lfirst(argNameList)))->name; */
        typename = strVal(lfirst(argNameList));
        argNameList = lnext(argNameList);
 
@@ -360,7 +319,8 @@ RemoveFunction(char *functionName,      /* function name to be removed */
            argList[i] = 0;
        else
        {
-           tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(typename),
+           tup = SearchSysCacheTuple(TYPNAME,
+                                     PointerGetDatum(typename),
                                      0, 0, 0);
 
            if (!HeapTupleIsValid(tup))
@@ -369,12 +329,6 @@ RemoveFunction(char *functionName,     /* function name to be removed */
        }
    }
 
-   tup = SearchSysCacheTuple(PRONAME, PointerGetDatum(functionName),
-                             Int32GetDatum(nargs),
-                             PointerGetDatum(argList), 0);
-   if (!HeapTupleIsValid(tup))
-       func_error("RemoveFunction", functionName, nargs, argList, NULL);
-
 #ifndef NO_SECURITY
    userName = GetPgUserName();
    if (!pg_func_ownercheck(userName, functionName, nargs, argList))
@@ -384,48 +338,27 @@ RemoveFunction(char *functionName,        /* function name to be removed */
    }
 #endif
 
-   key[0].sk_argument = PointerGetDatum(functionName);
-
-   fmgr_info(key[0].sk_procedure, &key[0].sk_func);
-   key[0].sk_nargs = key[0].sk_func.fn_nargs;
-
    relation = heap_openr(ProcedureRelationName);
-   scan = heap_beginscan(relation, 0, SnapshotNow, 1, key);
+   tup = SearchSysCacheTuple(PRONAME,
+                               PointerGetDatum(functionName),
+                               Int32GetDatum(nargs),
+                               PointerGetDatum(argList),
+                               0);
 
-   do
-   {                           /* hope this is ok because it's indexed */
-       if (bufferUsed)
-       {
-           ReleaseBuffer(buffer);
-           bufferUsed = FALSE;
-       }
-       tup = heap_getnext(scan, 0, (Buffer *) &buffer);
-       if (!HeapTupleIsValid(tup))
-           break;
-       bufferUsed = TRUE;
-       the_proc = (Form_pg_proc) GETSTRUCT(tup);
-   } while ((namestrcmp(&(the_proc->proname), functionName) == 0) &&
-            (the_proc->pronargs != nargs ||
-             !oid8eq(&(the_proc->proargtypes[0]), &argList[0])));
-
-
-   if (!HeapTupleIsValid(tup) || namestrcmp(&(the_proc->proname),
-                                            functionName) != 0)
+   if (!HeapTupleIsValid(tup))
    {
-       heap_endscan(scan);
        heap_close(relation);
        func_error("RemoveFunction", functionName, nargs, argList, NULL);
    }
 
-   /* ok, function has been found */
+   if ((((Form_pg_proc) GETSTRUCT(tup))->prolang) == INTERNALlanguageId)
+   {
+       heap_close(relation);   
+       elog(ERROR, "RemoveFunction: function \"%s\" is built-in",functionName);
+   }
 
-   if (the_proc->prolang == INTERNALlanguageId)
-       elog(ERROR, "RemoveFunction: function \"%s\" is built-in",
-            functionName);
+   heap_delete(relation, &tup->t_ctid);
 
-   ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-   heap_delete(relation, &itemPointerData);
-   heap_endscan(scan);
    heap_close(relation);
 }
 
@@ -433,13 +366,10 @@ void
 RemoveAggregate(char *aggName, char *aggType)
 {
    Relation    relation;
-   HeapScanDesc scan;
    HeapTuple   tup;
-   ItemPointerData itemPointerData;
    char       *userName;
    Oid         basetypeID = InvalidOid;
    bool        defined;
-   ScanKeyData aggregateKey[3];
 
 
    /*
@@ -461,9 +391,7 @@ RemoveAggregate(char *aggName, char *aggType)
    else
        basetypeID = 0;
 
-/*
 #ifndef NO_SECURITY
-*/
    userName = GetPgUserName();
    if (!pg_aggr_ownercheck(userName, aggName, basetypeID))
    {
@@ -478,26 +406,16 @@ RemoveAggregate(char *aggName, char *aggType)
                 aggName);
        }
    }
-/*
 #endif
-*/
-
-   ScanKeyEntryInitialize(&aggregateKey[0], 0x0,
-                          Anum_pg_aggregate_aggname,
-                          F_NAMEEQ,
-                          PointerGetDatum(aggName));
-
-   ScanKeyEntryInitialize(&aggregateKey[1], 0x0,
-                          Anum_pg_aggregate_aggbasetype,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(basetypeID));
 
    relation = heap_openr(AggregateRelationName);
-   scan = heap_beginscan(relation, 0, SnapshotNow, 2, aggregateKey);
-   tup = heap_getnext(scan, 0, (Buffer *) 0);
+   tup = SearchSysCacheTuple(AGGNAME,
+                              PointerGetDatum(aggName),
+                              ObjectIdGetDatum(basetypeID),
+                              0, 0);
+
    if (!HeapTupleIsValid(tup))
    {
-       heap_endscan(scan);
        heap_close(relation);
        if (aggType)
        {
@@ -510,8 +428,7 @@ RemoveAggregate(char *aggName, char *aggType)
                 aggName);
        }
    }
-   ItemPointerCopy(&tup->t_ctid, &itemPointerData);
-   heap_delete(relation, &itemPointerData);
-   heap_endscan(scan);
+   heap_delete(relation, &tup->t_ctid);
+
    heap_close(relation);
 }
index d893f9f119c8a4543d674579817a8179acfc1443..fdc7b43fdcc6f37c3b5e1b471d38f450b181cd91 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.13 1998/07/26 04:30:24 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.14 1998/08/19 02:01:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,7 +53,7 @@
  *     Attname attribute is changed in attribute catalog.
  *     No record of the previous attname is kept (correct?).
  *
- *     get proper reldesc from relation catalog (if not arg)
+ *     get proper relrelation from relation catalog (if not arg)
  *     scan attribute catalog
  *             for name conflict (within rel)
  *             for original attribute (if not arg)
@@ -70,14 +71,13 @@ renameatt(char *relname,
          char *userName,
          int recurse)
 {
-   Relation    relrdesc,
-               attrdesc;
+   Relation    attrelation;
    HeapTuple   reltup,
                oldatttup,
                newatttup;
-   ItemPointerData oldTID;
-   Relation    idescs[Num_pg_attr_indices];
-
+   Relation    irelations[Num_pg_attr_indices];
+   Oid         relid;
+   
    /*
     * permissions checking.  this would normally be done in utility.c,
     * but this particular routine is recursive.
@@ -110,19 +110,20 @@ renameatt(char *relname,
        List       *child,
                   *children;
 
-       relrdesc = heap_openr(relname);
-       if (!RelationIsValid(relrdesc))
+       reltup = SearchSysCacheTuple(RELNAME,
+                                    PointerGetDatum(relname),
+                                    0, 0, 0);
+
+       if (!HeapTupleIsValid(reltup))
        {
-           elog(ERROR, "renameatt: unknown relation: \"%s\"",
-                relname);
+           elog(ERROR, "renameatt: unknown relation: \"%s\"", relname);
        }
-       myrelid = relrdesc->rd_id;
-       heap_close(relrdesc);
 
+       myrelid = reltup->t_oid;
+       
        /* this routine is actually in the planner */
        children = find_all_inheritors(lconsi(myrelid, NIL), NIL);
 
-
        /*
         * find_all_inheritors does the recursive search of the
         * inheritance hierarchy, so all we have to do is process all of
@@ -130,72 +131,70 @@ renameatt(char *relname,
         */
        foreach(child, children)
        {
-           char       *childname;
+           char    childname[NAMEDATALEN];
 
            childrelid = lfirsti(child);
            if (childrelid == myrelid)
                continue;
-           relrdesc = heap_open(childrelid);
-           if (!RelationIsValid(relrdesc))
+           reltup = SearchSysCacheTuple(RELOID,
+                                        ObjectIdGetDatum(childrelid),
+                                        0, 0, 0);
+           if (!HeapTupleIsValid(reltup))
            {
                elog(ERROR, "renameatt: can't find catalog entry for inheriting class with oid %d",
                     childrelid);
            }
-           childname = (relrdesc->rd_rel->relname).data;
-           heap_close(relrdesc);
-           renameatt(childname, oldattname, newattname,
-                     userName, 0);     /* no more recursion! */
+           /* make copy of cache value, could disappear in call */
+           StrNCpy(childname,
+               ((Form_pg_class) GETSTRUCT(reltup))->relname.data,
+               NAMEDATALEN);
+           /* no more recursion! */
+           renameatt(childname, oldattname, newattname,  userName, 0);
        }
    }
 
-   relrdesc = heap_openr(RelationRelationName);
-   reltup = ClassNameIndexScan(relrdesc, relname);
-   if (!PointerIsValid(reltup))
-   {
-       heap_close(relrdesc);
-       elog(ERROR, "renameatt: relation \"%s\" nonexistent",
-            relname);
-       return;
-   }
-   heap_close(relrdesc);
+   reltup = SearchSysCacheTuple(RELNAME,
+                                PointerGetDatum(relname),
+                                0, 0, 0);
+   if (!HeapTupleIsValid(reltup))
+       elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
+
+   relid = reltup->t_oid;
+
+   oldatttup = SearchSysCacheTupleCopy(ATTNAME,
+                                        ObjectIdGetDatum(relid),
+                                        PointerGetDatum(oldattname),
+                                        0, 0);
+   if (!HeapTupleIsValid(oldatttup))
+       elog(ERROR, "renameatt: attribute \"%s\" nonexistent", oldattname);
 
-   attrdesc = heap_openr(AttributeRelationName);
-   oldatttup = AttributeNameIndexScan(attrdesc, reltup->t_oid, oldattname);
-   if (!PointerIsValid(oldatttup))
-   {
-       heap_close(attrdesc);
-       elog(ERROR, "renameatt: attribute \"%s\" nonexistent",
-            oldattname);
-   }
    if (((AttributeTupleForm) GETSTRUCT(oldatttup))->attnum < 0)
-   {
-       elog(ERROR, "renameatt: system attribute \"%s\" not renamed",
-            oldattname);
-   }
+       elog(ERROR, "renameatt: system attribute \"%s\" not renamed", oldattname);
 
-   newatttup = AttributeNameIndexScan(attrdesc, reltup->t_oid, newattname);
-   if (PointerIsValid(newatttup))
+   newatttup = SearchSysCacheTuple(ATTNAME,
+                                    ObjectIdGetDatum(relid),
+                                    PointerGetDatum(newattname),
+                                    0, 0);
+   /* should not already exist */
+   if (HeapTupleIsValid(newatttup))
    {
        pfree(oldatttup);
-       heap_close(attrdesc);
-       elog(ERROR, "renameatt: attribute \"%s\" exists",
-            newattname);
+       elog(ERROR, "renameatt: attribute \"%s\" exists", newattname);
    }
 
-   namestrcpy(&(((AttributeTupleForm) (GETSTRUCT(oldatttup)))->attname),
-              newattname);
-   oldTID = oldatttup->t_ctid;
+   StrNCpy((((AttributeTupleForm) (GETSTRUCT(oldatttup)))->attname.data),
+              newattname, NAMEDATALEN);
 
-   /* insert "fixed" tuple */
-   heap_replace(attrdesc, &oldTID, oldatttup);
+   attrelation = heap_openr(AttributeRelationName);
+   heap_replace(attrelation, &oldatttup->t_ctid, oldatttup);
 
    /* keep system catalog indices current */
-   CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
-   CatalogIndexInsert(idescs, Num_pg_attr_indices, attrdesc, oldatttup);
-   CatalogCloseIndices(Num_pg_attr_indices, idescs);
+   CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
+   CatalogIndexInsert(irelations, Num_pg_attr_indices, attrelation, oldatttup);
+   CatalogCloseIndices(Num_pg_attr_indices, irelations);
 
-   heap_close(attrdesc);
    pfree(oldatttup);
+   heap_close(attrelation);
 }
 
 /*
@@ -215,67 +214,52 @@ renameatt(char *relname,
  *             properly replace the new relation tuple.
  */
 void
-renamerel(char oldrelname[], char newrelname[])
+renamerel(char *oldrelname, char *newrelname)
 {
-   Relation    relrdesc;       /* for RELATION relation */
+   Relation    relrelation;        /* for RELATION relation */
    HeapTuple   oldreltup,
                newreltup;
-   ItemPointerData oldTID;
    char        oldpath[MAXPGPATH],
                newpath[MAXPGPATH];
-   Relation    idescs[Num_pg_class_indices];
-
+   Relation    irelations[Num_pg_class_indices];
+   
    if (IsSystemRelationName(oldrelname))
-   {
        elog(ERROR, "renamerel: system relation \"%s\" not renamed",
             oldrelname);
-       return;
-   }
+
    if (IsSystemRelationName(newrelname))
-   {
        elog(ERROR, "renamerel: Illegal class name: \"%s\" -- pg_ is reserved for system catalogs",
             newrelname);
-       return;
-   }
-
-   relrdesc = heap_openr(RelationRelationName);
-   oldreltup = ClassNameIndexScan(relrdesc, oldrelname);
 
-   if (!PointerIsValid(oldreltup))
-   {
-       heap_close(relrdesc);
-       elog(ERROR, "renamerel: relation \"%s\" does not exist",
-            oldrelname);
-   }
+   oldreltup = SearchSysCacheTupleCopy(RELNAME,
+                                        PointerGetDatum(oldrelname),
+                                        0, 0, 0);
+   if (!HeapTupleIsValid(oldreltup))
+       elog(ERROR, "renamerel: relation \"%s\" does not exist", oldrelname);
 
-   newreltup = ClassNameIndexScan(relrdesc, newrelname);
-   if (PointerIsValid(newreltup))
-   {
-       pfree(oldreltup);
-       heap_close(relrdesc);
-       elog(ERROR, "renamerel: relation \"%s\" exists",
-            newrelname);
-   }
+   newreltup = SearchSysCacheTuple(RELNAME,
+                                    PointerGetDatum(newrelname),
+                                    0, 0, 0);
+   if (HeapTupleIsValid(newreltup))
+       elog(ERROR, "renamerel: relation \"%s\" exists", newrelname);
 
-   /* rename the directory first, so if this fails the rename's not done */
+   /* rename the path first, so if this fails the rename's not done */
    strcpy(oldpath, relpath(oldrelname));
    strcpy(newpath, relpath(newrelname));
    if (rename(oldpath, newpath) < 0)
-       elog(ERROR, "renamerel: unable to rename file: %m");
+       elog(ERROR, "renamerel: unable to rename file: %s", oldpath);
 
-   memmove((char *) (((Form_pg_class) GETSTRUCT(oldreltup))->relname.data),
-           newrelname,
-           NAMEDATALEN);
-   oldTID = oldreltup->t_ctid;
+   StrNCpy((((Form_pg_class) GETSTRUCT(oldreltup))->relname.data),
+               newrelname, NAMEDATALEN);
 
    /* insert fixed rel tuple */
-   heap_replace(relrdesc, &oldTID, oldreltup);
+   relrelation = heap_openr(RelationRelationName);
+   heap_replace(relrelation, &oldreltup->t_ctid, oldreltup);
 
    /* keep the system catalog indices current */
-   CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
-   CatalogIndexInsert(idescs, Num_pg_class_indices, relrdesc, oldreltup);
-   CatalogCloseIndices(Num_pg_class_indices, idescs);
+   CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irelations);
+   CatalogIndexInsert(irelations, Num_pg_class_indices, relrelation, oldreltup);
+   CatalogCloseIndices(Num_pg_class_indices, irelations);
 
-   pfree(oldreltup);
-   heap_close(relrdesc);
+   heap_close(relrelation);
 }
index 2c81196ff7c7f4dd764b516c10d36cfa8f3d2db0..f28ec52b0099faa18a407e9730b6c0a784e11465 100644 (file)
@@ -395,18 +395,18 @@ init_sequence(char *caller, char *name)
 
    if (elm != (SeqTable) NULL) /* we opened sequence from our */
    {                           /* SeqTable - check relid ! */
-       if (RelationGetRelationId(elm->rel) != elm->relid)
+       if (RelationGetRelid(elm->rel) != elm->relid)
        {
            elog(NOTICE, "%s.%s: sequence was re-created",
                 name, caller, name);
            elm->cached = elm->last = elm->increment = 0;
-           elm->relid = RelationGetRelationId(elm->rel);
+           elm->relid = RelationGetRelid(elm->rel);
        }
    }
    else
    {
        elm = temp;
-       elm->relid = RelationGetRelationId(elm->rel);
+       elm->relid = RelationGetRelid(elm->rel);
        if (seqtab == (SeqTable) NULL)
            seqtab = elm;
        else
index 32db700c61ca9a2e3341e3c0e8a3911eb7e28016..6aa583cba4c420c94336369998f51d9c8700aa3e 100644 (file)
@@ -59,7 +59,6 @@ CreateTrigger(CreateTrigStmt *stmt)
    ScanKeyData key;
    Relation    relrdesc;
    HeapTuple   tuple;
-   ItemPointerData oldTID;
    Relation    idescs[Num_pg_trigger_indices];
    Relation    ridescs[Num_pg_class_indices];
    MemoryContext oldcxt;
@@ -118,9 +117,9 @@ CreateTrigger(CreateTrigStmt *stmt)
    tgrel = heap_openr(TriggerRelationName);
    RelationSetLockForWrite(tgrel);
    ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
-                          F_OIDEQ, rel->rd_id);
+                          F_OIDEQ, RelationGetRelid(rel));
    tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
-   while (tuple = heap_getnext(tgscan, 0, (Buffer *) NULL), PointerIsValid(tuple))
+   while (HeapTupleIsValid(tuple = heap_getnext(tgscan, 0)))
    {
        Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
 
@@ -135,7 +134,9 @@ CreateTrigger(CreateTrigStmt *stmt)
    MemSet(fargtypes, 0, 8 * sizeof(Oid));
    tuple = SearchSysCacheTuple(PRONAME,
                                PointerGetDatum(stmt->funcname),
-                               0, PointerGetDatum(fargtypes), 0);
+                               Int32GetDatum(0),
+                               PointerGetDatum(fargtypes),
+                               0);
    if (!HeapTupleIsValid(tuple) ||
        ((Form_pg_proc) GETSTRUCT(tuple))->prorettype != 0 ||
        ((Form_pg_proc) GETSTRUCT(tuple))->pronargs != 0)
@@ -157,7 +158,7 @@ CreateTrigger(CreateTrigStmt *stmt)
 
    MemSet(nulls, ' ', Natts_pg_trigger * sizeof(char));
 
-   values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(rel->rd_id);
+   values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel));
    values[Anum_pg_trigger_tgname - 1] = NameGetDatum(namein(stmt->trigname));
    values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_oid);
    values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
@@ -218,17 +219,16 @@ CreateTrigger(CreateTrigStmt *stmt)
    pfree(DatumGetPointer(values[Anum_pg_trigger_tgargs - 1]));
 
    /* update pg_class */
-   relrdesc = heap_openr(RelationRelationName);
-   tuple = ClassNameIndexScan(relrdesc, stmt->relname);
-   if (!PointerIsValid(tuple))
-   {
-       heap_close(relrdesc);
+   tuple = SearchSysCacheTupleCopy(RELNAME,
+                                    PointerGetDatum(stmt->relname),
+                                    0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "CreateTrigger: relation %s not found in pg_class", stmt->relname);
-   }
+
+   relrdesc = heap_openr(RelationRelationName);
    ((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found + 1;
    RelationInvalidateHeapTuple(relrdesc, tuple);
-   oldTID = tuple->t_ctid;
-   heap_replace(relrdesc, &oldTID, tuple);
+   heap_replace(relrdesc, &tuple->t_ctid, tuple);
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
    CatalogIndexInsert(ridescs, Num_pg_class_indices, relrdesc, tuple);
    CatalogCloseIndices(Num_pg_class_indices, ridescs);
@@ -254,12 +254,11 @@ DropTrigger(DropTrigStmt *stmt)
    ScanKeyData key;
    Relation    relrdesc;
    HeapTuple   tuple;
-   ItemPointerData oldTID;
    Relation    ridescs[Num_pg_class_indices];
    MemoryContext oldcxt;
    int         found = 0;
    int         tgfound = 0;
-
+   
 #ifndef NO_SECURITY
    if (!pg_ownercheck(GetPgUserName(), stmt->relname, RELNAME))
        elog(ERROR, "%s: %s", stmt->relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
@@ -274,9 +273,9 @@ DropTrigger(DropTrigStmt *stmt)
    tgrel = heap_openr(TriggerRelationName);
    RelationSetLockForWrite(tgrel);
    ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
-                          F_OIDEQ, rel->rd_id);
+                          F_OIDEQ, RelationGetRelid(rel));
    tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
-   while (tuple = heap_getnext(tgscan, 0, (Buffer *) NULL), PointerIsValid(tuple))
+   while (HeapTupleIsValid(tuple = heap_getnext(tgscan, 0)))
    {
        Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
 
@@ -298,18 +297,17 @@ DropTrigger(DropTrigStmt *stmt)
    RelationUnsetLockForWrite(tgrel);
    heap_close(tgrel);
 
+   tuple = SearchSysCacheTupleCopy(RELNAME,
+                                    PointerGetDatum(stmt->relname),
+                                    0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
+       elog(ERROR, "DropTrigger: relation %s not found in pg_class", stmt->relname);
+
    /* update pg_class */
    relrdesc = heap_openr(RelationRelationName);
-   tuple = ClassNameIndexScan(relrdesc, stmt->relname);
-   if (!PointerIsValid(tuple))
-   {
-       heap_close(relrdesc);
-       elog(ERROR, "DropTrigger: relation %s not found in pg_class", stmt->relname);
-   }
    ((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found;
    RelationInvalidateHeapTuple(relrdesc, tuple);
-   oldTID = tuple->t_ctid;
-   heap_replace(relrdesc, &oldTID, tuple);
+   heap_replace(relrdesc, &tuple->t_ctid, tuple);
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
    CatalogIndexInsert(ridescs, Num_pg_class_indices, relrdesc, tuple);
    CatalogCloseIndices(Num_pg_class_indices, ridescs);
@@ -338,11 +336,11 @@ RelationRemoveTriggers(Relation rel)
    tgrel = heap_openr(TriggerRelationName);
    RelationSetLockForWrite(tgrel);
    ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
-                          F_OIDEQ, rel->rd_id);
+                          F_OIDEQ, RelationGetRelid(rel));
 
    tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
 
-   while (tup = heap_getnext(tgscan, 0, (Buffer *) NULL), PointerIsValid(tup))
+   while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
        heap_delete(tgrel, &tup->t_ctid);
 
    heap_endscan(tgscan);
@@ -377,7 +375,7 @@ RelationBuildTriggers(Relation relation)
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
-                          ObjectIdGetDatum(relation->rd_id));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    tgrel = heap_openr(TriggerRelationName);
    RelationSetLockForRead(tgrel);
index fe0ee30201307f5a792300122f63d1f42ad1ba36..349e0aad07705da5f6c0dbcc9578edfb418c1ed3 100644 (file)
@@ -95,7 +95,6 @@ DefineUser(CreateUserStmt *stmt)
    HeapScanDesc scan;
    HeapTuple   tuple;
    Datum       datum;
-   Buffer      buffer;
    char        sql[512];
    char       *sql_end;
    bool        exists = false,
@@ -135,7 +134,7 @@ DefineUser(CreateUserStmt *stmt)
    RelationSetLockForWrite(pg_shadow_rel);
 
    scan = heap_beginscan(pg_shadow_rel, false, SnapshotNow, 0, NULL);
-   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer)))
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
    {
        datum = heap_getattr(tuple, Anum_pg_shadow_usename, pg_shadow_dsc, &n);
 
@@ -145,8 +144,6 @@ DefineUser(CreateUserStmt *stmt)
        datum = heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_shadow_dsc, &n);
        if ((int) datum > max_id)
            max_id = (int) datum;
-
-       ReleaseBuffer(buffer);
    }
    heap_endscan(scan);
 
@@ -223,15 +220,10 @@ AlterUser(AlterUserStmt *stmt)
    char       *pg_shadow;
    Relation    pg_shadow_rel;
    TupleDesc   pg_shadow_dsc;
-   HeapScanDesc scan;
    HeapTuple   tuple;
-   Datum       datum;
-   Buffer      buffer;
    char        sql[512];
    char       *sql_end;
-   bool        exists = false,
-               n,
-               inblock;
+   bool        inblock;
 
    if (stmt->password)
        CheckPgUserAclNotNull();
@@ -264,25 +256,14 @@ AlterUser(AlterUserStmt *stmt)
     */
    RelationSetLockForWrite(pg_shadow_rel);
 
-   scan = heap_beginscan(pg_shadow_rel, false, SnapshotNow, 0, NULL);
-   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer)))
-   {
-       datum = heap_getattr(tuple, Anum_pg_shadow_usename, pg_shadow_dsc, &n);
-
-       if (!strncmp((char *) datum, stmt->user, strlen(stmt->user)))
-       {
-           exists = true;
-           ReleaseBuffer(buffer);
-           break;
-       }
-   }
-   heap_endscan(scan);
-
-   if (!exists)
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(stmt->user),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
    {
        RelationUnsetLockForWrite(pg_shadow_rel);
        heap_close(pg_shadow_rel);
-       UserAbortTransactionBlock();
+       UserAbortTransactionBlock(); /* needed? */
        elog(ERROR, "alterUser: user \"%s\" does not exist", stmt->user);
        return;
    }
@@ -354,12 +335,11 @@ RemoveUser(char *user)
    HeapScanDesc scan;
    HeapTuple   tuple;
    Datum       datum;
-   Buffer      buffer;
    char        sql[512];
    bool        n,
                inblock;
-   int         usesysid = -1,
-               ndbase = 0;
+   int32       usesysid;
+   int         ndbase = 0;
    char      **dbase = NULL;
 
    if (!(inblock = IsTransactionBlock()))
@@ -375,7 +355,6 @@ RemoveUser(char *user)
        UserAbortTransactionBlock();
        elog(ERROR, "removeUser: user \"%s\" does not have SELECT and DELETE privilege for \"%s\"",
             pg_shadow, ShadowRelationName);
-       return;
    }
 
    /*
@@ -393,30 +372,19 @@ RemoveUser(char *user)
     */
    RelationSetLockForWrite(pg_shadow_rel);
 
-   scan = heap_beginscan(pg_shadow_rel, false, SnapshotNow, 0, NULL);
-   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer)))
-   {
-       datum = heap_getattr(tuple, Anum_pg_shadow_usename, pg_dsc, &n);
-
-       if (!strncmp((char *) datum, user, strlen(user)))
-       {
-           usesysid = (int) heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_dsc, &n);
-           ReleaseBuffer(buffer);
-           break;
-       }
-       ReleaseBuffer(buffer);
-   }
-   heap_endscan(scan);
-
-   if (usesysid == -1)
+   tuple = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(user),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(tuple))
    {
        RelationUnsetLockForWrite(pg_shadow_rel);
        heap_close(pg_shadow_rel);
        UserAbortTransactionBlock();
        elog(ERROR, "removeUser: user \"%s\" does not exist", user);
-       return;
    }
 
+   usesysid = (int32) heap_getattr(tuple, Anum_pg_shadow_usesysid, pg_dsc, &n);
+
    /*
     * Perform a scan of the pg_database relation to find the databases
     * owned by usesysid.  Then drop them.
@@ -425,7 +393,7 @@ RemoveUser(char *user)
    pg_dsc = RelationGetTupleDescriptor(pg_rel);
 
    scan = heap_beginscan(pg_rel, false, SnapshotNow, 0, NULL);
-   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0, &buffer)))
+   while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
    {
        datum = heap_getattr(tuple, Anum_pg_database_datdba, pg_dsc, &n);
 
@@ -440,7 +408,6 @@ RemoveUser(char *user)
                dbase[ndbase++][NAMEDATALEN] = '\0';
            }
        }
-       ReleaseBuffer(buffer);
    }
    heap_endscan(scan);
    heap_close(pg_rel);
@@ -496,17 +463,18 @@ RemoveUser(char *user)
 static void
 CheckPgUserAclNotNull()
 {
-   HeapTuple   htp;
+   HeapTuple   htup;
 
-   htp = SearchSysCacheTuple(RELNAME, PointerGetDatum(ShadowRelationName),
+   htup = SearchSysCacheTuple(RELNAME,
+                             PointerGetDatum(ShadowRelationName),
                              0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   if (!HeapTupleIsValid(htup))
    {
        elog(ERROR, "IsPgUserAclNull: class \"%s\" not found",
             ShadowRelationName);
    }
 
-   if (heap_attisnull(htp, Anum_pg_class_relacl))
+   if (heap_attisnull(htup, Anum_pg_class_relacl))
    {
        elog(NOTICE, "To use passwords, you have to revoke permissions on pg_shadow");
        elog(NOTICE, "so normal users can not read the passwords.");
index 40e5c3c3c3ff9f9505b15cc0f10caedae6db89ce..bf2752dfa9261d099138d8c2c2c8d7b70b7b5ba6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.69 1998/07/27 19:37:53 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.70 1998/08/19 02:01:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,7 +55,7 @@
 
  /* #include  *//* Why? */
 
-extern int BlowawayRelationBuffers(Relation rdesc, BlockNumber block);
+extern int BlowawayRelationBuffers(Relation rel, BlockNumber block);
 
 bool       VacuumRunning = false;
 
@@ -84,7 +84,7 @@ static void vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList vpl);
 static void vc_vacpage(Page page, VPageDescr vpd);
 static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups);
 static void vc_scanoneind(Relation indrel, int nhtups);
-static void vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple htup);
+static void vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple tuple);
 static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum *bucket, int16 *bucket_len);
 static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelstats);
 static void vc_delhilowstats(Oid relid, int attcnt, int *attnums);
@@ -261,7 +261,6 @@ vc_getrels(NameData *VacRelP)
    TupleDesc   pgcdesc;
    HeapScanDesc pgcscan;
    HeapTuple   pgctup;
-   Buffer      buf;
    PortalVariableMemory portalmem;
    MemoryContext old;
    VRelList    vrl,
@@ -270,8 +269,8 @@ vc_getrels(NameData *VacRelP)
    char       *rname;
    char        rkind;
    bool        n;
-   ScanKeyData pgckey;
    bool        found = false;
+   ScanKeyData pgckey;
 
    StartTransactionCommand();
 
@@ -295,9 +294,8 @@ vc_getrels(NameData *VacRelP)
 
    pgcscan = heap_beginscan(pgclass, false, SnapshotNow, 1, &pgckey);
 
-   while (HeapTupleIsValid(pgctup = heap_getnext(pgcscan, 0, &buf)))
+   while (HeapTupleIsValid(pgctup = heap_getnext(pgcscan, 0)))
    {
-
        found = true;
 
        d = heap_getattr(pgctup, Anum_pg_class_relname, pgcdesc, &n);
@@ -314,7 +312,6 @@ vc_getrels(NameData *VacRelP)
        {
            elog(NOTICE, "Rel %s: can't vacuum LargeObjects now",
                 rname);
-           ReleaseBuffer(buf);
            continue;
        }
 
@@ -325,7 +322,6 @@ vc_getrels(NameData *VacRelP)
        /* skip system relations */
        if (rkind != 'r')
        {
-           ReleaseBuffer(buf);
            elog(NOTICE, "Vacuum: can not process index and certain system tables");
            continue;
        }
@@ -343,9 +339,6 @@ vc_getrels(NameData *VacRelP)
 
        cur->vrl_relid = pgctup->t_oid;
        cur->vrl_next = (VRelList) NULL;
-
-       /* wei hates it if you forget to do this */
-       ReleaseBuffer(buf);
    }
    if (found == false)
        elog(NOTICE, "Vacuum: table not found");
@@ -378,10 +371,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
    TupleDesc   pgcdesc;
    HeapTuple   pgctup,
                pgttup;
-   Buffer      pgcbuf;
-   HeapScanDesc pgcscan;
    Relation    onerel;
-   ScanKeyData pgckey;
    VPageListData Vvpl;         /* List of pages to vacuum and/or clean
                                 * indices */
    VPageListData Fvpl;         /* List of pages with space enough for
@@ -394,22 +384,18 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
 
    StartTransactionCommand();
 
-   ScanKeyEntryInitialize(&pgckey, 0x0, ObjectIdAttributeNumber,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(relid));
-
    pgclass = heap_openr(RelationRelationName);
    pgcdesc = RelationGetTupleDescriptor(pgclass);
-   pgcscan = heap_beginscan(pgclass, false, SnapshotNow, 1, &pgckey);
 
    /*
     * Race condition -- if the pg_class tuple has gone away since the
     * last time we saw it, we don't need to vacuum it.
     */
-
-   if (!HeapTupleIsValid(pgctup = heap_getnext(pgcscan, 0, &pgcbuf)))
+   pgctup = SearchSysCacheTuple(RELOID,
+                                ObjectIdGetDatum(relid),
+                                0, 0, 0);
+   if (!HeapTupleIsValid(pgctup))
    {
-       heap_endscan(pgcscan);
        heap_close(pgclass);
        CommitTransactionCommand();
        return;
@@ -508,7 +494,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
                stats->f_cmpgt.fn_addr = NULL;
 
            pgttup = SearchSysCacheTuple(TYPOID,
-                                ObjectIdGetDatum(stats->attr->atttypid),
+                                    ObjectIdGetDatum(stats->attr->atttypid),
                                         0, 0, 0);
            if (HeapTupleIsValid(pgttup))
                stats->outfunc = ((TypeTupleForm) GETSTRUCT(pgttup))->typoutput;
@@ -581,7 +567,6 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
 
    /* all done with this class */
    heap_close(onerel);
-   heap_endscan(pgcscan);
    heap_close(pgclass);
 
    /* update statistics in pg_class */
@@ -610,8 +595,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                blkno;
    ItemId      itemid;
    ItemPointer itemptr;
-   HeapTuple   htup;
    Buffer      buf;
+   HeapTuple   tuple;
    Page        page,
                tempPage = NULL;
    OffsetNumber offnum,
@@ -706,23 +691,23 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                continue;
            }
 
-           htup = (HeapTuple) PageGetItem(page, itemid);
+           tuple = (HeapTuple) PageGetItem(page, itemid);
            tupgone = false;
 
-           if (!(htup->t_infomask & HEAP_XMIN_COMMITTED))
+           if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
            {
-               if (htup->t_infomask & HEAP_XMIN_INVALID)
+               if (tuple->t_infomask & HEAP_XMIN_INVALID)
                    tupgone = true;
                else
                {
-                   if (TransactionIdDidAbort(htup->t_xmin))
+                   if (TransactionIdDidAbort(tuple->t_xmin))
                        tupgone = true;
-                   else if (TransactionIdDidCommit(htup->t_xmin))
+                   else if (TransactionIdDidCommit(tuple->t_xmin))
                    {
-                       htup->t_infomask |= HEAP_XMIN_COMMITTED;
+                       tuple->t_infomask |= HEAP_XMIN_COMMITTED;
                        pgchanged = true;
                    }
-                   else if (!TransactionIdIsInProgress(htup->t_xmin))
+                   else if (!TransactionIdIsInProgress(tuple->t_xmin))
                    {
 
                        /*
@@ -735,7 +720,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                    else
                    {
                        elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
-                            relname, blkno, offnum, htup->t_xmin);
+                            relname, blkno, offnum, tuple->t_xmin);
                        do_shrinking = false;
                    }
                }
@@ -745,32 +730,32 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
             * here we are concerned about tuples with xmin committed and
             * xmax unknown or committed
             */
-           if (htup->t_infomask & HEAP_XMIN_COMMITTED &&
-               !(htup->t_infomask & HEAP_XMAX_INVALID))
+           if (tuple->t_infomask & HEAP_XMIN_COMMITTED &&
+               !(tuple->t_infomask & HEAP_XMAX_INVALID))
            {
-               if (htup->t_infomask & HEAP_XMAX_COMMITTED)
+               if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
                    tupgone = true;
-               else if (TransactionIdDidAbort(htup->t_xmax))
+               else if (TransactionIdDidAbort(tuple->t_xmax))
                {
-                   htup->t_infomask |= HEAP_XMAX_INVALID;
+                   tuple->t_infomask |= HEAP_XMAX_INVALID;
                    pgchanged = true;
                }
-               else if (TransactionIdDidCommit(htup->t_xmax))
+               else if (TransactionIdDidCommit(tuple->t_xmax))
                    tupgone = true;
-               else if (!TransactionIdIsInProgress(htup->t_xmax))
+               else if (!TransactionIdIsInProgress(tuple->t_xmax))
                {
 
                    /*
                     * Not Aborted, Not Committed, Not in Progress - so it
                     * from crashed process. - vadim 06/02/97
                     */
-                   htup->t_infomask |= HEAP_XMAX_INVALID;;
+                   tuple->t_infomask |= HEAP_XMAX_INVALID;;
                    pgchanged = true;
                }
                else
                {
                    elog(NOTICE, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
-                        relname, blkno, offnum, htup->t_xmax);
+                        relname, blkno, offnum, tuple->t_xmax);
                    do_shrinking = false;
                }
            }
@@ -779,7 +764,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
             * It's possibly! But from where it comes ? And should we fix
             * it ?  - vadim 11/28/96
             */
-           itemptr = &(htup->t_ctid);
+           itemptr = &(tuple->t_ctid);
            if (!ItemPointerIsValid(itemptr) ||
                BlockIdGetBlockNumber(&(itemptr->ip_blkid)) != blkno)
            {
@@ -792,13 +777,13 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
            /*
             * Other checks...
             */
-           if (htup->t_len != itemid->lp_len)
+           if (tuple->t_len != itemid->lp_len)
            {
                elog(NOTICE, "Rel %s: TID %u/%u: TUPLE_LEN IN PAGEHEADER %u IS NOT THE SAME AS IN TUPLEHEADER %u. TUPGONE %d.",
                     relname, blkno, offnum,
-                    itemid->lp_len, htup->t_len, tupgone);
+                    itemid->lp_len, tuple->t_len, tupgone);
            }
-           if (!OidIsValid(htup->t_oid))
+           if (!OidIsValid(tuple->t_oid))
            {
                elog(NOTICE, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
                     relname, blkno, offnum, tupgone);
@@ -830,11 +815,11 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
            {
                ntups++;
                notup = false;
-               if (htup->t_len < min_tlen)
-                   min_tlen = htup->t_len;
-               if (htup->t_len > max_tlen)
-                   max_tlen = htup->t_len;
-               vc_attrstats(onerel, vacrelstats, htup);
+               if (tuple->t_len < min_tlen)
+                   min_tlen = tuple->t_len;
+               if (tuple->t_len > max_tlen)
+                   max_tlen = tuple->t_len;
+               vc_attrstats(onerel, vacrelstats, tuple);
            }
        }
 
@@ -947,7 +932,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                moff;
    ItemId      itemid,
                newitemid;
-   HeapTuple   htup,
+   HeapTuple   tuple,
                newtup;
    TupleDesc   tupdesc = NULL;
    Datum      *idatum = NULL;
@@ -1064,8 +1049,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
            if (!ItemIdIsUsed(itemid))
                continue;
 
-           htup = (HeapTuple) PageGetItem(page, itemid);
-           tlen = htup->t_len;
+           tuple = (HeapTuple) PageGetItem(page, itemid);
+           tlen = tuple->t_len;
 
            /* try to find new page for this tuple */
            if (ToBuf == InvalidBuffer ||
@@ -1112,7 +1097,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
 
            /* copy tuple */
            newtup = (HeapTuple) palloc(tlen);
-           memmove((char *) newtup, (char *) htup, tlen);
+           memmove((char *) newtup, (char *) tuple, tlen);
 
            /* store transaction information */
            TransactionIdStore(myXID, &(newtup->t_xmin));
@@ -1138,10 +1123,10 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
            ItemPointerSet(&(newtup->t_ctid), ToVpd->vpd_blkno, newoff);
 
            /* now logically delete end-tuple */
-           TransactionIdStore(myXID, &(htup->t_xmax));
-           htup->t_cmax = myCID;
+           TransactionIdStore(myXID, &(tuple->t_xmax));
+           tuple->t_cmax = myCID;
            /* set xmax to unknown */
-           htup->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
+           tuple->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
 
            ToVpd->vpd_nusd++;
            nmoved++;
@@ -1158,7 +1143,6 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                               (AttrNumber *) &(idcur->tform->indkey[0]),
                                   newtup,
                                   tupdesc,
-                                  InvalidBuffer,
                                   idatum,
                                   inulls,
                                   idcur->finfoP);
@@ -1244,10 +1228,10 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                itemid = PageGetItemId(page, newoff);
                if (!ItemIdIsUsed(itemid))
                    continue;
-               htup = (HeapTuple) PageGetItem(page, itemid);
-               if (TransactionIdEquals((TransactionId) htup->t_xmin, myXID))
+               tuple = (HeapTuple) PageGetItem(page, itemid);
+               if (TransactionIdEquals((TransactionId) tuple->t_xmin, myXID))
                {
-                   htup->t_infomask |= HEAP_XMIN_COMMITTED;
+                   tuple->t_infomask |= HEAP_XMIN_COMMITTED;
                    ntups++;
                }
            }
@@ -1307,8 +1291,8 @@ Elapsed %u/%u sec.",
                itemid = PageGetItemId(page, offnum);
                if (!ItemIdIsUsed(itemid))
                    continue;
-               htup = (HeapTuple) PageGetItem(page, itemid);
-               Assert(TransactionIdEquals((TransactionId) htup->t_xmax, myXID));
+               tuple = (HeapTuple) PageGetItem(page, itemid);
+               Assert(TransactionIdEquals((TransactionId) tuple->t_xmax, myXID));
                itemid->lp_flags &= ~LP_USED;
                ntups++;
            }
@@ -1453,7 +1437,7 @@ vc_scanoneind(Relation indrel, int nhtups)
 
    /* now update statistics in pg_class */
    nipages = RelationGetNumberOfBlocks(indrel);
-   vc_updstats(indrel->rd_id, nipages, nitups, false, NULL);
+   vc_updstats(RelationGetRelid(indrel), nipages, nitups, false, NULL);
 
    getrusage(RUSAGE_SELF, &ru1);
 
@@ -1526,7 +1510,6 @@ vc_vaconeind(VPageList vpl, Relation indrel, int nhtups)
        else
            nitups++;
 
-       /* be tidy */
        pfree(res);
    }
 
@@ -1534,7 +1517,7 @@ vc_vaconeind(VPageList vpl, Relation indrel, int nhtups)
 
    /* now update statistics in pg_class */
    nipages = RelationGetNumberOfBlocks(indrel);
-   vc_updstats(indrel->rd_id, nipages, nitups, false, NULL);
+   vc_updstats(RelationGetRelid(indrel), nipages, nitups, false, NULL);
 
    getrusage(RUSAGE_SELF, &ru1);
 
@@ -1615,7 +1598,7 @@ vc_tidreapped(ItemPointer itemptr, VPageList vpl)
  *
  */
 static void
-vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple htup)
+vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple tuple)
 {
    int         i,
                attr_cnt = vacrelstats->va_natts;
@@ -1629,7 +1612,7 @@ vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple htup)
        VacAttrStats *stats = &vacattrstats[i];
        bool        value_hit = true;
 
-       value = heap_getattr(htup,
+       value = heap_getattr(tuple,
                             stats->attr->attnum, tupDesc, &isnull);
 
        if (!VacAttrStatsEqValid(stats))
@@ -1751,35 +1734,28 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
    Relation    rd,
                ad,
                sd;
-   HeapScanDesc rsdesc,
-               asdesc;
-   TupleDesc   sdesc;
+   HeapScanDesc scan;
    HeapTuple   rtup,
                atup,
                stup;
-   Buffer      rbuf,
-               abuf;
    Form_pg_class pgcform;
-   ScanKeyData rskey,
-               askey;
+   ScanKeyData askey;
    AttributeTupleForm attp;
 
    /*
     * update number of tuples and number of pages in pg_class
     */
-   ScanKeyEntryInitialize(&rskey, 0x0, ObjectIdAttributeNumber,
-                          F_OIDEQ,
-                          ObjectIdGetDatum(relid));
+   rtup = SearchSysCacheTupleCopy(RELOID,
+                                    ObjectIdGetDatum(relid),
+                                    0, 0, 0);
+   if (!HeapTupleIsValid(rtup))
+       elog(ERROR, "pg_class entry for relid %d vanished during vacuuming",
+               relid);
 
    rd = heap_openr(RelationRelationName);
-   rsdesc = heap_beginscan(rd, false, SnapshotNow, 1, &rskey);
-
-   if (!HeapTupleIsValid(rtup = heap_getnext(rsdesc, 0, &rbuf)))
-       elog(ERROR, "pg_class entry for relid %d vanished during vacuuming",
-            relid);
 
    /* overwrite the existing statistics in the tuple */
-   vc_setpagelock(rd, BufferGetBlockNumber(rbuf));
+   vc_setpagelock(rd, ItemPointerGetBlockNumber(&rtup->t_ctid));
    pgcform = (Form_pg_class) GETSTRUCT(rtup);
    pgcform->reltuples = ntups;
    pgcform->relpages = npages;
@@ -1795,9 +1771,9 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
        ScanKeyEntryInitialize(&askey, 0, Anum_pg_attribute_attrelid,
                               F_INT4EQ, relid);
 
-       asdesc = heap_beginscan(ad, false, SnapshotNow, 1, &askey);
+       scan = heap_beginscan(ad, false, SnapshotNow, 1, &askey);
 
-       while (HeapTupleIsValid(atup = heap_getnext(asdesc, 0, &abuf)))
+       while (HeapTupleIsValid(atup = heap_getnext(scan, 0)))
        {
            int         i;
            float32data selratio;       /* average ratio of rows selected
@@ -1824,7 +1800,7 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
            if (VacAttrStatsEqValid(stats))
            {
 
-               vc_setpagelock(ad, BufferGetBlockNumber(abuf));
+               vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_ctid));
 
                if (stats->nonnull_cnt + stats->null_cnt == 0 ||
                    (stats->null_cnt <= 1 && stats->best_cnt == 1))
@@ -1853,7 +1829,7 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
                if (selratio > 1.0)
                    selratio = 1.0;
                attp->attdisbursion = selratio;
-               WriteNoReleaseBuffer(abuf);
+               WriteNoReleaseBuffer(ItemPointerGetBlockNumber(&atup->t_ctid));
 
                /* DO PG_STATISTIC INSERTS */
 
@@ -1888,9 +1864,7 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
                    values[i++] = (Datum) fmgr(F_TEXTIN, out_string);
                    pfree(out_string);
 
-                   sdesc = sd->rd_att;
-
-                   stup = heap_formtuple(sdesc, values, nulls);
+                   stup = heap_formtuple(sd->rd_att, values, nulls);
 
                    /* ----------------
                     *  insert the tuple in the relation and get the tuple's oid.
@@ -1903,13 +1877,15 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
                }
            }
        }
-       heap_endscan(asdesc);
+       heap_endscan(scan);
        heap_close(ad);
        heap_close(sd);
    }
 
    /* XXX -- after write, should invalidate relcache in other backends */
-   WriteNoReleaseBuffer(rbuf); /* heap_endscan release scan' buffers ? */
+#ifdef NOT_USED
+   WriteNoReleaseBuffer(&rtup->t_ctid); /* heap_endscan release scan' buffers ? */
+#endif
 
    /*
     * invalidating system relations confuses the function cache of
@@ -1918,8 +1894,7 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
    if (!IsSystemRelationName(pgcform->relname.data))
        RelationInvalidateHeapTuple(rd, rtup);
 
-   /* that's all, folks */
-   heap_endscan(rsdesc);
+   pfree(rtup);
    heap_close(rd);
 }
 
@@ -1947,7 +1922,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
    else
        pgsscan = heap_beginscan(pgstatistic, false, SnapshotNow, 0, NULL);
 
-   while (HeapTupleIsValid(pgstup = heap_getnext(pgsscan, 0, NULL)))
+   while (HeapTupleIsValid(pgstup = heap_getnext(pgsscan, 0)))
    {
        if (attcnt > 0)
        {
@@ -2156,7 +2131,7 @@ vc_getindices(Oid relid, int *nindices, Relation **Irel)
 
    pgiscan = heap_beginscan(pgindex, false, SnapshotNow, 1, &pgikey);
 
-   while (HeapTupleIsValid(pgitup = heap_getnext(pgiscan, 0, NULL)))
+   while (HeapTupleIsValid(pgitup = heap_getnext(pgiscan, 0)))
    {
        d = heap_getattr(pgitup, Anum_pg_index_indexrelid,
                         pgidesc, &n);
@@ -2233,7 +2208,7 @@ vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc)
    {
        pgIndexTup =
            SearchSysCacheTuple(INDEXRELID,
-                               ObjectIdGetDatum(Irel[i]->rd_id),
+                               ObjectIdGetDatum(RelationGetRelid(Irel[i])),
                                0, 0, 0);
        Assert(pgIndexTup);
        idcur->tform = (IndexTupleForm) GETSTRUCT(pgIndexTup);
index 41bb1dc5d41febaaadbacbe477ffde000201b411..41943446a7ea2052d9f6fac2dfe3b73ced597014 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.52 1998/08/06 05:12:33 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.53 1998/08/19 02:01:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -283,7 +283,7 @@ ExecCheckPerms(CmdType operation,
 {
    int         i = 1;
    Oid         relid;
-   HeapTuple   htp;
+   HeapTuple   htup;
    List       *lp;
    List       *qvars,
               *tvars;
@@ -314,14 +314,14 @@ ExecCheckPerms(CmdType operation,
        }
 
        relid = rte->relid;
-       htp = SearchSysCacheTuple(RELOID,
+       htup = SearchSysCacheTuple(RELOID,
                                  ObjectIdGetDatum(relid),
                                  0, 0, 0);
-       if (!HeapTupleIsValid(htp))
+       if (!HeapTupleIsValid(htup))
            elog(ERROR, "ExecCheckPerms: bogus RT relid: %d",
                 relid);
        StrNCpy(rname.data,
-               ((Form_pg_class) GETSTRUCT(htp))->relname.data,
+               ((Form_pg_class) GETSTRUCT(htup))->relname.data,
                NAMEDATALEN);
        if (i == resultRelation)
        {                       /* this is the result relation */
@@ -1290,9 +1290,10 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
    if (repl == NULL)
        return (tuple);
 
-   newtuple = heap_modifytuple(tuple, InvalidBuffer, rel, replValue, replNull, repl);
+   newtuple = heap_modifytuple(tuple, rel, replValue, replNull, repl);
 
    pfree(repl);
+   pfree(tuple);
    pfree(replNull);
    pfree(replValue);
 
@@ -1323,7 +1324,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
    slot->ttc_whichplan = -1;
    rte->relname = nameout(&(rel->rd_rel->relname));
    rte->refname = rte->relname;
-   rte->relid = rel->rd_id;
+   rte->relid = RelationGetRelid(rel);
    rte->inh = false;
    rte->inFromCl = true;
    rtlist = lcons(rte, NIL);
index 158f78ebcdbbfc151c7a0350dac8fd1a4975f983..489fc9096a8bb822473b156f6d9dbad7a03b25d1 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.34 1998/07/27 19:37:56 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.35 1998/08/19 02:02:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -760,10 +760,7 @@ ExecOpenIndices(Oid resultRelationOid,
    fiList = NIL;
    predList = NIL;
 
-   while (tuple = heap_getnext(indexSd,        /* scan desc */
-                               false,  /* scan backward flag */
-                               NULL),  /* return: buffer */
-          HeapTupleIsValid(tuple))
+   while (HeapTupleIsValid(tuple = heap_getnext(indexSd, 0)))
    {
 
        /* ----------------
@@ -1020,8 +1017,6 @@ ExecFormIndexTuple(HeapTuple heapTuple,
                   keyAttributeNumbers, /* array of att nums to extract */
                   heapTuple,   /* tuple from base relation */
                   heapDescriptor,      /* heap tuple's descriptor */
-                  InvalidBuffer,       /* buffer associated with heap
-                                        * tuple */
                   datum,       /* return: array of attributes */
                   nulls,       /* return: array of char's */
                   fInfoP);     /* functional index information */
@@ -1136,8 +1131,6 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
                                                 * extract */
                       heapTuple,       /* tuple from base relation */
                       heapDescriptor,  /* heap tuple's descriptor */
-                      InvalidBuffer,   /* buffer associated with heap
-                                        * tuple */
                       datum,   /* return: array of attributes */
                       nulls,   /* return: array of char's */
                       fInfoP); /* functional index information */
index 55cc9d926fad62c6b5bbf038bc864ea8121f3ae5..cdc15c7e0c93cf87bf991c67bcf4f9124ee5929d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.23 1998/08/04 18:42:38 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.24 1998/08/19 02:02:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -123,7 +123,6 @@ IndexNext(IndexScan *node)
        {
            tuple = heap_fetch(heapRelation, snapshot,
                                &result->heap_iptr, &buffer);
-           /* be tidy */
            pfree(result);
 
            if (tuple != NULL)
@@ -224,7 +223,7 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
    ScanDirection direction;
    IndexScanDescPtr scanDescs;
    ScanKey    *scanKeys;
-   IndexScanDesc sdesc;
+   IndexScanDesc scan;
    ScanKey     skey;
    int         numIndices;
    int         i;
@@ -301,9 +300,9 @@ ExecIndexReScan(IndexScan *node, ExprContext *exprCtxt, Plan *parent)
                }
            }
        }
-       sdesc = scanDescs[i];
+       scan = scanDescs[i];
        skey = scanKeys[i];
-       index_rescan(sdesc, direction, skey);
+       index_rescan(scan, direction, skey);
    }
    /* ----------------
     *  perhaps return something meaningful
index e58bc39f5e42cd5e7555dd7bbb91ee048c4d4980..3d5496c7e665bd35021b86688a0df73538a9094a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.14 1998/07/27 19:37:57 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.15 1998/08/19 02:02:03 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -59,7 +59,6 @@ ExecMaterial(Material *node)
    HeapScanDesc currentScanDesc;
    HeapTuple   heapTuple;
    TupleTableSlot *slot;
-   Buffer      buffer;
 
    /* ----------------
     *  get state info from node
@@ -162,10 +161,7 @@ ExecMaterial(Material *node)
     */
    currentScanDesc = matstate->csstate.css_currentScanDesc;
 
-   heapTuple = heap_getnext(currentScanDesc,   /* scan desc */
-                            ScanDirectionIsBackward(dir),
-   /* bkwd flag */
-                            &buffer);  /* return: buffer */
+   heapTuple = heap_getnext(currentScanDesc, ScanDirectionIsBackward(dir));
 
    /* ----------------
     *  put the tuple into the scan tuple slot and return the slot.
@@ -177,7 +173,7 @@ ExecMaterial(Material *node)
 
    return ExecStoreTuple(heapTuple,    /* tuple to store */
                          slot, /* slot to store in */
-                         buffer,       /* buffer for this tuple */
+                         currentScanDesc->rs_cbuf, /* buffer for this tuple */
                          false);       /* don't pfree this pointer */
 
 }
@@ -370,7 +366,7 @@ List                            /* nothing of interest */
 ExecMaterialMarkPos(Material node)
 {
    MaterialState matstate;
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
 
    /* ----------------
     *  if we haven't materialized yet, just return NIL.
@@ -386,8 +382,8 @@ ExecMaterialMarkPos(Material node)
     *      they will never return positions for all I know -cim 10/16/89
     * ----------------
     */
-   sdesc = get_css_currentScanDesc((CommonScanState) matstate);
-   heap_markpos(sdesc);
+   scan = get_css_currentScanDesc((CommonScanState) matstate);
+   heap_markpos(scan);
 
    return NIL;
 }
@@ -400,7 +396,7 @@ void
 ExecMaterialRestrPos(Material node)
 {
    MaterialState matstate;
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
 
    /* ----------------
     *  if we haven't materialized yet, just return.
@@ -414,8 +410,8 @@ ExecMaterialRestrPos(Material node)
     *  restore the scan to the previously marked position
     * ----------------
     */
-   sdesc = get_css_currentScanDesc((CommonScanState) matstate);
-   heap_restrpos(sdesc);
+   scan = get_css_currentScanDesc((CommonScanState) matstate);
+   heap_restrpos(scan);
 }
 
 #endif
index 1ff4f1f13eb3d4686561d57ca40e85efed46f4c8..80bdef829376b062141f38dfbf80a9add1bbdfde 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.11 1998/07/27 19:37:57 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.12 1998/08/19 02:02:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,7 +55,6 @@ SeqNext(SeqScan *node)
    EState     *estate;
    ScanDirection direction;
    TupleTableSlot *slot;
-   Buffer      buffer;
 
    /* ----------------
     *  get information from the estate and scan state
@@ -70,9 +69,7 @@ SeqNext(SeqScan *node)
     *  get the next tuple from the access methods
     * ----------------
     */
-   tuple = heap_getnext(scandesc,      /* scan desc */
-                        ScanDirectionIsBackward(direction),    /* backward flag */
-                        &buffer);      /* return: buffer */
+   tuple = heap_getnext(scandesc, ScanDirectionIsBackward(direction));
 
    /* ----------------
     *  save the tuple and the buffer returned to us by the access methods
@@ -86,8 +83,7 @@ SeqNext(SeqScan *node)
 
    slot = ExecStoreTuple(tuple,/* tuple to store */
                          slot, /* slot to store in */
-                         buffer,       /* buffer associated with this
-                                        * tuple */
+                         scandesc->rs_cbuf,/* buffer associated with this tuple */
                          false);       /* don't pfree this pointer */
 
    /* ----------------
@@ -364,8 +360,8 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
    CommonScanState *scanstate;
    EState     *estate;
    Plan       *outerPlan;
-   Relation    rdesc;
-   HeapScanDesc sdesc;
+   Relation    rel;
+   HeapScanDesc scan;
    ScanDirection direction;
 
    scanstate = node->scanstate;
@@ -380,11 +376,11 @@ ExecSeqReScan(SeqScan *node, ExprContext *exprCtxt, Plan *parent)
    else
    {
        /* otherwise, we are scanning a relation */
-       rdesc = scanstate->css_currentRelation;
-       sdesc = scanstate->css_currentScanDesc;
+       rel = scanstate->css_currentRelation;
+       scan = scanstate->css_currentScanDesc;
        direction = estate->es_direction;
-       sdesc = ExecReScanR(rdesc, sdesc, direction, 0, NULL);
-       scanstate->css_currentScanDesc = sdesc;
+       scan = ExecReScanR(rel, scan, direction, 0, NULL);
+       scanstate->css_currentScanDesc = scan;
    }
 }
 
@@ -399,7 +395,7 @@ ExecSeqMarkPos(SeqScan *node)
 {
    CommonScanState *scanstate;
    Plan       *outerPlan;
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
 
    scanstate = node->scanstate;
 
@@ -421,8 +417,8 @@ ExecSeqMarkPos(SeqScan *node)
     *
     * ----------------
     */
-   sdesc = scanstate->css_currentScanDesc;
-   heap_markpos(sdesc);
+   scan = scanstate->css_currentScanDesc;
+   heap_markpos(scan);
 
    return;
 }
@@ -438,7 +434,7 @@ ExecSeqRestrPos(SeqScan *node)
 {
    CommonScanState *scanstate;
    Plan       *outerPlan;
-   HeapScanDesc sdesc;
+   HeapScanDesc scan;
 
    scanstate = node->scanstate;
 
@@ -459,6 +455,6 @@ ExecSeqRestrPos(SeqScan *node)
     *  position using the access methods..
     * ----------------
     */
-   sdesc = scanstate->css_currentScanDesc;
-   heap_restrpos(sdesc);
+   scan = scanstate->css_currentScanDesc;
+   heap_restrpos(scan);
 }
index c23c7d65d404e42e34d3424e5b0224adbb65fca4..c7a0a99a277e392f4687df778cf673cd7244110e 100644 (file)
@@ -15,7 +15,7 @@
  *     ExecEndTee
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.20 1998/08/06 05:12:36 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.21 1998/08/19 02:02:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -303,7 +303,6 @@ ExecTee(Tee *node, Plan *parent)
    HeapTuple   heapTuple;
    Relation    bufferRel;
    HeapScanDesc scanDesc;
-   Buffer      buffer;
 
    estate = ((Plan *) node)->state;
    teeState = node->teestate;
@@ -366,10 +365,7 @@ ExecTee(Tee *node, Plan *parent)
                HeapTuple   throwAway;
 
                /* Buffer buffer; */
-               throwAway = heap_getnext(scanDesc,
-                                        ScanDirectionIsBackward(dir),
-               /* &buffer */
-                                        (Buffer *) NULL);
+               throwAway = heap_getnext(scanDesc,ScanDirectionIsBackward(dir));
            }
 
            /*
@@ -393,9 +389,7 @@ ExecTee(Tee *node, Plan *parent)
        scanDesc = (parent == node->leftParent) ?
            teeState->tee_leftScanDesc : teeState->tee_rightScanDesc;
 
-       heapTuple = heap_getnext(scanDesc,
-                                ScanDirectionIsBackward(dir),
-                                &buffer);
+       heapTuple = heap_getnext(scanDesc, ScanDirectionIsBackward(dir));
 
        /*
         * Increase the pin count on the buffer page, because the tuple
@@ -404,15 +398,15 @@ ExecTee(Tee *node, Plan *parent)
         * count on the next iteration.
         */
 
-       if (buffer != InvalidBuffer)
-           IncrBufferRefCount(buffer);
+       if (scanDesc->rs_cbuf != InvalidBuffer)
+           IncrBufferRefCount(scanDesc->rs_cbuf);
 
        slot = teeState->cstate.cs_ResultTupleSlot;
        slot->ttc_tupleDescriptor = RelationGetTupleDescriptor(bufferRel);
 
        result = ExecStoreTuple(heapTuple,      /* tuple to store */
                                slot,   /* slot to store in */
-                               buffer, /* this tuple's buffer */
+                               scanDesc->rs_cbuf, /* this tuple's buffer */
                                false); /* don't free stuff from
                                         * heap_getnext */
 
index 040baa7d42efacb58760e5db868e8730c542e254..e2e87d88e069aadfa07a6eb6a020444a346468d4 100644 (file)
@@ -466,7 +466,7 @@ SPI_gettype(TupleDesc tupdesc, int fnumber)
    }
 
    typeTuple = SearchSysCacheTuple(TYPOID,
-                ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid),
+                    ObjectIdGetDatum(tupdesc->attrs[fnumber - 1]->atttypid),
                                    0, 0, 0);
 
    if (!HeapTupleIsValid(typeTuple))
index 82806bdbe90b5df906610f0d66b8a63db04994bb..05a639aec4a72bef93709e54dcc79eaabc6555ee 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.23 1998/07/22 05:48:59 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.24 1998/08/19 02:02:09 momjian Exp $
  *
  * NOTES
  *   This should be moved to a more appropriate place.  It is here
@@ -182,7 +182,7 @@ lo_creat(int mode)
        return InvalidOid;
    }
 
-   lobjId = lobjDesc->heap_r->rd_id;
+   lobjId = RelationGetRelid(lobjDesc->heap_r);
 
    inv_close(lobjDesc);
 
@@ -288,7 +288,7 @@ lo_import(text *filename)
     * the oid for the large object is just the oid of the relation
     * XInv??? which contains the data.
     */
-   lobjOid = lobj->heap_r->rd_id;
+   lobjOid = RelationGetRelid(lobj->heap_r);
 
    /*
     * read in from the Unix file and write to the inversion file
index f8fe91ed875abff1f3e7e1add009373385fb1253..00543dcdf16a2e93171a5105dc23f893d418835b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.30 1998/08/16 05:37:04 thomas Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.31 1998/08/19 02:02:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1071,7 +1071,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
     * --Nels, Jan '93
     */
    scan = heap_beginscan(relation, false, SnapshotNow, 2, entry);
-   tuple = heap_getnext(scan, false, (Buffer *) NULL);
+   tuple = heap_getnext(scan, 0);
    if (!HeapTupleIsValid(tuple))
    {
        elog(DEBUG, "clause_pred_clause_test: unknown pred_op");
@@ -1102,7 +1102,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
                           ObjectIdGetDatum(clause_op));
 
    scan = heap_beginscan(relation, false, SnapshotNow, 3, entry);
-   tuple = heap_getnext(scan, false, (Buffer *) NULL);
+   tuple = heap_getnext(scan, 0);
    if (!HeapTupleIsValid(tuple))
    {
        elog(DEBUG, "clause_pred_clause_test: unknown clause_op");
@@ -1134,7 +1134,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
                           Int16GetDatum(test_strategy));
 
    scan = heap_beginscan(relation, false, SnapshotNow, 3, entry);
-   tuple = heap_getnext(scan, false, (Buffer *) NULL);
+   tuple = heap_getnext(scan, 0);
    if (!HeapTupleIsValid(tuple))
    {
        elog(DEBUG, "clause_pred_clause_test: unknown test_op");
index ecde942e9c35f399123e72d127e97fa01cfa8068..eb66a4f6e2eb6a1895e30175cd61cbcf880a4929 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.18 1998/08/10 02:26:25 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.19 1998/08/19 02:02:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -496,7 +496,9 @@ xfunc_func_expense(LispValue node, LispValue args)
        funcid = get_funcid((Func) node);
 
    /* look up tuple in cache */
-   tupl = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid), 0, 0, 0);
+   tupl = SearchSysCacheTuple(PROOID,
+                               ObjectIdGetDatum(funcid),
+                               0, 0, 0);
    if (!HeapTupleIsValid(tupl))
        elog(ERROR, "Cache lookup failed for procedure %d", funcid);
    proc = (Form_pg_proc) GETSTRUCT(tupl);
@@ -610,7 +612,7 @@ xfunc_width(LispValue clause)
    {
        /* base case: width is width of this attribute */
        tupl = SearchSysCacheTuple(TYPOID,
-                             PointerGetDatum(get_vartype((Var) clause)),
+                                 ObjectIdGetDatum(get_vartype((Var) clause)),
                                   0, 0, 0);
        if (!HeapTupleIsValid(tupl))
            elog(ERROR, "Cache lookup failed for type %d",
@@ -1307,7 +1309,9 @@ xfunc_func_width(RegProcedure funcid, LispValue args)
 
    /* lookup function and find its return type */
    Assert(RegProcedureIsValid(funcid));
-   tupl = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid), 0, 0, 0);
+   tupl = SearchSysCacheTuple(PROOID,
+                               ObjectIdGetDatum(funcid),
+                               0, 0, 0);
    if (!HeapTupleIsValid(tupl))
        elog(ERROR, "Cache lookup failed for procedure %d", funcid);
    proc = (Form_pg_proc) GETSTRUCT(tupl);
index 3e2a3a6829ce68978ba55fab1eca8202e8769072..e46205523ccab42f057d980ea7271cff0ba3cd8e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.18 1998/07/27 19:38:00 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.19 1998/08/19 02:02:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,7 +65,7 @@ relation_info(Query *root, Index relid,
 
    relationObjectId = getrelid(relid, root->rtable);
    relationTuple = SearchSysCacheTuple(RELOID,
-                                     ObjectIdGetDatum(relationObjectId),
+                                       ObjectIdGetDatum(relationObjectId),
                                        0, 0, 0);
    if (HeapTupleIsValid(relationTuple))
    {
@@ -153,7 +153,7 @@ index_info(Query *root, bool first, int relid, IdxInfoRetval *info)
    }
    if (!HeapScanIsValid(scan))
        elog(ERROR, "index_info: scan not started");
-   indexTuple = heap_getnext(scan, 0, (Buffer *) NULL);
+   indexTuple = heap_getnext(scan, 0);
    if (!HeapTupleIsValid(indexTuple))
    {
        heap_endscan(scan);
@@ -414,9 +414,7 @@ find_inheritance_children(Oid inhparent)
    key[0].sk_argument = ObjectIdGetDatum((Oid) inhparent);
    relation = heap_openr(InheritsRelationName);
    scan = heap_beginscan(relation, 0, SnapshotNow, 1, key);
-   while (HeapTupleIsValid(inheritsTuple =
-                           heap_getnext(scan, 0,
-                                        (Buffer *) NULL)))
+   while (HeapTupleIsValid(inheritsTuple = heap_getnext(scan, 0)))
    {
        inhrelid = ((InheritsTupleForm) GETSTRUCT(inheritsTuple))->inhrel;
        list = lappendi(list, inhrelid);
@@ -450,12 +448,8 @@ VersionGetParents(Oid verrelid)
    relation = heap_openr(VersionRelationName);
    key[0].sk_argument = ObjectIdGetDatum(verrelid);
    scan = heap_beginscan(relation, 0, SnapshotNow, 1, key);
-   for (;;)
+   while (HeapTupleIsValid(versionTuple = heap_getnext(scan, 0)))
    {
-       versionTuple = heap_getnext(scan, 0,
-                                   (Buffer *) NULL);
-       if (!HeapTupleIsValid(versionTuple))
-           break;
        verbaseid = ((VersionTupleForm)
                     GETSTRUCT(versionTuple))->verbaseid;
 
index 7c874f88454295bbd05b74340ffae0031dab0a8d..5d16d31341058b97445ffd41b4def018d77f7c54 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.11 1998/06/15 19:28:54 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.12 1998/08/19 02:02:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -230,7 +230,8 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype,
    HeapTuple   theAggTuple;
    bool        usenulls = false;
 
-   theAggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname),
+   theAggTuple = SearchSysCacheTuple(AGGNAME,
+                                     PointerGetDatum(aggname),
                                      ObjectIdGetDatum(basetype),
                                      0, 0);
    if (!HeapTupleIsValid(theAggTuple))
index ffdebccb26b2ae409bba8b134f3fdddb6b34d782..4b02a1f344f004cfc1c06b046d476f5bbcd1d682 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.24 1998/07/27 19:38:02 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.25 1998/08/19 02:02:20 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -488,7 +488,8 @@ funcid_get_rettype(Oid funcid)
    HeapTuple   func_tuple = NULL;
    Oid         funcrettype = (Oid) 0;
 
-   func_tuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid),
+   func_tuple = SearchSysCacheTuple(PROOID,
+                                    ObjectIdGetDatum(funcid),
                                     0, 0, 0);
 
    if (!HeapTupleIsValid(func_tuple))
@@ -514,9 +515,7 @@ func_get_candidates(char *funcname, int nargs)
    HeapTuple   tuple;
    IndexScanDesc sd;
    RetrieveIndexResult indexRes;
-   Buffer      buffer;
    Form_pg_proc pgProcP;
-   bool        bufferUsed = FALSE;
    CandidateList candidates = NULL;
    CandidateList current_candidate;
    int         i;
@@ -535,24 +534,19 @@ func_get_candidates(char *funcname, int nargs)
    do
    {
        tuple = (HeapTuple) NULL;
-       if (bufferUsed)
-       {
-           ReleaseBuffer(buffer);
-           bufferUsed = FALSE;
-       }
 
        indexRes = index_getnext(sd, ForwardScanDirection);
        if (indexRes)
        {
            ItemPointer iptr;
-
+           Buffer      buffer;
+           
            iptr = &indexRes->heap_iptr;
            tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
            pfree(indexRes);
            if (HeapTupleIsValid(tuple))
            {
                pgProcP = (Form_pg_proc) GETSTRUCT(tuple);
-               bufferUsed = TRUE;
                if (pgProcP->pronargs == nargs)
                {
                    current_candidate = (CandidateList)
@@ -567,6 +561,7 @@ func_get_candidates(char *funcname, int nargs)
                    current_candidate->next = candidates;
                    candidates = current_candidate;
                }
+               ReleaseBuffer(buffer);
            }
        }
    } while (indexRes);
@@ -1000,7 +995,6 @@ find_inheritors(Oid relid, Oid **supervec)
               *elt;
 
    Relation    rd;
-   Buffer      buf;
    Datum       d;
    bool        newrelid;
    char        isNull;
@@ -1026,7 +1020,7 @@ find_inheritors(Oid relid, Oid **supervec)
 
        inhscan = heap_beginscan(inhrel, 0, SnapshotNow, 1, &skey);
 
-       while (HeapTupleIsValid(inhtup = heap_getnext(inhscan, 0, &buf)))
+       while (HeapTupleIsValid(inhtup = heap_getnext(inhscan, 0)))
        {
            qentry = (SuperQE *) palloc(sizeof(SuperQE));
 
@@ -1036,8 +1030,6 @@ find_inheritors(Oid relid, Oid **supervec)
 
            /* put this one on the queue */
            DLAddTail(queue, DLNewElem(qentry));
-
-           ReleaseBuffer(buf);
        }
 
        heap_endscan(inhscan);
@@ -1311,7 +1303,7 @@ ParseComplexProjection(ParseState *pstate,
                    rd = heap_openr(typeidTypeName(argtype));
                    if (RelationIsValid(rd))
                    {
-                       relid = RelationGetRelationId(rd);
+                       relid = RelationGetRelid(rd);
                        heap_close(rd);
                    }
                    if (RelationIsValid(rd))
@@ -1369,7 +1361,7 @@ ParseComplexProjection(ParseState *pstate,
                    rd = heap_openr(typeidTypeName(argtype));
                    if (RelationIsValid(rd))
                    {
-                       relid = RelationGetRelationId(rd);
+                       relid = RelationGetRelid(rd);
                        heap_close(rd);
                    }
                    if (RelationIsValid(rd))
@@ -1406,7 +1398,7 @@ ParseComplexProjection(ParseState *pstate,
                rd = heap_openr(typeidTypeName(param->paramtype));
                if (RelationIsValid(rd))
                {
-                   relid = RelationGetRelationId(rd);
+                   relid = RelationGetRelid(rd);
                    heap_close(rd);
                    if ((attnum = get_attnum(relid, funcname))
                        != InvalidAttrNumber)
index 7c9f6940d6855ac261d7b180e454dcd3b9080c8c..44548398713c5ccb0c5e41e0a73f65d39a8e853f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.18 1998/07/20 11:17:11 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.19 1998/08/19 02:02:23 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -284,7 +284,7 @@ make_array_ref(Node *expr,
 
    /* get the type tuple for the element type */
    type_tuple = SearchSysCacheTuple(TYPOID,
-                           ObjectIdGetDatum(type_struct_array->typelem),
+                               ObjectIdGetDatum(type_struct_array->typelem),
                                     0, 0, 0);
    if (!HeapTupleIsValid(type_tuple))
        elog(ERROR, "make_array_ref: Cache lookup failed for type %d\n",
@@ -365,7 +365,7 @@ make_array_set(Expr *target_expr,
             type_struct_array->typname);
    /* get the type tuple for the element type */
    type_tuple = SearchSysCacheTuple(TYPOID,
-                           ObjectIdGetDatum(type_struct_array->typelem),
+                               ObjectIdGetDatum(type_struct_array->typelem),
                                     0, 0, 0);
 
    if (!HeapTupleIsValid(type_tuple))
index 42e18e4d37561b0fa1429f4c321cb915a774b40f..689f64a87d3d15a18e7f1344ee20a80e1c9fe431 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.14 1998/07/27 19:38:04 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.15 1998/08/19 02:02:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,7 +86,6 @@ binary_oper_get_candidates(char *opname,
    HeapScanDesc pg_operator_scan;
    HeapTuple   tup;
    OperatorTupleForm oper;
-   Buffer      buffer;
    int         nkeys;
    int         ncandidates = 0;
    ScanKeyData opKey[3];
@@ -112,23 +111,18 @@ binary_oper_get_candidates(char *opname,
                                      nkeys,
                                      opKey);
 
-   do
+   while (HeapTupleIsValid(tup = heap_getnext(pg_operator_scan, 0)))
    {
-       tup = heap_getnext(pg_operator_scan, 0, &buffer);
-       if (HeapTupleIsValid(tup))
-       {
-           current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
-           current_candidate->args = (Oid *) palloc(2 * sizeof(Oid));
-
-           oper = (OperatorTupleForm) GETSTRUCT(tup);
-           current_candidate->args[0] = oper->oprleft;
-           current_candidate->args[1] = oper->oprright;
-           current_candidate->next = *candidates;
-           *candidates = current_candidate;
-           ncandidates++;
-           ReleaseBuffer(buffer);
-       }
-   } while (HeapTupleIsValid(tup));
+       current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
+       current_candidate->args = (Oid *) palloc(2 * sizeof(Oid));
+
+       oper = (OperatorTupleForm) GETSTRUCT(tup);
+       current_candidate->args[0] = oper->oprleft;
+       current_candidate->args[1] = oper->oprright;
+       current_candidate->next = *candidates;
+       *candidates = current_candidate;
+       ncandidates++;
+   }
 
    heap_endscan(pg_operator_scan);
    heap_close(pg_operator_desc);
@@ -465,7 +459,7 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
                              PointerGetDatum(op),
                              ObjectIdGetDatum(arg1),
                              ObjectIdGetDatum(arg2),
-                             Int8GetDatum('b'));
+                             CharGetDatum('b'));
 
    /* Did not find anything? then try flipping arguments on a commutative operator... */
    if (!HeapTupleIsValid(tup) && (arg1 != arg2))
@@ -474,7 +468,7 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
                                  PointerGetDatum(op),
                                  ObjectIdGetDatum(arg2),
                                  ObjectIdGetDatum(arg1),
-                                 Int8GetDatum('b'));
+                                 CharGetDatum('b'));
 
        if (HeapTupleIsValid(tup))
        {
@@ -545,7 +539,7 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
                                  PointerGetDatum(op),
                                  ObjectIdGetDatum(candidates->args[0]),
                                  ObjectIdGetDatum(candidates->args[1]),
-                                 Int8GetDatum('b'));
+                                 CharGetDatum('b'));
        Assert(HeapTupleIsValid(tup));
 
 #if PARSEDEBUG
@@ -569,8 +563,7 @@ printf("oper_inexact: found candidate\n");
                                      PointerGetDatum(op),
                                      ObjectIdGetDatum(targetOids[0]),
                                      ObjectIdGetDatum(targetOids[1]),
-                                     Int8GetDatum('b'));
-
+                                     CharGetDatum('b'));
        }
        else
            tup = NULL;
@@ -635,7 +628,6 @@ unary_oper_get_candidates(char *op,
    HeapScanDesc pg_operator_scan;
    HeapTuple   tup;
    OperatorTupleForm oper;
-   Buffer      buffer;
    int         ncandidates = 0;
 
    static ScanKeyData opKey[2] = {
@@ -659,29 +651,24 @@ printf("unary_oper_get_candidates: start scan for '%s'\n", op);
                                      2,
                                      opKey);
 
-   do
+   while (HeapTupleIsValid(tup = heap_getnext(pg_operator_scan, 0)))
    {
-       tup = heap_getnext(pg_operator_scan, 0, &buffer);
-       if (HeapTupleIsValid(tup))
-       {
-           current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
-           current_candidate->args = (Oid *) palloc(sizeof(Oid));
+       current_candidate = (CandidateList) palloc(sizeof(struct _CandidateList));
+       current_candidate->args = (Oid *) palloc(sizeof(Oid));
 
-           oper = (OperatorTupleForm) GETSTRUCT(tup);
-           if (rightleft == 'r')
-               current_candidate->args[0] = oper->oprleft;
-           else
-               current_candidate->args[0] = oper->oprright;
-           current_candidate->next = *candidates;
-           *candidates = current_candidate;
+       oper = (OperatorTupleForm) GETSTRUCT(tup);
+       if (rightleft == 'r')
+           current_candidate->args[0] = oper->oprleft;
+       else
+           current_candidate->args[0] = oper->oprright;
+       current_candidate->next = *candidates;
+       *candidates = current_candidate;
 #ifdef PARSEDEBUG
 printf("unary_oper_get_candidates: found candidate '%s' for type %s\n",
  op, typeidTypeName(current_candidate->args[0]));
 #endif
-           ncandidates++;
-           ReleaseBuffer(buffer);
-       }
-   } while (HeapTupleIsValid(tup));
+       ncandidates++;
+   }
 
    heap_endscan(pg_operator_scan);
    heap_close(pg_operator_desc);
@@ -707,7 +694,7 @@ right_oper(char *op, Oid arg)
                              PointerGetDatum(op),
                              ObjectIdGetDatum(arg),
                              ObjectIdGetDatum(InvalidOid),
-                             Int8GetDatum('r'));
+                             CharGetDatum('r'));
 
    if (!HeapTupleIsValid(tup))
    {
@@ -723,7 +710,7 @@ right_oper(char *op, Oid arg)
                                      PointerGetDatum(op),
                                      ObjectIdGetDatum(candidates->args[0]),
                                      ObjectIdGetDatum(InvalidOid),
-                                     Int8GetDatum('r'));
+                                     CharGetDatum('r'));
            Assert(HeapTupleIsValid(tup));
        }
        else
@@ -736,7 +723,7 @@ right_oper(char *op, Oid arg)
                                          PointerGetDatum(op),
                                          ObjectIdGetDatum(InvalidOid),
                                          ObjectIdGetDatum(*targetOid),
-                                         Int8GetDatum('r'));
+                                         CharGetDatum('r'));
            }
            else
                tup = NULL;
@@ -767,7 +754,7 @@ left_oper(char *op, Oid arg)
                              PointerGetDatum(op),
                              ObjectIdGetDatum(InvalidOid),
                              ObjectIdGetDatum(arg),
-                             Int8GetDatum('l'));
+                             CharGetDatum('l'));
 
    if (!HeapTupleIsValid(tup))
    {
@@ -783,7 +770,7 @@ left_oper(char *op, Oid arg)
                                      PointerGetDatum(op),
                                      ObjectIdGetDatum(InvalidOid),
                                      ObjectIdGetDatum(candidates->args[0]),
-                                     Int8GetDatum('l'));
+                                     CharGetDatum('l'));
            Assert(HeapTupleIsValid(tup));
 #ifdef PARSEDEBUG
 printf("left_oper: searched cache for single left oper candidate '%s %s'\n",
@@ -797,7 +784,7 @@ printf("left_oper: searched cache for single left oper candidate '%s %s'\n",
                                      PointerGetDatum(op),
                                      ObjectIdGetDatum(InvalidOid),
                                      ObjectIdGetDatum(*targetOid),
-                                     Int8GetDatum('l'));
+                                     CharGetDatum('l'));
 
            if (!HeapTupleIsValid(tup))
            {
index 181152bfa5b21e65a49e4e3645e54c05093cd8d2..e87476f14b28c3032b4fae7a303d647e09583367 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.13 1998/08/18 00:48:57 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.14 1998/08/19 02:02:25 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -208,7 +208,7 @@ addRangeTableEntry(ParseState *pstate,
        elog(ERROR, "%s: %s",
             relname, aclcheck_error_strings[ACLCHECK_NO_CLASS]);
 
-   rte->relid = RelationGetRelationId(relation);
+   rte->relid = RelationGetRelid(relation);
 
    heap_close(relation);
 
@@ -237,7 +237,7 @@ addRangeTableEntry(ParseState *pstate,
 List *
 expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
 {
-   Relation    rdesc;
+   Relation    rel;
    List       *te_tail = NIL,
               *te_head = NIL;
    Var        *varnode;
@@ -249,13 +249,13 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
    if (rte == NULL)
        rte = addRangeTableEntry(pstate, relname, refname, FALSE, FALSE);
 
-   rdesc = heap_open(rte->relid);
+   rel = heap_open(rte->relid);
 
-   if (rdesc == NULL)
+   if (rel == NULL)
        elog(ERROR, "Unable to expand all -- heap_open failed on %s",
             rte->refname);
 
-   maxattrs = RelationGetNumberOfAttributes(rdesc);
+   maxattrs = RelationGetNumberOfAttributes(rel);
 
    for (varattno = 0; varattno <= maxattrs - 1; varattno++)
    {
@@ -263,7 +263,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
        char       *resname = NULL;
        TargetEntry *te = makeNode(TargetEntry);
 
-       attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data);
+       attrname = pstrdup((rel->rd_att->attrs[varattno]->attname).data);
        varnode = (Var *) make_var(pstate, rte->relid, refname, attrname);
 
        handleTargetColname(pstate, &resname, refname, attrname);
@@ -289,7 +289,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
            te_tail = lappend(te_tail, te);
    }
 
-   heap_close(rdesc);
+   heap_close(rel);
 
    return (te_head);
 }
@@ -343,7 +343,7 @@ attnameIsSet(Relation rd, char *name)
            return (false);     /* no sys attr is a set */
        }
    }
-   return (get_attisset(rd->rd_id, name));
+   return (get_attisset(RelationGetRelid(rd), name));
 }
 
 /*
index 58dd3a28b352421de9835c7b9a7efee257113b6f..a71df492799ce74d83af3a45e411462c3777a9d9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.20 1998/08/05 04:49:11 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.21 1998/08/19 02:02:26 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -683,7 +683,7 @@ printf("MakeTargetlistExpr: attrtypmod is %d\n", (int4) attrtypmod);
                                           lowerIndexpr,
                                           (Expr *) expr);
            attrtype = attnumTypeId(rd, resdomno);
-           attrtypmod = get_atttypmod(rd->rd_id, resdomno);
+           attrtypmod = get_atttypmod(RelationGetRelid(rd), resdomno);
        }
    }
    else
index 6daf38db87eb2cb28147ff058c9a7a23ef9b9c9a..682b214eed1cfdcca504f8b07aa926d9a4d79310 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.13 1998/07/20 11:17:11 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.14 1998/08/19 02:02:27 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,8 @@ typeidTypeName(Oid id)
    HeapTuple   tup;
    TypeTupleForm typetuple;
 
-   if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
+   if (!(tup = SearchSysCacheTuple(TYPOID,
+                                   ObjectIdGetDatum(id),
                                    0, 0, 0)))
    {
        elog(ERROR, "type id lookup of %u failed", id);
@@ -63,7 +64,8 @@ typeidType(Oid id)
 {
    HeapTuple   tup;
 
-   if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
+   if (!(tup = SearchSysCacheTuple(TYPOID,
+                                   ObjectIdGetDatum(id),
                                    0, 0, 0)))
    {
        elog(ERROR, "type id lookup of %u failed", id);
@@ -81,7 +83,9 @@ typenameType(char *s)
    if (s == NULL)
        elog(ERROR, "type(): Null type");
 
-   if (!(tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(s), 0, 0, 0)))
+   if (!(tup = SearchSysCacheTuple(TYPNAME,
+                                   PointerGetDatum(s),
+                                   0, 0, 0)))
        elog(ERROR, "type name lookup of %s failed", s);
    return ((Type) tup);
 }
index 3c1b6528605d11e33a84fbb26017c6d075b53779..4d8ecb8b1e96691536186e7d21ef5bdf01bee2bb 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.17 1998/08/18 00:48:58 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.18 1998/08/19 02:02:29 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,7 +97,7 @@ InsertRule(char *rulname,
    eventrel = heap_openr(evobj);
    if (eventrel == NULL)
        elog(ERROR, "rules cannot be defined on relations not in schema");
-   eventrel_oid = RelationGetRelationId(eventrel);
+   eventrel_oid = RelationGetRelid(eventrel);
 
    /*
     * if the slotname is null, we know that this is a multi-attr rule
@@ -201,7 +201,7 @@ DefineQueryRewrite(RuleStmt *stmt)
    event_relation = heap_openr(event_obj->relname);
    if (event_relation == NULL)
        elog(ERROR, "virtual relations not supported yet");
-   ev_relid = RelationGetRelationId(event_relation);
+   ev_relid = RelationGetRelid(event_relation);
 
    if (eslot_string == NULL)
    {
index e80fc4cf55eef4897f21a4ef51839b7bcc5efea6..68169cbf2d2dd85cc3e8ded109afc7b876481148 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.18 1998/08/18 00:48:59 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.19 1998/08/19 02:02:30 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1038,7 +1038,9 @@ CheckViewPerms(Relation view, List *rtable)
    /*
     * get the usename of the view's owner
     */
-   utup = SearchSysCacheTuple(USESYSID, view->rd_rel->relowner, 0, 0, 0);
+   utup = SearchSysCacheTuple(USESYSID,
+                               ObjectIdGetDatum(view->rd_rel->relowner),
+                               0, 0, 0);
    if (!HeapTupleIsValid(utup))
    {
        elog(ERROR, "cache lookup for userid %d failed",
index 5464793eb3d97cfb6af18f798b9ac6938b0a8ea6..e9d3e791fb1a7f9de34a2ae98c62d91b23f24ccd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.15 1998/07/27 19:38:08 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.16 1998/08/19 02:02:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 char *
 RewriteGetRuleEventRel(char *rulename)
 {
-   HeapTuple   htp;
+   HeapTuple   htup;
    Oid         eventrel;
 
-   htp = SearchSysCacheTuple(REWRITENAME, PointerGetDatum(rulename),
-                             0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   htup = SearchSysCacheTuple(REWRITENAME,
+                               PointerGetDatum(rulename),
+                               0, 0, 0);
+   if (!HeapTupleIsValid(htup))
        elog(ERROR, "RewriteGetRuleEventRel: rule \"%s\" not found",
             rulename);
-   eventrel = ((Form_pg_rewrite) GETSTRUCT(htp))->ev_class;
-   htp = SearchSysCacheTuple(RELOID, PointerGetDatum(eventrel),
+   eventrel = ((Form_pg_rewrite) GETSTRUCT(htup))->ev_class;
+   htup = SearchSysCacheTuple(RELOID,
+                             PointerGetDatum(eventrel),
                              0, 0, 0);
-   if (!HeapTupleIsValid(htp))
+   if (!HeapTupleIsValid(htup))
        elog(ERROR, "RewriteGetRuleEventRel: class %d not found",
             eventrel);
-   return ((Form_pg_class) GETSTRUCT(htp))->relname.data;
+   return ((Form_pg_class) GETSTRUCT(htup))->relname.data;
 }
 
 /* ----------------------------------------------------------------
@@ -68,8 +70,6 @@ void
 RemoveRewriteRule(char *ruleName)
 {
    Relation    RewriteRelation = NULL;
-   HeapScanDesc scanDesc = NULL;
-   ScanKeyData scanKeyData;
    HeapTuple   tuple = NULL;
    Oid         ruleId = (Oid) 0;
    Oid         eventRelationOid = (Oid) NULL;
@@ -84,13 +84,9 @@ RemoveRewriteRule(char *ruleName)
    /*
     * Scan the RuleRelation ('pg_rewrite') until we find a tuple
     */
-   ScanKeyEntryInitialize(&scanKeyData, 0, Anum_pg_rewrite_rulename,
-                          F_NAMEEQ, NameGetDatum(ruleName));
-   scanDesc = heap_beginscan(RewriteRelation,
-                             0, SnapshotNow, 1, &scanKeyData);
-
-   tuple = heap_getnext(scanDesc, 0, (Buffer *) NULL);
-
+   tuple = SearchSysCacheTupleCopy(REWRITENAME,
+                                   PointerGetDatum(ruleName),
+                                   0, 0, 0);
    /*
     * complain if no rule with such name existed
     */
@@ -105,14 +101,14 @@ RemoveRewriteRule(char *ruleName)
     * relation's OID
     */
    ruleId = tuple->t_oid;
-   eventRelationOidDatum =
-       heap_getattr(tuple,
-                    Anum_pg_rewrite_ev_class,
-                    RelationGetTupleDescriptor(RewriteRelation),
-                    &isNull);
+   eventRelationOidDatum = heap_getattr(tuple,
+                                Anum_pg_rewrite_ev_class,
+                                RelationGetTupleDescriptor(RewriteRelation),
+                                &isNull);
    if (isNull)
    {
        /* XXX strange!!! */
+       pfree(tuple);
        elog(ERROR, "RemoveRewriteRule: null event target relation!");
    }
    eventRelationOid = DatumGetObjectId(eventRelationOidDatum);
@@ -128,9 +124,10 @@ RemoveRewriteRule(char *ruleName)
    /*
     * Now delete the tuple...
     */
-   heap_delete(RewriteRelation, &(tuple->t_ctid));
+   heap_delete(RewriteRelation, &tuple->t_ctid);
+
+   pfree(tuple);
    heap_close(RewriteRelation);
-   heap_endscan(scanDesc);
 }
 
 /*
@@ -163,20 +160,8 @@ RelationRemoveRules(Oid relid)
    scanDesc = heap_beginscan(RewriteRelation,
                              0, SnapshotNow, 1, &scanKeyData);
 
-   for (;;)
-   {
-       tuple = heap_getnext(scanDesc, 0, (Buffer *) NULL);
-
-       if (!HeapTupleIsValid(tuple))
-       {
-           break;              /* we're done */
-       }
-
-       /*
-        * delete the tuple...
-        */
-       heap_delete(RewriteRelation, &(tuple->t_ctid));
-   }
+   while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0)))
+       heap_delete(RewriteRelation, &tuple->t_ctid);
 
    heap_endscan(scanDesc);
    heap_close(RewriteRelation);
index f75c22302e7957b2f63f91c33e0b5e0dfe95ce82..dae10410809b4a29b76687c67ac7183f2dad3c0d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.24 1998/07/27 19:38:09 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.25 1998/08/19 02:02:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,6 +22,7 @@
 #include "nodes/parsenodes.h"
 #include "nodes/pg_list.h"
 #include "storage/buf.h"       /* for InvalidBuffer */
+#include "storage/bufmgr.h"
 #include "utils/builtins.h"        /* for textout */
 #include "utils/catcache.h"        /* for CacheContext */
 #include "utils/mcxt.h"            /* MemoryContext stuff */
@@ -89,9 +90,7 @@ int
 IsDefinedRewriteRule(char *ruleName)
 {
    Relation    RewriteRelation = NULL;
-   HeapScanDesc scanDesc = NULL;
-   ScanKeyData scanKey;
-   HeapTuple   tuple = NULL;
+   HeapTuple   tuple;
 
 
    /*
@@ -99,21 +98,13 @@ IsDefinedRewriteRule(char *ruleName)
     */
    RewriteRelation = heap_openr(RewriteRelationName);
 
-   /*
-    * Scan the RuleRelation ('pg_rewrite') until we find a tuple
-    */
-   ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_rewrite_rulename,
-                      F_NAMEEQ, PointerGetDatum(ruleName));
-   scanDesc = heap_beginscan(RewriteRelation,
-                             0, SnapshotNow, 1, &scanKey);
-
-   tuple = heap_getnext(scanDesc, 0, (Buffer *) NULL);
-
+   tuple = SearchSysCacheTuple(REWRITENAME,
+                                PointerGetDatum(ruleName),
+                                0, 0, 0);
    /*
     * return whether or not the rewrite rule existed
     */
    heap_close(RewriteRelation);
-   heap_endscan(scanDesc);
    return (HeapTupleIsValid(tuple));
 }
 
@@ -122,40 +113,28 @@ setRelhasrulesInRelation(Oid relationId, bool relhasrules)
 {
    Relation    relationRelation;
    HeapTuple   tuple;
-   HeapTuple   newTuple;
    Relation    idescs[Num_pg_class_indices];
-   Form_pg_class relp;
 
    /*
     * Lock a relation given its Oid. Go to the RelationRelation (i.e.
     * pg_relation), find the appropriate tuple, and add the specified
     * lock to it.
     */
-   relationRelation = heap_openr(RelationRelationName);
-   tuple = ClassOidIndexScan(relationRelation, relationId);
-
-   /*
-    * Create a new tuple (i.e. a copy of the old tuple with its rule lock
-    * field changed and replace the old tuple in the RelationRelation
-    * NOTE: XXX ??? do we really need to make that copy ????
-    */
-   newTuple = heap_copytuple(tuple);
+   tuple = SearchSysCacheTupleCopy(RELOID,
+                                    ObjectIdGetDatum(relationId),
+                                    0, 0, 0);
+   Assert(HeapTupleIsValid(tuple));
 
-   relp = (Form_pg_class) GETSTRUCT(newTuple);
-   relp->relhasrules = relhasrules;
-
-   heap_replace(relationRelation, &(tuple->t_ctid), newTuple);
+   relationRelation = heap_openr(RelationRelationName);
+   ((Form_pg_class)GETSTRUCT(tuple))->relhasrules = relhasrules;
+   heap_replace(relationRelation, &tuple->t_ctid, tuple);
 
    /* keep the catalog indices up to date */
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
-   CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation,
-                      newTuple);
+   CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple);
    CatalogCloseIndices(Num_pg_class_indices, idescs);
 
-   /* be tidy */
    pfree(tuple);
-   pfree(newTuple);
-
    heap_close(relationRelation);
 }
 
index cffe640e2c3201bc4bb75b19c84b92920152e47d..77efdf3538aec0044540bb09afa13de65ac69776 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.40 1998/08/01 15:26:12 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.41 1998/08/19 02:02:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -100,7 +100,7 @@ static void BufferSync(void);
 static int BufferReplace(BufferDesc *bufHdr, bool bufferLockHeld);
 
 /* not static but used by vacuum only ... */
-int            BlowawayRelationBuffers(Relation rdesc, BlockNumber block);
+int            BlowawayRelationBuffers(Relation rel, BlockNumber block);
 
 /* ---------------------------------------------------
  * RelationGetBufferWithBuffer
@@ -135,7 +135,7 @@ RelationGetBufferWithBuffer(Relation relation,
        else
        {
            bufHdr = &LocalBufferDescriptors[-buffer - 1];
-           if (bufHdr->tag.relId.relId == relation->rd_id &&
+           if (bufHdr->tag.relId.relId == RelationGetRelid(relation) &&
                bufHdr->tag.blockNum == blockNumber)
                return (buffer);
        }
@@ -416,7 +416,7 @@ BufferAlloc(Relation reln,
            }
        }
 #ifdef BMTRACE
-       _bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), reln->rd_id, blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCFND);
+       _bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCFND);
 #endif                         /* BMTRACE */
 
        SpinRelease(BufMgrLock);
@@ -660,7 +660,7 @@ BufferAlloc(Relation reln,
    }
 
 #ifdef BMTRACE
-   _bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), reln->rd_id, blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCNOTFND);
+   _bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCNOTFND);
 #endif                         /* BMTRACE */
 
    SpinRelease(BufMgrLock);
@@ -1389,19 +1389,19 @@ RelationGetNumberOfBlocks(Relation relation)
  * --------------------------------------------------------------------
  */
 void
-ReleaseRelationBuffers(Relation rdesc)
+ReleaseRelationBuffers(Relation rel)
 {
    int         i;
    int         holding = 0;
    BufferDesc *buf;
 
-   if (rdesc->rd_islocal)
+   if (rel->rd_islocal)
    {
        for (i = 0; i < NLocBuffer; i++)
        {
            buf = &LocalBufferDescriptors[i];
            if ((buf->flags & BM_DIRTY) &&
-               (buf->tag.relId.relId == rdesc->rd_id))
+               (buf->tag.relId.relId == RelationGetRelid(rel)))
                buf->flags &= ~BM_DIRTY;
        }
        return;
@@ -1417,7 +1417,7 @@ ReleaseRelationBuffers(Relation rdesc)
        }
        if ((buf->flags & BM_DIRTY) &&
            (buf->tag.relId.dbId == MyDatabaseId) &&
-           (buf->tag.relId.relId == rdesc->rd_id))
+           (buf->tag.relId.relId == RelationGetRelid(rel)))
        {
            buf->flags &= ~BM_DIRTY;
            if (!(buf->flags & BM_FREE))
@@ -1559,29 +1559,29 @@ BufferPoolBlowaway()
  * --------------------------------------------------------------------
  */
 int
-BlowawayRelationBuffers(Relation rdesc, BlockNumber block)
+BlowawayRelationBuffers(Relation rel, BlockNumber block)
 {
    int         i;
    BufferDesc *buf;
 
-   if (rdesc->rd_islocal)
+   if (rel->rd_islocal)
    {
        for (i = 0; i < NLocBuffer; i++)
        {
            buf = &LocalBufferDescriptors[i];
-           if (buf->tag.relId.relId == rdesc->rd_id &&
+           if (buf->tag.relId.relId == RelationGetRelid(rel) &&
                buf->tag.blockNum >= block)
            {
                if (buf->flags & BM_DIRTY)
                {
                    elog(NOTICE, "BlowawayRelationBuffers(%s (local), %u): block %u is dirty",
-                        rdesc->rd_rel->relname.data, block, buf->tag.blockNum);
+                        rel->rd_rel->relname.data, block, buf->tag.blockNum);
                    return (-1);
                }
                if (LocalRefCount[i] > 0)
                {
                    elog(NOTICE, "BlowawayRelationBuffers(%s (local), %u): block %u is referenced (%d)",
-                        rdesc->rd_rel->relname.data, block,
+                        rel->rd_rel->relname.data, block,
                         buf->tag.blockNum, LocalRefCount[i]);
                    return (-2);
                }
@@ -1596,7 +1596,7 @@ BlowawayRelationBuffers(Relation rdesc, BlockNumber block)
    {
        buf = &BufferDescriptors[i];
        if (buf->tag.relId.dbId == MyDatabaseId &&
-           buf->tag.relId.relId == rdesc->rd_id &&
+           buf->tag.relId.relId == RelationGetRelid(rel) &&
            buf->tag.blockNum >= block)
        {
            if (buf->flags & BM_DIRTY)
index 3d05dc4b8558630f0c359be95728df9a9bc6f7ef..e08450da854643d849f908a814f0775c05104fff 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.18 1998/02/26 04:35:26 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.19 1998/08/19 02:02:37 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,13 +76,13 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
    /* a low tech search for now -- not optimized for scans */
    for (i = 0; i < NLocBuffer; i++)
    {
-       if (LocalBufferDescriptors[i].tag.relId.relId == reln->rd_id &&
+       if (LocalBufferDescriptors[i].tag.relId.relId == RelationGetRelid(reln) &&
            LocalBufferDescriptors[i].tag.blockNum == blockNum)
        {
 
 #ifdef LBDEBUG
            fprintf(stderr, "LB ALLOC (%d,%d) %d\n",
-                   reln->rd_id, blockNum, -i - 1);
+                   RelationGetRelid(reln), blockNum, -i - 1);
 #endif
            LocalRefCount[i]++;
            *foundPtr = TRUE;
@@ -92,7 +92,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
 
 #ifdef LBDEBUG
    fprintf(stderr, "LB ALLOC (%d,%d) %d\n",
-           reln->rd_id, blockNum, -nextFreeLocalBuf - 1);
+           RelationGetRelid(reln), blockNum, -nextFreeLocalBuf - 1);
 #endif
 
    /* need to get a new buffer (round robin for now) */
@@ -132,7 +132,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
    /*
     * it's all ours now.
     */
-   bufHdr->tag.relId.relId = reln->rd_id;
+   bufHdr->tag.relId.relId = RelationGetRelid(reln);
    bufHdr->tag.blockNum = blockNum;
    bufHdr->flags &= ~BM_DIRTY;
 
index f06bb5968a13d324081d99cd3922acb0b761e2a8..28856f518456fae20469612d3cec4f7f179cdc72 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.33 1998/08/06 05:12:45 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.34 1998/08/19 02:02:38 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 static HeapTuple
 inv_newtuple(LargeObjectDesc *obj_desc, Buffer buffer,
             Page page, char *dbuf, int nwrite);
-static HeapTuple inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP);
+static HeapTuple inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer);
 static int inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes);
 static int
 inv_wrold(LargeObjectDesc *obj_desc, char *dbuf, int nbytes,
-         HeapTuple htup, Buffer buffer);
-static void inv_indextup(LargeObjectDesc *obj_desc, HeapTuple htup);
+         HeapTuple tuple, Buffer buffer);
+static void inv_indextup(LargeObjectDesc *obj_desc, HeapTuple tuple);
 static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln);
 
 /*
@@ -122,14 +122,16 @@ inv_create(int flags)
    sprintf(objname, "xinv%d", file_oid);
    sprintf(indname, "xinx%d", file_oid);
 
-   if (SearchSysCacheTuple(RELNAME, PointerGetDatum(objname),
+   if (SearchSysCacheTuple(RELNAME,
+                           PointerGetDatum(objname),
                            0, 0, 0) != NULL)
    {
        elog(ERROR,
          "internal error: %s already exists -- cannot create large obj",
             objname);
    }
-   if (SearchSysCacheTuple(RELNAME, PointerGetDatum(indname),
+   if (SearchSysCacheTuple(RELNAME,
+                           PointerGetDatum(indname),
                            0, 0, 0) != NULL)
    {
        elog(ERROR,
@@ -331,7 +333,7 @@ inv_stat(LargeObjectDesc *obj_desc, struct pgstat * stbuf)
        obj_desc->flags |= IFS_RDLOCK;
    }
 
-   stbuf->st_ino = obj_desc->heap_r->rd_id;
+   stbuf->st_ino = RelationGetRelid(obj_desc->heap_r);
 #if 1
    stbuf->st_mode = (S_IFREG | 0666);  /* IFREG|rw-rw-rw- */
 #else
@@ -439,8 +441,7 @@ inv_tell(LargeObjectDesc *obj_desc)
 int
 inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 {
-   HeapTuple   htup;
-   Buffer      b;
+   HeapTuple   tuple;
    int         nread;
    int         off;
    int         ncopy;
@@ -467,18 +468,21 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
    /* fetch a block at a time */
    while (nread < nbytes)
    {
-
+       Buffer buffer;
+       
        /* fetch an inversion file system block */
-       htup = inv_fetchtup(obj_desc, &b);
+       tuple = inv_fetchtup(obj_desc, &buffer);
 
-       if (!HeapTupleIsValid(htup))
+       if (!HeapTupleIsValid(tuple))
        {
            obj_desc->flags |= IFS_ATEOF;
            break;
        }
 
        /* copy the data from this block into the buffer */
-       d = heap_getattr(htup, 2, obj_desc->hdesc, &isNull);
+       d = heap_getattr(tuple, 2, obj_desc->hdesc, &isNull);
+       ReleaseBuffer(buffer);
+       
        fsblock = (struct varlena *) DatumGetPointer(d);
 
        off = obj_desc->offset - obj_desc->lowbyte;
@@ -487,9 +491,6 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
            ncopy = (nbytes - nread);
        memmove(buf, &(fsblock->vl_dat[off]), ncopy);
 
-       /* be a good citizen */
-       ReleaseBuffer(b);
-
        /* move pointers past the amount we just read */
        buf += ncopy;
        nread += ncopy;
@@ -503,8 +504,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 int
 inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 {
-   HeapTuple   htup;
-   Buffer      b;
+   HeapTuple   tuple;
    int         nwritten;
    int         tuplen;
 
@@ -527,7 +527,8 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
    /* write a block at a time */
    while (nwritten < nbytes)
    {
-
+       Buffer buffer;
+       
        /*
         * Fetch the current inversion file system block.  If the class
         * storing the inversion file is empty, we don't want to do an
@@ -537,21 +538,22 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 
        if ((obj_desc->flags & IFS_ATEOF)
            || obj_desc->heap_r->rd_nblocks == 0)
-           htup = (HeapTuple) NULL;
+           tuple = (HeapTuple) NULL;
        else
-           htup = inv_fetchtup(obj_desc, &b);
+           tuple = inv_fetchtup(obj_desc, &buffer);
 
        /* either append or replace a block, as required */
-       if (!HeapTupleIsValid(htup))
+       if (!HeapTupleIsValid(tuple))
            tuplen = inv_wrnew(obj_desc, buf, nbytes - nwritten);
        else
        {
            if (obj_desc->offset > obj_desc->highbyte)
                tuplen = inv_wrnew(obj_desc, buf, nbytes - nwritten);
            else
-               tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, htup, b);
+               tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, tuple, buffer);
        }
-
+       ReleaseBuffer(buffer);
+       
        /* move pointers past the amount we just wrote */
        buf += tuplen;
        nwritten += tuplen;
@@ -602,9 +604,9 @@ inv_cleanindex(LargeObjectDesc *obj_desc)
  *             such tuple exists.
  */
 static HeapTuple
-inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
+inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
 {
-   HeapTuple   htup;
+   HeapTuple   tuple;
    RetrieveIndexResult res;
    Datum       d;
    int         firstbyte,
@@ -642,8 +644,11 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
                                &skey);
        }
 
+       res = NULL;
        do
        {
+           if (res)
+               pfree(res);
            res = index_getnext(obj_desc->iscan, ForwardScanDirection);
 
            if (res == (RetrieveIndexResult) NULL)
@@ -662,10 +667,9 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
             * 
             */
 
-           htup = heap_fetch(obj_desc->heap_r, SnapshotNow,
-                             &(res->heap_iptr), bufP);
-
-       } while (htup == (HeapTuple) NULL);
+           tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
+                             &(res->heap_iptr), buffer);
+       } while (tuple == (HeapTuple) NULL);
 
        /* remember this tid -- we may need it for later reads/writes */
        ItemPointerCopy(&(res->heap_iptr), &(obj_desc->htid));
@@ -673,8 +677,8 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
    }
    else
    {
-       htup = heap_fetch(obj_desc->heap_r, SnapshotNow,
-                         &(obj_desc->htid), bufP);
+       tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
+                         &(obj_desc->htid), buffer);
    }
 
    /*
@@ -683,9 +687,9 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
     * return the tuple.
     */
 
-   d = heap_getattr(htup, 1, obj_desc->hdesc, &isNull);
+   d = heap_getattr(tuple, 1, obj_desc->hdesc, &isNull);
    lastbyte = (int32) DatumGetInt32(d);
-   d = heap_getattr(htup, 2, obj_desc->hdesc, &isNull);
+   d = heap_getattr(tuple, 2, obj_desc->hdesc, &isNull);
    fsblock = (struct varlena *) DatumGetPointer(d);
 
    /*
@@ -697,8 +701,7 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *bufP)
    obj_desc->lowbyte = firstbyte;
    obj_desc->highbyte = lastbyte;
 
-   /* done */
-   return (htup);
+   return tuple;
 }
 
 /*
@@ -798,7 +801,7 @@ static int
 inv_wrold(LargeObjectDesc *obj_desc,
          char *dbuf,
          int nbytes,
-         HeapTuple htup,
+         HeapTuple tuple,
          Buffer buffer)
 {
    Relation    hr;
@@ -814,6 +817,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
                freespc;
    bool        isNull;
    int         keep_offset;
+   RetrieveIndexResult res;
 
    /*
     * Since we're using a no-overwrite storage manager, the way we
@@ -822,9 +826,9 @@ inv_wrold(LargeObjectDesc *obj_desc,
     * abstraction.
     */
 
-   TransactionIdStore(GetCurrentTransactionId(), &(htup->t_xmax));
-   htup->t_cmax = GetCurrentCommandId();
-   htup->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
+   TransactionIdStore(GetCurrentTransactionId(), &(tuple->t_xmax));
+   tuple->t_cmax = GetCurrentCommandId();
+   tuple->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
 
    /*
     * If we're overwriting the entire block, we're lucky.  All we need to
@@ -851,7 +855,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
    newpage = BufferGetPage(newbuf);
    hr = obj_desc->heap_r;
    freespc = IFREESPC(page);
-   d = heap_getattr(htup, 2, obj_desc->hdesc, &isNull);
+   d = heap_getattr(tuple, 2, obj_desc->hdesc, &isNull);
    fsblock = (struct varlena *) DatumGetPointer(d);
    tupbytes = fsblock->vl_len - sizeof(fsblock->vl_len);
 
@@ -956,8 +960,12 @@ inv_wrold(LargeObjectDesc *obj_desc,
     * move the scandesc forward so we don't reread the newly inserted
     * tuple on the next index scan
     */
+   res = NULL;
    if (obj_desc->iscan)
-       index_getnext(obj_desc->iscan, ForwardScanDirection);
+       res = index_getnext(obj_desc->iscan, ForwardScanDirection);
+
+   if (res)
+       pfree(res);
 
    /*
     * Okay, by here, a tuple for the new block is correctly placed,
@@ -1038,7 +1046,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
     */
 
    ntup->t_len = tupsize;
-   ItemPointerSet(&(ntup->t_ctid), BufferGetBlockNumber(buffer), off);
+   ItemPointerSet(&ntup->t_ctid, BufferGetBlockNumber(buffer), off);
    LastOidProcessed = ntup->t_oid = newoid();
    TransactionIdStore(GetCurrentTransactionId(), &(ntup->t_xmin));
    ntup->t_cmin = GetCurrentCommandId();
@@ -1091,7 +1099,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 }
 
 static void
-inv_indextup(LargeObjectDesc *obj_desc, HeapTuple htup)
+inv_indextup(LargeObjectDesc *obj_desc, HeapTuple tuple)
 {
    InsertIndexResult res;
    Datum       v[1];
@@ -1100,7 +1108,7 @@ inv_indextup(LargeObjectDesc *obj_desc, HeapTuple htup)
    n[0] = ' ';
    v[0] = Int32GetDatum(obj_desc->highbyte);
    res = index_insert(obj_desc->index_r, &v[0], &n[0],
-                      &(htup->t_ctid), obj_desc->heap_r);
+                      &(tuple->t_ctid), obj_desc->heap_r);
 
    if (res)
        pfree(res);
@@ -1203,17 +1211,15 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
 {
    IndexScanDesc iscan;
    RetrieveIndexResult res;
-   Buffer      buf;
-   HeapTuple   htup;
+   HeapTuple   tuple;
    Datum       d;
    long        size;
    bool        isNull;
-
+   Buffer      buffer;
+   
    /* scan backwards from end */
    iscan = index_beginscan(ireln, (bool) 1, 0, (ScanKey) NULL);
 
-   buf = InvalidBuffer;
-
    do
    {
        res = index_getnext(iscan, BackwardScanDirection);
@@ -1235,25 +1241,18 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
         * rather that NowTimeQual.  We currently have no way to pass a
         * time qual in.
         */
-
-       if (buf != InvalidBuffer)
-           ReleaseBuffer(buf);
-
-       htup = heap_fetch(hreln, SnapshotNow, &(res->heap_iptr), &buf);
+       tuple = heap_fetch(hreln, SnapshotNow, &res->heap_iptr, &buffer);
        pfree(res);
-
-   } while (!HeapTupleIsValid(htup));
+   } while (!HeapTupleIsValid(tuple));
 
    /* don't need the index scan anymore */
    index_endscan(iscan);
    pfree(iscan);
 
    /* get olastbyte attribute */
-   d = heap_getattr(htup, 1, hdesc, &isNull);
+   d = heap_getattr(tuple, 1, hdesc, &isNull);
    size = DatumGetInt32(d) + 1;
-
-   /* wei hates it if you forget to do this */
-   ReleaseBuffer(buf);
-
+   ReleaseBuffer(buffer);
+   
    return (size);
 }
index cebbce364cc60d46bcf7517e62c0b707edafdd69..bcdc57d54fcb2e2d88758a2f65b278b169f2828c 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.16 1998/08/01 15:26:24 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.17 1998/08/19 02:02:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -67,7 +67,7 @@ RelationInitLockInfo(Relation relation)
    extern GlobalMemory CacheCxt;
 
    Assert(RelationIsValid(relation));
-   Assert(OidIsValid(RelationGetRelationId(relation)));
+   Assert(OidIsValid(RelationGetRelid(relation)));
 
    info = (LockInfo) relation->lockInfo;
    
@@ -80,7 +80,7 @@ RelationInitLockInfo(Relation relation)
    info = (LockInfo) palloc(sizeof(LockInfoData));
    MemoryContextSwitchTo(oldcxt);
 
-   info->lockRelId.relId = RelationGetRelationId(relation);
+   info->lockRelId.relId = RelationGetRelid(relation);
    if (IsSharedSystemRelationName(relname))
        info->lockRelId.dbId = InvalidOid;
    else
index 606ee4f560b321084d3bdd5d1e005d13de3fac3a..0998389ffe91ec373a01760c722c3b68fb9f493b 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.21 1998/08/01 15:26:26 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.22 1998/08/19 02:02:44 momjian Exp $
  *
  * NOTES:
  *  (1) The lock.c module assumes that the caller here is doing
@@ -248,7 +248,7 @@ MultiAcquire(LOCKMETHOD lockmethod,
             LOCKMODE lockmode,
             PG_LOCK_LEVEL level)
 {
-   LOCKMODE        locks[N_LEVELS];
+   LOCKMODE    locks[N_LEVELS];
    int         i,
                status;
    LOCKTAG     xxTag,
index 8c8d229cb27e24ca9e4481829927fa3f385814d5..2f5b57a45167ed19181551cdd8bce7bf76620989 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.9 1998/06/23 15:35:45 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.10 1998/08/19 02:02:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -181,7 +181,7 @@ mmcreate(Relation reln)
 
    (*MMCurRelno)++;
 
-   tag.mmrt_relid = reln->rd_id;
+   tag.mmrt_relid = RelationGetRelid(reln);
    if (reln->rd_rel->relisshared)
        tag.mmrt_dbid = (Oid) 0;
    else
@@ -233,7 +233,7 @@ mmunlink(Relation reln)
    for (i = 0; i < MMNBUFFERS; i++)
    {
        if (MMBlockTags[i].mmct_dbid == reldbid
-           && MMBlockTags[i].mmct_relid == reln->rd_id)
+           && MMBlockTags[i].mmct_relid == RelationGetRelid(reln))
        {
            entry = (MMHashEntry *) hash_search(MMCacheHT,
                                                (char *) &MMBlockTags[i],
@@ -249,7 +249,7 @@ mmunlink(Relation reln)
        }
    }
    rtag.mmrt_dbid = reldbid;
-   rtag.mmrt_relid = reln->rd_id;
+   rtag.mmrt_relid = RelationGetRelid(reln);
 
    rentry = (MMRelHashEntry *) hash_search(MMRelCacheHT, (char *) &rtag,
                                            HASH_REMOVE, &found);
@@ -290,7 +290,7 @@ mmextend(Relation reln, char *buffer)
        reldbid = MyDatabaseId;
 
    tag.mmct_dbid = rtag.mmrt_dbid = reldbid;
-   tag.mmct_relid = rtag.mmrt_relid = reln->rd_id;
+   tag.mmct_relid = rtag.mmrt_relid = RelationGetRelid(reln);
 
    SpinAcquire(MMCacheLock);
 
@@ -334,7 +334,7 @@ mmextend(Relation reln, char *buffer)
 
    entry->mmhe_bufno = i;
    MMBlockTags[i].mmct_dbid = reldbid;
-   MMBlockTags[i].mmct_relid = reln->rd_id;
+   MMBlockTags[i].mmct_relid = RelationGetRelid(reln);
    MMBlockTags[i].mmct_blkno = rentry->mmrhe_nblocks;
 
    /* page numbers are zero-based, so we increment this at the end */
@@ -389,7 +389,7 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer)
    else
        tag.mmct_dbid = MyDatabaseId;
 
-   tag.mmct_relid = reln->rd_id;
+   tag.mmct_relid = RelationGetRelid(reln);
    tag.mmct_blkno = blocknum;
 
    SpinAcquire(MMCacheLock);
@@ -436,7 +436,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
    else
        tag.mmct_dbid = MyDatabaseId;
 
-   tag.mmct_relid = reln->rd_id;
+   tag.mmct_relid = RelationGetRelid(reln);
    tag.mmct_blkno = blocknum;
 
    SpinAcquire(MMCacheLock);
@@ -509,7 +509,7 @@ mmnblocks(Relation reln)
    else
        rtag.mmrt_dbid = MyDatabaseId;
 
-   rtag.mmrt_relid = reln->rd_id;
+   rtag.mmrt_relid = RelationGetRelid(reln);
 
    SpinAcquire(MMCacheLock);
 
index 3110c9afdd4e89270334a0b280999a6fed3343bb..adcdd063d16d8f93a293c8f1a65693b132767bdc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.18 1998/06/15 19:29:26 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.19 1998/08/19 02:02:48 momjian Exp $
  *
  * NOTES
  *   This cruft is the server side of PQfn.
@@ -204,7 +204,8 @@ update_fp_info(Oid func_id, struct fp_info * fip)
    MemSet((char *) fip, 0, (int) sizeof(struct fp_info));
    fip->funcid = InvalidOid;
 
-   func_htp = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(func_id),
+   func_htp = SearchSysCacheTuple(PROOID,
+                                  ObjectIdGetDatum(func_id),
                                   0, 0, 0);
    if (!HeapTupleIsValid(func_htp))
    {
@@ -236,7 +237,8 @@ update_fp_info(Oid func_id, struct fp_info * fip)
 
    if (OidIsValid(rettype))
    {
-       type_htp = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(rettype),
+       type_htp = SearchSysCacheTuple(TYPOID,
+                                      ObjectIdGetDatum(rettype),
                                       0, 0, 0);
        if (!HeapTupleIsValid(type_htp))
        {
index f8bfa0ff0dde7249d9e413be4728e3876a1d2aa2..9d2f4df3e3ca38c81eff28e0f5502fc179222acf 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for utils/adt
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.15 1998/07/26 04:30:52 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.16 1998/08/19 02:02:52 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -21,7 +21,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \
    date.o datetime.o datum.o dt.o filename.o float.o \
    geo_ops.o geo_selfuncs.o int.o int8.o like.o \
    misc.o nabstime.o name.o not_in.o numutils.o \
-   oid.o oidname.o oidint2.o oidint4.o oracle_compat.o \
+   oid.o oracle_compat.o \
    regexp.o regproc.o selfuncs.o sets.o tid.o timestamp.o \
    varchar.o varlena.o version.o
 
index f212dfcdd7031710f1641ba5040d0e4c3f86e380..aa0f1014692ecc332007e62a810526912345e5a6 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.28 1998/06/15 19:29:31 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.29 1998/08/19 02:02:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,7 +86,7 @@ getid(char *s, char *n)
 static char *
 aclparse(char *s, AclItem *aip, unsigned *modechg)
 {
-   HeapTuple   htp;
+   HeapTuple   htup;
    char        name[NAMEDATALEN];
 
    Assert(s && aip && modechg);
@@ -150,11 +150,12 @@ aclparse(char *s, AclItem *aip, unsigned *modechg)
    switch (aip->ai_idtype)
    {
        case ACL_IDTYPE_UID:
-           htp = SearchSysCacheTuple(USENAME, PointerGetDatum(name),
-                                     0, 0, 0);
-           if (!HeapTupleIsValid(htp))
+           htup = SearchSysCacheTuple(USENAME,
+                                       PointerGetDatum(name),
+                                       0, 0, 0);
+           if (!HeapTupleIsValid(htup))
                elog(ERROR, "aclparse: non-existent user \"%s\"", name);
-           aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htp))->usesysid;
+           aip->ai_id = ((Form_pg_shadow) GETSTRUCT(htup))->usesysid;
            break;
        case ACL_IDTYPE_GID:
            aip->ai_id = get_grosysid(name);
@@ -241,7 +242,7 @@ aclitemout(AclItem *aip)
 {
    char       *p;
    char       *out;
-   HeapTuple   htp;
+   HeapTuple   htup;
    unsigned    i;
    static AclItem default_aclitem = {ACL_ID_WORLD,
        ACL_IDTYPE_WORLD,
@@ -260,9 +261,10 @@ aclitemout(AclItem *aip)
    switch (aip->ai_idtype)
    {
        case ACL_IDTYPE_UID:
-           htp = SearchSysCacheTuple(USESYSID, ObjectIdGetDatum(aip->ai_id),
-                                     0, 0, 0);
-           if (!HeapTupleIsValid(htp))
+           htup = SearchSysCacheTuple(USESYSID,
+                                       ObjectIdGetDatum(aip->ai_id),
+                                       0, 0, 0);
+           if (!HeapTupleIsValid(htup))
            {
                char       *tmp = int2out(aip->ai_id);
 
@@ -283,7 +285,7 @@ aclitemout(AclItem *aip)
            }
            else
                strncat(p, (char *) &((Form_pg_shadow)
-                                     GETSTRUCT(htp))->usename,
+                                     GETSTRUCT(htup))->usename,
                        sizeof(NameData));
            break;
        case ACL_IDTYPE_GID:
index b3c898cbcf429ca8b4cad4d95c59b16f5c0c280a..cf76efabf3b0c9a647528efb0baa096ce95d0423 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.31 1998/07/12 21:29:22 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.32 1998/08/19 02:02:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1302,7 +1302,8 @@ system_cache_lookup(Oid element_type,
    HeapTuple   typeTuple;
    TypeTupleForm typeStruct;
 
-   typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(element_type),
+   typeTuple = SearchSysCacheTuple(TYPOID,
+                                   ObjectIdGetDatum(element_type),
                                    0, 0, 0);
 
    if (!HeapTupleIsValid(typeTuple))
index b0f38347f81960f75e276768da73bcfa34091785..beb0e719dd6c71566579c0e9566799f8c049a7fd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.23 1998/06/15 19:29:33 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.24 1998/08/19 02:02:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -614,7 +614,7 @@ datetime_datetime(DateADT date, TimeADT *time)
 
 
 int32                          /* RelativeTime */
-int42reltime(int32 timevalue)
+int4reltime(int32 timevalue)
 {
    return (timevalue);
 }
index 986f0e4d2411c420cb5642de7b2d39273b58065d..4658d29b499fdeacaac2040dc29b95b6f589df7c 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.10 1998/07/27 19:38:18 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.11 1998/08/19 02:02:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,9 +78,8 @@ int4notin(int16 not_in_arg, char *relation_and_attr)
    retval = true;
 
    /* do a scan of the relation, and do the check */
-   for (current_tuple = heap_getnext(scan_descriptor, 0, NULL);
-        current_tuple != NULL && retval;
-        current_tuple = heap_getnext(scan_descriptor, 0, NULL))
+   while (HeapTupleIsValid(current_tuple = heap_getnext(scan_descriptor, 0)) &&
+           retval)
    {
        value = heap_getattr(current_tuple,
                             (AttrNumber) attrid,
index e6d66d126eda925d840215ebd7dc41f381a1f134..3e1097f0e08a21800309052d0dbcdb37a9906ac2 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.15 1998/02/26 04:37:16 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.16 1998/08/19 02:02:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,6 +125,46 @@ oid8eq(Oid arg1[], Oid arg2[])
    return (bool) (memcmp(arg1, arg2, 8 * sizeof(Oid)) == 0);
 }
 
+bool
+oid8lt(Oid arg1[], Oid arg2[])
+{
+   int i;
+   for (i=0; i < 8; i++)
+       if (!int4eq(arg1[i], arg2[i]))
+           return int4lt(arg1[i], arg2[i]);
+   return false;
+}
+
+bool
+oid8le(Oid arg1[], Oid arg2[])
+{
+   int i;
+   for (i=0; i < 8; i++)
+       if (!int4eq(arg1[i], arg2[i]))
+           return int4le(arg1[i], arg2[i]);
+   return true;
+}
+
+bool
+oid8ge(Oid arg1[], Oid arg2[])
+{
+   int i;
+   for (i=0; i < 8; i++)
+       if (!int4eq(arg1[i], arg2[i]))
+           return int4ge(arg1[i], arg2[i]);
+   return true;
+}
+
+bool
+oid8gt(Oid arg1[], Oid arg2[])
+{
+   int i;
+   for (i=0; i < 8; i++)
+       if (!int4eq(arg1[i], arg2[i]))
+           return int4gt(arg1[i], arg2[i]);
+   return false;
+}
+
 bool
 oideqint4(Oid arg1, int32 arg2)
 {
diff --git a/src/backend/utils/adt/oidint2.c b/src/backend/utils/adt/oidint2.c
deleted file mode 100644 (file)
index 1bcb37e..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * oidint2.c--
- *   Functions for the built-in type "oidint2".
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.6 1998/06/15 19:29:36 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include 
-#include "postgres.h"
-#include "utils/palloc.h"
-#include "utils/builtins.h"        /* for pg_atoi() */
-#include "utils/oidcompos.h"   /* where function declarations go */
-
-
-OidInt2
-oidint2in(char *o)
-{
-   OidInt2     oi;
-   char       *p;
-
-   oi = (OidInt2) palloc(sizeof(OidInt2Data));
-
-   for (p = o; *p != '\0' && *p != '/'; p++)
-       continue;
-
-   oi->oi_oid = (Oid) pg_atoi(o, sizeof(Oid), '/');
-   if (*p == '\0')
-       oi->oi_int2 = 0;
-   else
-       oi->oi_int2 = (int16) pg_atoi(++p, sizeof(int2), '\0');
-
-   return (oi);
-}
-
-char *
-oidint2out(OidInt2 o)
-{
-   char       *r;
-
-   /*
-    * -2147483647/-32767 0        1 1234567890123456789
-    */
-   r = (char *) palloc(19);
-   sprintf(r, "%d/%d", o->oi_oid, o->oi_int2);
-
-   return (r);
-}
-
-bool
-oidint2lt(OidInt2 o1, OidInt2 o2)
-{
-   return
-   ((bool) (o1->oi_oid < o2->oi_oid ||
-            (o1->oi_oid == o2->oi_oid && o1->oi_int2 < o2->oi_int2)));
-}
-
-bool
-oidint2le(OidInt2 o1, OidInt2 o2)
-{
-   return ((bool) (o1->oi_oid < o2->oi_oid ||
-             (o1->oi_oid == o2->oi_oid && o1->oi_int2 <= o2->oi_int2)));
-}
-
-bool
-oidint2eq(OidInt2 o1, OidInt2 o2)
-{
-   return ((bool) (o1->oi_oid == o2->oi_oid && o1->oi_int2 == o2->oi_int2));
-}
-
-bool
-oidint2ge(OidInt2 o1, OidInt2 o2)
-{
-   return ((bool) (o1->oi_oid > o2->oi_oid ||
-             (o1->oi_oid == o2->oi_oid && o1->oi_int2 >= o2->oi_int2)));
-}
-
-bool
-oidint2gt(OidInt2 o1, OidInt2 o2)
-{
-   return ((bool) (o1->oi_oid > o2->oi_oid ||
-              (o1->oi_oid == o2->oi_oid && o1->oi_int2 > o2->oi_int2)));
-}
-
-bool
-oidint2ne(OidInt2 o1, OidInt2 o2)
-{
-   return ((bool) (o1->oi_oid != o2->oi_oid || o1->oi_int2 != o2->oi_int2));
-}
-
-int
-oidint2cmp(OidInt2 o1, OidInt2 o2)
-{
-   if (oidint2lt(o1, o2))
-       return (-1);
-   else if (oidint2eq(o1, o2))
-       return (0);
-   else
-       return (1);
-}
-
-OidInt2
-mkoidint2(Oid v_oid, uint16 v_int2)
-{
-   OidInt2     o;
-
-   o = (OidInt2) palloc(sizeof(OidInt2Data));
-   o->oi_oid = v_oid;
-   o->oi_int2 = v_int2;
-   return (o);
-}
diff --git a/src/backend/utils/adt/oidint4.c b/src/backend/utils/adt/oidint4.c
deleted file mode 100644 (file)
index 90f4827..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * oidint4.c--
- *   Functions for the built-in type "oidint4".
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.6 1998/06/15 19:29:36 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include              /* for sprintf() */
-#include "postgres.h"
-#include "utils/palloc.h"
-#include "utils/builtins.h"
-#include "utils/oidcompos.h"   /* where function declarations go */
-
-OidInt4
-oidint4in(char *o)
-{
-   OidInt4     oi;
-   char       *p;
-
-   oi = (OidInt4) palloc(sizeof(OidInt4Data));
-
-   for (p = o; *p != '\0' && *p != '/'; p++)
-       continue;
-
-   oi->oi_oid = (Oid) pg_atoi(o, sizeof(Oid), '/');
-   if (*p == '\0')
-       oi->oi_int4 = 0;
-   else
-       oi->oi_int4 = pg_atoi(++p, sizeof(int4), '\0');
-
-   return (oi);
-}
-
-char *
-oidint4out(OidInt4 o)
-{
-   char       *r;
-
-   /*
-    * -2147483647/-2147483647 0        1         2
-    * 123456789012345678901234
-    */
-   r = (char *) palloc(24);
-   sprintf(r, "%d/%d", o->oi_oid, o->oi_int4);
-
-   return (r);
-}
-
-bool
-oidint4lt(OidInt4 o1, OidInt4 o2)
-{
-   return
-   ((bool) (o1->oi_oid < o2->oi_oid ||
-            (o1->oi_oid == o2->oi_oid && o1->oi_int4 < o2->oi_int4)));
-}
-
-bool
-oidint4le(OidInt4 o1, OidInt4 o2)
-{
-   return ((bool) (o1->oi_oid < o2->oi_oid ||
-             (o1->oi_oid == o2->oi_oid && o1->oi_int4 <= o2->oi_int4)));
-}
-
-bool
-oidint4eq(OidInt4 o1, OidInt4 o2)
-{
-   return ((bool) (o1->oi_oid == o2->oi_oid && o1->oi_int4 == o2->oi_int4));
-}
-
-bool
-oidint4ge(OidInt4 o1, OidInt4 o2)
-{
-   return ((bool) (o1->oi_oid > o2->oi_oid ||
-             (o1->oi_oid == o2->oi_oid && o1->oi_int4 >= o2->oi_int4)));
-}
-
-bool
-oidint4gt(OidInt4 o1, OidInt4 o2)
-{
-   return ((bool) (o1->oi_oid > o2->oi_oid ||
-              (o1->oi_oid == o2->oi_oid && o1->oi_int4 > o2->oi_int4)));
-}
-
-bool
-oidint4ne(OidInt4 o1, OidInt4 o2)
-{
-   return ((bool) (o1->oi_oid != o2->oi_oid || o1->oi_int4 != o2->oi_int4));
-}
-
-int
-oidint4cmp(OidInt4 o1, OidInt4 o2)
-{
-   if (oidint4lt(o1, o2))
-       return (-1);
-   else if (oidint4eq(o1, o2))
-       return (0);
-   else
-       return (1);
-}
-
-OidInt4
-mkoidint4(Oid v_oid, uint32 v_int4)
-{
-   OidInt4     o;
-
-   o = (OidInt4) palloc(sizeof(OidInt4Data));
-   o->oi_oid = v_oid;
-   o->oi_int4 = v_int4;
-   return (o);
-}
diff --git a/src/backend/utils/adt/oidname.c b/src/backend/utils/adt/oidname.c
deleted file mode 100644 (file)
index ff61681..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * oidname.c--
- *   adt for multiple key indices involving oid and name.  Used for cache
- *   index scans (could also be used in the general case with name).
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.12 1998/02/26 04:37:18 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include 
-#include 
-
-#include "postgres.h"
-#include "utils/oidcompos.h"   /* where function declarations go */
-#include "utils/builtins.h"        /* for pg_atoi() */
-#include "utils/palloc.h"
-
-OidName
-oidnamein(char *inStr)
-{
-   OidName     oc;
-   char       *inptr;
-
-   oc = (OidName) palloc(sizeof(OidNameData));
-
-   MemSet(oc, 0, sizeof(OidNameData));
-   for (inptr = inStr; *inptr && *inptr != ','; inptr++)
-       ;
-
-   if (*inptr)
-   {
-       oc->id = (Oid) pg_atoi(inStr, sizeof(Oid), ',');
-       /* copy one less to ensure null-padding */
-       ++inptr;
-       StrNCpy(oc->name.data, inptr, NAMEDATALEN);
-   }
-   else
-       elog(ERROR, "Bad input data for type oidname");
-
-   return oc;
-}
-
-char *
-oidnameout(OidName oidname)
-{
-   char        buf[30 + NAMEDATALEN];  /* oidname length + oid length +
-                                        * some safety */
-   char       *res;
-
-   sprintf(buf, "%d,%s", oidname->id, oidname->name.data);
-   res = pstrdup(buf);
-   return (res);
-}
-
-bool
-oidnamelt(OidName o1, OidName o2)
-{
-   return (bool)
-   (o1->id < o2->id ||
-    (o1->id == o2->id && namecmp(&o1->name, &o2->name) < 0));
-}
-
-bool
-oidnamele(OidName o1, OidName o2)
-{
-   return (bool)
-   (o1->id < o2->id ||
-    (o1->id == o2->id && namecmp(&o1->name, &o2->name) <= 0));
-}
-
-bool
-oidnameeq(OidName o1, OidName o2)
-{
-   return (bool)
-   (o1->id == o2->id &&
-    (namecmp(&o1->name, &o2->name) == 0));
-}
-
-bool
-oidnamene(OidName o1, OidName o2)
-{
-   return (bool)
-   (o1->id != o2->id ||
-    (namecmp(&o1->name, &o2->name) != 0));
-}
-
-bool
-oidnamege(OidName o1, OidName o2)
-{
-   return (bool) (o1->id > o2->id || (o1->id == o2->id &&
-                                   namecmp(&o1->name, &o2->name) >= 0));
-}
-
-bool
-oidnamegt(OidName o1, OidName o2)
-{
-   return (bool) (o1->id > o2->id || (o1->id == o2->id &&
-                                    namecmp(&o1->name, &o2->name) > 0));
-}
-
-int
-oidnamecmp(OidName o1, OidName o2)
-{
-   if (o1->id == o2->id)
-       return (namecmp(&o1->name, &o2->name));
-
-   return (o1->id < o2->id) ? -1 : 1;
-}
-
-OidName
-mkoidname(Oid id, char *name)
-{
-   OidName     oidname;
-
-   oidname = (OidName) palloc(sizeof(Oid) + NAMEDATALEN);
-
-   oidname->id = id;
-   namestrcpy(&oidname->name, name);
-   return oidname;
-}
index b3beb0b7cc528bbf385c1bc5b5e32f7505074c2f..227158748b3b50e1854cc4a3d41a90073ca51512 100644 (file)
@@ -1,4 +1,4 @@
-/*-------------------------------------------------------------------------
+ /*-------------------------------------------------------------------------
  *
  * regproc.c--
  *   Functions for the built-in type "RegProcedure".
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.21 1998/07/27 19:38:19 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.22 1998/08/19 02:03:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include 
 #include "postgres.h"
+#include "miscadmin.h"
 #include "access/heapam.h"
 #include "access/relscan.h"
 #include "fmgr.h"
 #include "utils/palloc.h"
+#include "utils/syscache.h"
 
 #include "catalog/catname.h"
+#include "catalog/pg_proc.h"
+#include "catalog/pg_type.h"
 #include "utils/builtins.h"        /* where function declarations go */
 
 /*****************************************************************************
  *  USER I/O ROUTINES                                                       *
  *****************************************************************************/
-
 /*
  *     regprocin       - converts "proname" to proid
  *
  *     proid of NULL signifies unknown
  */
 int32
-regprocin(char *proname)
+regprocin(char *pro_oid_name)
 {
-   Relation    proc;
-   HeapScanDesc procscan;
    HeapTuple   proctup;
-   ScanKeyData key;
    RegProcedure result = (Oid) 0;
-   bool        isnull;
 
-   if (proname == NULL)
+   if (pro_oid_name == NULL)
        return (0);
-   proc = heap_openr(ProcedureRelationName);
-   if (!RelationIsValid(proc))
+
+
+   if (!IsBootstrapProcessingMode())
    {
-       elog(ERROR, "regprocin: could not open %s",
-            ProcedureRelationName);
-       return (0);
+       /*
+        *  we need to use the oid because there can be multiple entries
+        *  with the same name, i.e.  1323(int4eq)
+        */
+       proctup = SearchSysCacheTuple(PROOID,
+                                       ObjectIdGetDatum(atoi(pro_oid_name)),
+                                       0, 0, 0);
+       if (HeapTupleIsValid(proctup))
+               result = (RegProcedure) proctup->t_oid;
+       else    result = (RegProcedure) 0;
    }
-   ScanKeyEntryInitialize(&key,
-                          (bits16) 0,
-                          (AttrNumber) 1,
-                          (RegProcedure) F_NAMEEQ,
-                          (Datum) proname);
-
-   procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
-   if (!HeapScanIsValid(procscan))
+   else
    {
+       Relation    proc;
+       HeapScanDesc procscan;
+       ScanKeyData key;
+       bool        isnull;
+   
+       proc = heap_openr(ProcedureRelationName);
+       if (!RelationIsValid(proc))
+       {
+           elog(ERROR, "regprocin: could not open %s",
+                ProcedureRelationName);
+           return (0);
+       }
+       ScanKeyEntryInitialize(&key,
+                              (bits16) 0,
+                              (AttrNumber) 1,
+                              (RegProcedure) F_NAMEEQ,
+                              (Datum) pro_oid_name);
+   
+       procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
+       if (!HeapScanIsValid(procscan))
+       {
+           heap_close(proc);
+           elog(ERROR, "regprocin: could not being scan of %s",
+                ProcedureRelationName);
+           return (0);
+       }
+       proctup = heap_getnext(procscan, 0);
+       if (HeapTupleIsValid(proctup))
+       {
+               result = (RegProcedure) heap_getattr(proctup,
+                                                    ObjectIdAttributeNumber,
+                                           RelationGetTupleDescriptor(proc),
+                                                    &isnull);
+               if (isnull)
+                   elog(FATAL, "regprocin: null procedure %s", pro_oid_name);
+       }
+       else
+               result = (RegProcedure) 0;
+
+       heap_endscan(procscan);
        heap_close(proc);
-       elog(ERROR, "regprocin: could not being scan of %s",
-            ProcedureRelationName);
-       return (0);
-   }
-   proctup = heap_getnext(procscan, 0, (Buffer *) NULL);
-   switch (HeapTupleIsValid(proctup))
-   {
-       case 1:
-           result = (RegProcedure) heap_getattr(proctup,
-                                                ObjectIdAttributeNumber,
-                                       RelationGetTupleDescriptor(proc),
-                                                &isnull);
-           if (isnull)
-               elog(FATAL, "regprocin: null procedure %s", proname);
-           break;
-       case 0:
-           result = (RegProcedure) 0;
+   }   
+
 #ifdef EBUG
-           elog(DEBUG, "regprocin: no such procedure %s", proname);
+   elog(DEBUG, "regprocin: no such procedure %s", pro_oid_name);
 #endif                         /* defined(EBUG) */
-   }
-   heap_endscan(procscan);
-   heap_close(proc);
-   return ((int32) result);
+   return (int32) result;
 }
 
 /*
- *     regprocout      - converts proid to "proname"
+ *     regprocout      - converts proid to "pro_oid_name"
  */
 char *
 regprocout(RegProcedure proid)
 {
-   Relation    proc;
-   HeapScanDesc procscan;
    HeapTuple   proctup;
    char       *result;
-   ScanKeyData key;
 
    result = (char *) palloc(NAMEDATALEN);
-   proc = heap_openr(ProcedureRelationName);
-   if (!RelationIsValid(proc))
-   {
-       elog(ERROR, "regprocout: could not open %s",
-            ProcedureRelationName);
-       return (0);
-   }
-   ScanKeyEntryInitialize(&key,
-                          (bits16) 0,
-                          (AttrNumber) ObjectIdAttributeNumber,
-                          (RegProcedure) F_INT4EQ,
-                          (Datum) proid);
-
-   procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
-   if (!HeapScanIsValid(procscan))
+
+   if (!IsBootstrapProcessingMode())
    {
-       heap_close(proc);
-       elog(ERROR, "regprocout: could not being scan of %s",
-            ProcedureRelationName);
-       return (0);
+       proctup = SearchSysCacheTuple(PROOID,
+                                       ObjectIdGetDatum(proid),
+                                       0, 0, 0);
+   
+       if (HeapTupleIsValid(proctup))
+       {
+               char       *s;
+   
+               s = ((Form_pg_proc) GETSTRUCT(proctup))->proname.data;
+               snprintf(result, NAMEDATALEN, "%d(%s)", proid, s);
+       }
+       else
+       {
+           result[0] = '-';
+           result[1] = '\0';
+       }
    }
-   proctup = heap_getnext(procscan, 0, (Buffer *) NULL);
-   switch (HeapTupleIsValid(proctup))
+   else
    {
+       Relation    proc;
+       HeapScanDesc procscan;
+       ScanKeyData key;
+   
+       proc = heap_openr(ProcedureRelationName);
+       if (!RelationIsValid(proc))
+       {
+           elog(ERROR, "regprocout: could not open %s",
+                ProcedureRelationName);
+           return (0);
+       }
+       ScanKeyEntryInitialize(&key,
+                              (bits16) 0,
+                              (AttrNumber) ObjectIdAttributeNumber,
+                              (RegProcedure) F_INT4EQ,
+                              (Datum) proid);
+   
+       procscan = heap_beginscan(proc, 0, SnapshotNow, 1, &key);
+       if (!HeapScanIsValid(procscan))
+       {
+           heap_close(proc);
+           elog(ERROR, "regprocout: could not being scan of %s",
+                ProcedureRelationName);
+           return (0);
+       }
+       proctup = heap_getnext(procscan, 0);
+       if (HeapTupleIsValid(proctup))
+       {
            char       *s;
            bool        isnull;
 
-       case 1:
            s = (char *) heap_getattr(proctup, 1,
                              RelationGetTupleDescriptor(proc), &isnull);
            if (!isnull)
-           {
                StrNCpy(result, s, NAMEDATALEN);
-               break;
-           }
-           elog(FATAL, "regprocout: null procedure %d", proid);
-           /* FALLTHROUGH */
-       case 0:
-           result[0] = '-';
-           result[1] = '\0';
+           else
+               elog(FATAL, "regprocout: null procedure %d", proid);
+       }
+       else
+       {
+               result[0] = '-';
+               result[1] = '\0';
+       }
+       heap_endscan(procscan);
+       heap_close(proc);
+       return (result);
+   }
+
 #ifdef EBUG
            elog(DEBUG, "regprocout: no such procedure %d", proid);
 #endif                         /* defined(EBUG) */
-   }
-   heap_endscan(procscan);
-   heap_close(proc);
    return (result);
 }
 
@@ -153,11 +200,8 @@ regprocout(RegProcedure proid)
 text *
 oid8types(Oid (*oidArray)[])
 {
-   Relation    type;
-   HeapScanDesc typescan;
    HeapTuple   typetup;
    text       *result;
-   ScanKeyData key;
    int         num;
    Oid        *sp;
 
@@ -170,55 +214,26 @@ oid8types(Oid (*oidArray)[])
 
    result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ);
    *VARDATA(result) = '\0';
-   type = heap_openr(TypeRelationName);
-   if (!RelationIsValid(type))
-   {
-       elog(ERROR, "int8typeout: could not open %s",
-            TypeRelationName);
-       return (0);
-   }
 
    sp = *oidArray;
    for (num = 8; num != 0; num--, sp++)
    {
        if (*sp != InvalidOid)
        {
-           ScanKeyEntryInitialize(&key,
-                                  (bits16) 0,
-                                  (AttrNumber) ObjectIdAttributeNumber,
-                                  (RegProcedure) F_INT4EQ,
-                                  (Datum) *sp);
-
-           typescan = heap_beginscan(type, 0, SnapshotNow, 1, &key);
-           if (!HeapScanIsValid(typescan))
-           {
-               heap_close(type);
-               elog(ERROR, "int8typeout: could not being scan of %s",
-                    TypeRelationName);
-               return (0);
-           }
-           typetup = heap_getnext(typescan, 0, (Buffer *) NULL);
+           typetup = SearchSysCacheTuple(TYPOID,
+                                           ObjectIdGetDatum(*sp),
+                                           0, 0, 0);
            if (HeapTupleIsValid(typetup))
            {
                char       *s;
-               bool        isnull;
 
-               s = (char *) heap_getattr(typetup, 1,
-                             RelationGetTupleDescriptor(type), &isnull);
-               if (!isnull)
-               {
-                   StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s,
+               s = ((TypeTupleForm) GETSTRUCT(typetup))->typname.data;
+               StrNCpy(VARDATA(result) + strlen(VARDATA(result)), s,
                            NAMEDATALEN);
-                   strcat(VARDATA(result), " ");
-               }
-               else
-                   elog(FATAL, "int8typeout: null procedure %d", *sp);
-               /* FALLTHROUGH */
+               strcat(VARDATA(result), " ");
            }
-           heap_endscan(typescan);
        }
    }
-   heap_close(type);
    VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ;
    return (result);
 }
index d444ced1071a7c480de44708073b46a3b355d842..a5a0b86e4a4f6d50e96d96f1ef6819a665ae9ccf 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.20 1998/07/27 19:38:20 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.21 1998/08/19 02:03:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -295,7 +295,8 @@ getattdisbursion(Oid relid, AttrNumber attnum)
    if (nvals > 0)
        return (nvals);
 
-   atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(relid),
+   atp = SearchSysCacheTuple(RELOID,
+                             ObjectIdGetDatum(relid),
                              0, 0, 0);
 
    /*
@@ -334,8 +335,8 @@ gethilokey(Oid relid,
           char **high,
           char **low)
 {
-   Relation    rdesc;
-   HeapScanDesc sdesc;
+   Relation    rel;
+   HeapScanDesc scan;
    static ScanKeyData key[3] = {
        {0, Anum_pg_statistic_starelid, F_OIDEQ, {0, 0, F_OIDEQ}},
        {0, Anum_pg_statistic_staattnum, F_INT2EQ, {0, 0, F_INT2EQ}},
@@ -344,13 +345,13 @@ gethilokey(Oid relid,
    bool        isnull;
    HeapTuple   tuple;
 
-   rdesc = heap_openr(StatisticRelationName);
+   rel = heap_openr(StatisticRelationName);
 
    key[0].sk_argument = ObjectIdGetDatum(relid);
    key[1].sk_argument = Int16GetDatum((int16) attnum);
    key[2].sk_argument = ObjectIdGetDatum(opid);
-   sdesc = heap_beginscan(rdesc, 0, SnapshotNow, 3, key);
-   tuple = heap_getnext(sdesc, 0, (Buffer *) NULL);
+   scan = heap_beginscan(rel, 0, SnapshotNow, 3, key);
+   tuple = heap_getnext(scan, 0);
    if (!HeapTupleIsValid(tuple))
    {
        *high = "n";
@@ -365,19 +366,19 @@ gethilokey(Oid relid,
    *high = textout((struct varlena *)
                    heap_getattr(tuple,
                                 Anum_pg_statistic_stahikey,
-                                RelationGetTupleDescriptor(rdesc),
+                                RelationGetTupleDescriptor(rel),
                                 &isnull));
    if (isnull)
        elog(DEBUG, "gethilokey: high key is null");
    *low = textout((struct varlena *)
                   heap_getattr(tuple,
                                Anum_pg_statistic_stalokey,
-                               RelationGetTupleDescriptor(rdesc),
+                               RelationGetTupleDescriptor(rel),
                                &isnull));
    if (isnull)
        elog(DEBUG, "gethilokey: low key is null");
-   heap_endscan(sdesc);
-   heap_close(rdesc);
+   heap_endscan(scan);
+   heap_close(rel);
 }
 
 float64
@@ -497,7 +498,8 @@ hashsel(Oid operatorObjectId,
         * have selectivity functions
         */
 
-       atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid),
+       atp = SearchSysCacheTuple(RELOID,
+                                 ObjectIdGetDatum(indexrelid),
                                  0, 0, 0);
        if (!HeapTupleIsValid(atp))
        {
@@ -549,7 +551,8 @@ hashnpage(Oid operatorObjectId,
    int         npage;
    int         ntuples;
 
-   atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid),
+   atp = SearchSysCacheTuple(RELOID,
+                             ObjectIdGetDatum(indexrelid),
                              0, 0, 0);
    if (!HeapTupleIsValid(atp))
    {
index 2822756786caf458f08102c56f5587631b965e1d..1d150805ce941d6534eabee0dfce4c410004a49c 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.15 1998/07/27 19:38:21 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.16 1998/08/19 02:03:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,13 +56,6 @@ SetDefine(char *querystr, char *typename)
    Datum       replValue[Natts_pg_proc];
    char        replNull[Natts_pg_proc];
    char        repl[Natts_pg_proc];
-   HeapScanDesc pg_proc_scan;
-   Buffer      buffer;
-   ItemPointerData ipdata;
-
-   static ScanKeyData oidKey[1] = {
-   {0, ObjectIdAttributeNumber, F_OIDEQ}};
-
 
    setoid = ProcedureCreate(procname,  /* changed below, after oid known */
                             true,      /* returnsSet */
@@ -117,37 +110,26 @@ SetDefine(char *querystr, char *typename)
        /* change the pg_proc tuple */
        procrel = heap_openr(ProcedureRelationName);
        RelationSetLockForWrite(procrel);
-       fmgr_info(F_OIDEQ,
-                 &oidKey[0].sk_func);
-       oidKey[0].sk_nargs = oidKey[0].sk_func.fn_nargs;
-       oidKey[0].sk_argument = ObjectIdGetDatum(setoid);
-       pg_proc_scan = heap_beginscan(procrel,
-                                     0,
-                                     SnapshotSelf,
-                                     1,
-                                     oidKey);
-       tup = heap_getnext(pg_proc_scan, 0, &buffer);
+
+       tup = SearchSysCacheTuple(PROOID,
+                                   ObjectIdGetDatum(setoid),
+                                   0, 0, 0);
        if (HeapTupleIsValid(tup))
        {
            newtup = heap_modifytuple(tup,
-                                     buffer,
                                      procrel,
                                      replValue,
                                      replNull,
                                      repl);
 
-           /* XXX may not be necessary */
-           ItemPointerCopy(&tup->t_ctid, &ipdata);
-
            setheapoverride(true);
-           heap_replace(procrel, &ipdata, newtup);
+           heap_replace(procrel, &tup->t_ctid, newtup);
            setheapoverride(false);
 
            setoid = newtup->t_oid;
        }
        else
            elog(ERROR, "setin: could not find new set oid tuple");
-       heap_endscan(pg_proc_scan);
 
        if (RelationGetRelationTupleForm(procrel)->relhasindex)
        {
index 51e9646ffddcaf96eb9ce4bec56a26eef2250254..4820eff22247656da6ce15b7c55772bd89b0e50f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.31 1998/07/27 19:38:22 vadim Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.32 1998/08/19 02:03:08 momjian Exp $
  *
  * Notes:
  *     XXX This needs to use exception.h to handle recovery when
 
 static void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
 static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP);
-static Index
-CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
+static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
                                  Relation relation, HeapTuple tuple);
-static void
-CatalogCacheInitializeCache(struct catcache * cache,
+static void CatalogCacheInitializeCache(struct catcache * cache,
                            Relation relation);
 static long comphash(long l, char *v);
 
@@ -182,7 +180,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
     * ----------------
     */
    Assert(RelationIsValid(relation));
-   cache->relationId = RelationGetRelationId(relation);
+   cache->relationId = RelationGetRelid(relation);
    tupdesc = cache->cc_tupdesc = RelationGetTupleDescriptor(relation);
 
    CACHE3_elog(DEBUG, "CatalogCacheInitializeCache: relid %d, %d keys",
@@ -250,7 +248,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
             */
            relation = index_openr(cache->cc_indname);
            Assert(relation);
-           cache->indexId = RelationGetRelationId(relation);
+           cache->indexId = RelationGetRelid(relation);
            index_close(relation);
        }
        else
@@ -827,7 +825,6 @@ SearchSysCache(struct catcache * cache,
    CatCTup    *nct2;
    Dlelem     *elt;
    HeapTuple   ntp = 0;
-   Buffer      buffer;
 
    Relation    relation;
    MemoryContext oldcxt;
@@ -997,8 +994,7 @@ SearchSysCache(struct catcache * cache,
        sd = heap_beginscan(relation, 0, SnapshotNow,
                            cache->cc_nkeys, cache->cc_skey);
 
-       /* should this buffer be ReleaseBuffer'd?  --djm 8/20/96 */
-       ntp = heap_getnext(sd, 0, &buffer);
+       ntp = heap_getnext(sd, 0);
 
        MemoryContextSwitchTo((MemoryContext) CacheCxt);
 
@@ -1129,7 +1125,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
     *         in the proper hash bucket
     * ----------------
     */
-   relationId = RelationGetRelationId(relation);
+   relationId = RelationGetRelid(relation);
 
    for (ccp = Caches; ccp; ccp = ccp->cc_next)
    {
index 1a10eaedb4b162e9d89fe85905a4e8b7a410369d..13d42341239892a99ce0d11c9898b9bbd0dd7d79 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.14 1998/07/26 04:30:55 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.15 1998/08/19 02:03:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -72,7 +72,8 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
    relname = (char *) getrelname(rtid, econtext->ecxt_range_table);
 
 
-   tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(relname),
+   tup = SearchSysCacheTuple(TYPNAME,
+                             PointerGetDatum(relname),
                              0, 0, 0);
    if (!tup)
        elog(ERROR, "Lookup failed on type tuple for class %s",
@@ -129,7 +130,7 @@ init_fcache(Oid foid,
     * ----------------
     */
    typeTuple = SearchSysCacheTuple(TYPOID,
-                          ObjectIdGetDatum(procedureStruct->prorettype),
+                              ObjectIdGetDatum(procedureStruct->prorettype),
                                    0, 0, 0);
 
    if (!HeapTupleIsValid(typeTuple))
index b71215442822679f3f0a6357633b7cdb85079ab3..ae77305ab3491c60b739f025e8729fac1c7ccd24 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.11 1998/06/15 19:29:39 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.12 1998/08/19 02:03:11 momjian Exp $
  *
  * Note - this code is real crufty...
  *
@@ -267,7 +267,7 @@ getmyrelids()
    MyAMRelationId = tuple->t_oid;
 
    tuple = SearchSysCacheTuple(RELNAME,
-                      PointerGetDatum(AccessMethodOperatorRelationName),
+                               PointerGetDatum(AccessMethodOperatorRelationName),
                                0, 0, 0);
    Assert(HeapTupleIsValid(tuple));
    MyAMOPRelationId = tuple->t_oid;
@@ -476,7 +476,7 @@ RelationInvalidateRelationCache(Relation relation,
     * ----------------
     */
    ValidateHacks();            /* XXX */
-   relationId = RelationGetRelationId(relation);
+   relationId = RelationGetRelid(relation);
 
    /* ----------------
     *
index be8d348e51f51ec2fe57a70af12f5d7afee69a87..38c29fd2749aa62686d74ff577964cdd64c7dca1 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.19 1998/08/16 05:38:41 thomas Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.20 1998/08/19 02:03:12 momjian Exp $
  *
  * NOTES
  *   Eventually, the index information should go through here, too.
@@ -47,8 +47,7 @@ op_class(Oid oprno, int32 opclass, Oid amopid)
 {
    FormData_pg_amop amoptup;
 
-   if (SearchSysCacheStruct(AMOPOPID,
-                            (char *) &amoptup,
+   if (SearchSysCacheStruct(AMOPOPID, (char *) &amoptup,
                             ObjectIdGetDatum(opclass),
                             ObjectIdGetDatum(oprno),
                             ObjectIdGetDatum(amopid),
@@ -72,8 +71,7 @@ get_attname(Oid relid, AttrNumber attnum)
 {
    FormData_pg_attribute att_tup;
 
-   if (SearchSysCacheStruct(ATTNUM,
-                            (char *) &att_tup,
+   if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
                             ObjectIdGetDatum(relid),
                             UInt16GetDatum(attnum),
                             0, 0))
@@ -115,8 +113,7 @@ get_atttype(Oid relid, AttrNumber attnum)
 {
    AttributeTupleForm att_tup = (AttributeTupleForm) palloc(sizeof(*att_tup));
 
-   if (SearchSysCacheStruct(ATTNUM,
-                            (char *) att_tup,
+   if (SearchSysCacheStruct(ATTNUM, (char *) att_tup,
                             ObjectIdGetDatum(relid),
                             UInt16GetDatum(attnum),
                             0, 0))
@@ -132,24 +129,24 @@ get_atttype(Oid relid, AttrNumber attnum)
 bool
 get_attisset(Oid relid, char *attname)
 {
-   HeapTuple   htup;
+   HeapTuple   tuple;
    AttrNumber  attno;
    AttributeTupleForm att_tup;
 
    attno = get_attnum(relid, attname);
 
-   htup = SearchSysCacheTuple(ATTNAME,
+   tuple = SearchSysCacheTuple(ATTNAME,
                               ObjectIdGetDatum(relid),
                               PointerGetDatum(attname),
                               0, 0);
-   if (!HeapTupleIsValid(htup))
+   if (!HeapTupleIsValid(tuple))
        elog(ERROR, "get_attisset: no attribute %s in relation %d",
             attname, relid);
-   if (heap_attisnull(htup, attno))
+   if (heap_attisnull(tuple, attno))
        return false;
    else
    {
-       att_tup = (AttributeTupleForm) GETSTRUCT(htup);
+       att_tup = (AttributeTupleForm) GETSTRUCT(tuple);
        return att_tup->attisset;
    }
 }
@@ -166,10 +163,9 @@ get_atttypmod(Oid relid, AttrNumber attnum)
 {
    FormData_pg_attribute att_tup;
 
-   if (SearchSysCacheStruct(ATTNUM,
-                            (char *) &att_tup,
+   if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup,
                             ObjectIdGetDatum(relid),
-                            Int32GetDatum(attnum),
+                            Int16GetDatum(attnum),
                             0, 0))
        return att_tup.atttypmod;
    else
@@ -400,8 +396,7 @@ get_rel_name(Oid relid)
 {
    FormData_pg_class reltup;
 
-   if ((SearchSysCacheStruct(RELOID,
-                             (char *) &reltup,
+   if ((SearchSysCacheStruct(RELOID, (char *) &reltup,
                              ObjectIdGetDatum(relid),
                              0, 0, 0)))
        return pstrdup(reltup.relname.data);
index 92a1384b1a9e6c624958d92fe0d136131f9e8efb..432c65fdf373d10ed5b705facdd89ed0cde4a066 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.46 1998/08/11 18:28:22 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.47 1998/08/19 02:03:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -337,7 +337,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
    Relation    pg_class_desc;
    HeapScanDesc pg_class_scan;
    ScanKeyData key;
-   Buffer      buf;
 
    /* ----------------
     *  form a scan key
@@ -371,9 +370,8 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
    pg_class_desc = heap_openr(RelationRelationName);
    if (!IsInitProcessingMode())
        RelationSetLockForRead(pg_class_desc);
-   pg_class_scan =
-       heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
-   pg_class_tuple = heap_getnext(pg_class_scan, 0, &buf);
+   pg_class_scan = heap_beginscan(pg_class_desc, 0, SnapshotNow, 1, &key);
+   pg_class_tuple = heap_getnext(pg_class_scan, 0);
 
    /* ----------------
     *  get set to return tuple
@@ -394,7 +392,6 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
        memmove((char *) return_tuple,
                (char *) pg_class_tuple,
                (int) pg_class_tuple->t_len);
-       ReleaseBuffer(buf);
    }
 
    /* all done */
@@ -534,15 +531,14 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
    ScanKeyEntryInitialize(&key, 0,
                           Anum_pg_attribute_attrelid,
                           F_OIDEQ,
-                          ObjectIdGetDatum(relation->rd_id));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    /* ----------------
     *  open pg_attribute and begin a scan
     * ----------------
     */
    pg_attribute_desc = heap_openr(AttributeRelationName);
-   pg_attribute_scan =
-       heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
+   pg_attribute_scan = heap_beginscan(pg_attribute_desc, 0, SnapshotNow, 1, &key);
 
    /* ----------------
     *  add attribute data to relation->rd_att
@@ -550,7 +546,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
     */
    need = natts;
 
-   pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0, (Buffer *) NULL);
+   pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
    while (HeapTupleIsValid(pg_attribute_tuple) && need > 0)
    {
        attp = (AttributeTupleForm) GETSTRUCT(pg_attribute_tuple);
@@ -565,13 +561,12 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
                    ATTRIBUTE_TUPLE_SIZE);
            need--;
        }
-       pg_attribute_tuple = heap_getnext(pg_attribute_scan,
-                                         0, (Buffer *) NULL);
+       pg_attribute_tuple = heap_getnext(pg_attribute_scan, 0);
    }
 
    if (need > 0)
        elog(ERROR, "catalog is missing %d attribute%s for relid %d",
-            need, (need == 1 ? "" : "s"), relation->rd_id);
+            need, (need == 1 ? "" : "s"), RelationGetRelid(relation));
 
    /* ----------------
     *  end the scan and close the attribute relation
@@ -600,8 +595,8 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
 
    for (i = 1; i <= relation->rd_rel->relnatts; i++)
    {
-
-       atttup = (HeapTuple) AttributeNumIndexScan(attrel, relation->rd_id, i);
+       atttup = (HeapTuple) AttributeNumIndexScan(attrel,
+                           RelationGetRelid(relation), i);
 
        if (!HeapTupleIsValid(atttup))
            elog(ERROR, "cannot find attribute %d of relation %s", i,
@@ -705,24 +700,21 @@ RelationBuildRuleLock(Relation relation)
    ScanKeyEntryInitialize(&key, 0,
                           Anum_pg_rewrite_ev_class,
                           F_OIDEQ,
-                          ObjectIdGetDatum(relation->rd_id));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    /* ----------------
     *  open pg_attribute and begin a scan
     * ----------------
     */
    pg_rewrite_desc = heap_openr(RewriteRelationName);
-   pg_rewrite_scan =
-       heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
-   pg_rewrite_tupdesc =
-       RelationGetTupleDescriptor(pg_rewrite_desc);
+   pg_rewrite_scan = heap_beginscan(pg_rewrite_desc, 0, SnapshotNow, 1, &key);
+   pg_rewrite_tupdesc = RelationGetTupleDescriptor(pg_rewrite_desc);
 
    /* ----------------
     *  add attribute data to relation->rd_att
     * ----------------
     */
-   while ((pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0,
-                                           (Buffer *) NULL)) != NULL)
+   while (HeapTupleIsValid(pg_rewrite_tuple=heap_getnext(pg_rewrite_scan, 0)))
    {
        bool        isnull;
        Datum       ruleaction;
@@ -867,7 +859,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
     *  initialize the relation's relation id (relation->rd_id)
     * ----------------
     */
-   relation->rd_id = relid;
+   RelationGetRelid(relation) = relid;
 
    /* ----------------
     *  initialize relation->rd_refcnt
@@ -1093,7 +1085,7 @@ formrdesc(char *relationName,
     *  initialize relation id
     * ----------------
     */
-   relation->rd_id = relation->rd_att->attrs[0]->attrelid;
+   RelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;
 
    /* ----------------
     *  add new reldesc to relcache
@@ -1109,7 +1101,7 @@ formrdesc(char *relationName,
     * the check (and possible set) after cache insertion.
     */
    relation->rd_rel->relhasindex =
-       CatalogHasIndex(relationName, relation->rd_id);
+       CatalogHasIndex(relationName, RelationGetRelid(relation));
 }
 
 
@@ -1328,7 +1320,7 @@ RelationFlushRelation(Relation *relationPtr,
        RelationCacheDelete(relation);
 
        FreeTupleDesc(relation->rd_att);
-       SystemCacheRelationFlushed(relation->rd_id);
+       SystemCacheRelationFlushed(RelationGetRelid(relation));
 
        FreeTriggerDesc(relation);
 
@@ -1379,7 +1371,7 @@ RelationForgetRelation(Oid rid)
            Relation    reln = lfirst(curr);
 
            Assert(reln != NULL && reln->rd_islocal);
-           if (reln->rd_id == rid)
+           if (RelationGetRelid(reln) == rid)
                break;
            prev = curr;
        }
@@ -1678,7 +1670,6 @@ AttrDefaultFetch(Relation relation)
    Form_pg_attrdef adform;
    IndexScanDesc sd;
    RetrieveIndexResult indexRes;
-   Buffer      buffer;
    ItemPointer iptr;
    struct varlena *val;
    bool        isnull;
@@ -1689,7 +1680,7 @@ AttrDefaultFetch(Relation relation)
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
-                          ObjectIdGetDatum(relation->rd_id));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    adrel = heap_openr(AttrDefaultRelationName);
    irel = index_openr(AttrDefaultIndex);
@@ -1698,6 +1689,8 @@ AttrDefaultFetch(Relation relation)
 
    for (found = 0;;)
    {
+       Buffer  buffer;
+       
        indexRes = index_getnext(sd, ForwardScanDirection);
        if (!indexRes)
            break;
@@ -1736,12 +1729,12 @@ AttrDefaultFetch(Relation relation)
            attrdef[i].adsrc = textout(val);
            break;
        }
-
+       ReleaseBuffer(buffer);
+       
        if (i >= ndef)
            elog(ERROR, "AttrDefaultFetch: unexpected record found for attr %d in rel %s",
                 adform->adnum,
                 relation->rd_rel->relname.data);
-       ReleaseBuffer(buffer);
    }
 
    if (found < ndef)
@@ -1752,7 +1745,6 @@ AttrDefaultFetch(Relation relation)
    pfree(sd);
    index_close(irel);
    heap_close(adrel);
-
 }
 
 static void
@@ -1766,7 +1758,6 @@ RelCheckFetch(Relation relation)
    HeapTuple   tuple;
    IndexScanDesc sd;
    RetrieveIndexResult indexRes;
-   Buffer      buffer;
    ItemPointer iptr;
    Name        rcname;
    struct varlena *val;
@@ -1777,7 +1768,7 @@ RelCheckFetch(Relation relation)
                           (bits16) 0x0,
                           (AttrNumber) 1,
                           (RegProcedure) F_OIDEQ,
-                          ObjectIdGetDatum(relation->rd_id));
+                          ObjectIdGetDatum(RelationGetRelid(relation)));
 
    rcrel = heap_openr(RelCheckRelationName);
    irel = index_openr(RelCheckIndex);
@@ -1786,6 +1777,8 @@ RelCheckFetch(Relation relation)
 
    for (found = 0;;)
    {
+       Buffer buffer;
+       
        indexRes = index_getnext(sd, ForwardScanDirection);
        if (!indexRes)
            break;
@@ -1821,7 +1814,6 @@ RelCheckFetch(Relation relation)
                 relation->rd_rel->relname.data);
        check[found].ccsrc = textout(val);
        found++;
-
        ReleaseBuffer(buffer);
    }
 
index e98a26a60b75bec2e1f24d0d31ae5ac166c2ea32..7b4a411d1721602f5589c6ebf887e1130d14f9d8 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.19 1998/07/20 16:57:05 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.20 1998/08/19 02:03:15 momjian Exp $
  *
  * NOTES
  *   These routines allow the parser/planner/executor to perform
@@ -67,262 +67,320 @@ typedef HeapTuple (*ScanFunc) ();
 static struct cachedesc cacheinfo[] = {
    {AccessMethodOperatorRelationName,  /* AMOPOPID */
        3,
-       {Anum_pg_amop_amopclaid,
+       {
+           Anum_pg_amop_amopclaid,
            Anum_pg_amop_amopopr,
            Anum_pg_amop_amopid,
-       0},
+           0
+       },
        sizeof(FormData_pg_amop),
        NULL,
    (ScanFunc) NULL},
    {AccessMethodOperatorRelationName,  /* AMOPSTRATEGY */
        3,
-       {Anum_pg_amop_amopid,
+       {
+           Anum_pg_amop_amopid,
            Anum_pg_amop_amopclaid,
            Anum_pg_amop_amopstrategy,
-       0},
+           0
+       },
        sizeof(FormData_pg_amop),
        NULL,
    (ScanFunc) NULL},
    {AttributeRelationName,     /* ATTNAME */
        2,
-       {Anum_pg_attribute_attrelid,
+       {
+           Anum_pg_attribute_attrelid,
            Anum_pg_attribute_attname,
            0,
-       0},
+           0
+       },
        ATTRIBUTE_TUPLE_SIZE,
        AttributeNameIndex,
    (ScanFunc) AttributeNameIndexScan},
    {AttributeRelationName,     /* ATTNUM */
        2,
-       {Anum_pg_attribute_attrelid,
+       {
+           Anum_pg_attribute_attrelid,
            Anum_pg_attribute_attnum,
            0,
-       0},
+           0
+       },
        ATTRIBUTE_TUPLE_SIZE,
        AttributeNumIndex,
    (ScanFunc) AttributeNumIndexScan},
    {IndexRelationName,         /* INDEXRELID */
        1,
-       {Anum_pg_index_indexrelid,
+       {
+           Anum_pg_index_indexrelid,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_index, indpred),
        NULL,
    NULL},
    {LanguageRelationName,      /* LANNAME */
        1,
-       {Anum_pg_language_lanname,
+       {
+           Anum_pg_language_lanname,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_language, lancompiler),
        NULL,
    NULL},
    {OperatorRelationName,      /* OPRNAME */
        4,
-       {Anum_pg_operator_oprname,
+       {
+           Anum_pg_operator_oprname,
            Anum_pg_operator_oprleft,
            Anum_pg_operator_oprright,
-       Anum_pg_operator_oprkind},
+           Anum_pg_operator_oprkind
+       },
        sizeof(FormData_pg_operator),
        NULL,
    NULL},
    {OperatorRelationName,      /* OPROID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_operator),
        NULL,
    (ScanFunc) NULL},
    {ProcedureRelationName,     /* PRONAME */
        3,
-       {Anum_pg_proc_proname,
+       {
+           Anum_pg_proc_proname,
            Anum_pg_proc_pronargs,
            Anum_pg_proc_proargtypes,
-       0},
+           0
+       },
        offsetof(FormData_pg_proc, prosrc),
        ProcedureNameIndex,
    (ScanFunc) ProcedureNameIndexScan},
    {ProcedureRelationName,     /* PROOID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_proc, prosrc),
        ProcedureOidIndex,
    (ScanFunc) ProcedureOidIndexScan},
    {RelationRelationName,      /* RELNAME */
        1,
-       {Anum_pg_class_relname,
+       {
+           Anum_pg_class_relname,
            0,
            0,
-       0},
+           0
+       },
        CLASS_TUPLE_SIZE,
        ClassNameIndex,
    (ScanFunc) ClassNameIndexScan},
    {RelationRelationName,      /* RELOID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        CLASS_TUPLE_SIZE,
        ClassOidIndex,
    (ScanFunc) ClassOidIndexScan},
    {TypeRelationName,          /* TYPNAME */
        1,
-       {Anum_pg_type_typname,
+       {
+           Anum_pg_type_typname,
            0,
            0,
-       0},
+           0
+       },
        offsetof(TypeTupleFormData, typalign) +sizeof(char),
        TypeNameIndex,
    TypeNameIndexScan},
    {TypeRelationName,          /* TYPOID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        offsetof(TypeTupleFormData, typalign) +sizeof(char),
        TypeOidIndex,
    TypeOidIndexScan},
    {AccessMethodRelationName,  /* AMNAME */
        1,
-       {Anum_pg_am_amname,
+       {
+           Anum_pg_am_amname,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_am),
        NULL,
    NULL},
    {OperatorClassRelationName, /* CLANAME */
        1,
-       {Anum_pg_opclass_opcname,
+       {
+           Anum_pg_opclass_opcname,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_opclass),
        NULL,
    NULL},
-   {IndexRelationName,         /* INDRELIDKEY */
+   {IndexRelationName,         /* INDRELIDKEY */ /* never used */
        2,
-       {Anum_pg_index_indrelid,
+       {
+           Anum_pg_index_indrelid,
            Anum_pg_index_indkey,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_index, indpred),
        NULL,
    (ScanFunc) NULL},
    {InheritsRelationName,      /* INHRELID */
        2,
-       {Anum_pg_inherits_inhrel,
+       {
+           Anum_pg_inherits_inhrel,
            Anum_pg_inherits_inhseqno,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_inherits),
        NULL,
    (ScanFunc) NULL},
    {RewriteRelationName,       /* RULOID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_rewrite, ev_qual),
        NULL,
    (ScanFunc) NULL},
    {AggregateRelationName,     /* AGGNAME */
        2,
-       {Anum_pg_aggregate_aggname,
+       {
+           Anum_pg_aggregate_aggname,
            Anum_pg_aggregate_aggbasetype,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_aggregate, agginitval1),
        NULL,
    (ScanFunc) NULL},
    {ListenerRelationName,      /* LISTENREL */
        2,
-       {Anum_pg_listener_relname,
+       {
+           Anum_pg_listener_relname,
            Anum_pg_listener_pid,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_listener),
        NULL,
    (ScanFunc) NULL},
    {ShadowRelationName,        /* USENAME */
        1,
-       {Anum_pg_shadow_usename,
+       {
+           Anum_pg_shadow_usename,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_shadow),
        NULL,
    (ScanFunc) NULL},
    {ShadowRelationName,        /* USESYSID */
        1,
-       {Anum_pg_shadow_usesysid,
+       {
+           Anum_pg_shadow_usesysid,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_shadow),
        NULL,
    (ScanFunc) NULL},
    {GroupRelationName,         /* GRONAME */
        1,
-       {Anum_pg_group_groname,
+       {
+           Anum_pg_group_groname,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_group, grolist[0]),
        NULL,
    (ScanFunc) NULL},
    {GroupRelationName,         /* GROSYSID */
        1,
-       {Anum_pg_group_grosysid,
+       {
+           Anum_pg_group_grosysid,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_group, grolist[0]),
        NULL,
    (ScanFunc) NULL},
    {RewriteRelationName,       /* REWRITENAME */
        1,
-       {Anum_pg_rewrite_rulename,
+       {
+           Anum_pg_rewrite_rulename,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_rewrite, ev_qual),
        NULL,
    (ScanFunc) NULL},
    {ProcedureRelationName,     /* PROSRC */
        1,
-       {Anum_pg_proc_prosrc,
+       {
+           Anum_pg_proc_prosrc,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_proc, prosrc),
        ProcedureSrcIndex,
    (ScanFunc) ProcedureSrcIndexScan},
    {OperatorClassRelationName, /* CLADEFTYPE */
        1,
-       {Anum_pg_opclass_opcdeftype,
+       {
+           Anum_pg_opclass_opcdeftype,
            0,
            0,
-       0},
+           0
+       },
        sizeof(FormData_pg_opclass),
        NULL,
    (ScanFunc) NULL},
    {LanguageRelationName,      /* LANOID */
        1,
-       {ObjectIdAttributeNumber,
+       {
+           ObjectIdAttributeNumber,
            0,
            0,
-       0},
+           0
+       },
        offsetof(FormData_pg_language, lancompiler),
        NULL,
    NULL}
@@ -380,16 +438,39 @@ InitCatalogCache()
        }
    }
 }
+/*
+ * SearchSysCacheTupleCopy--
+ *
+ * THis is like SearchSysCacheTuple, except it returns a copy of the tuple
+ * that the user is required to pfree().
+ */
+HeapTuple
+SearchSysCacheTupleCopy(int cacheId,/* cache selection code */
+                   Datum key1,
+                   Datum key2,
+                   Datum key3,
+                   Datum key4)
+{
+   HeapTuple   cachetup;
+
+   cachetup = SearchSysCacheTuple(cacheId, key1, key2, key3, key4);
+   if (PointerIsValid(cachetup))
+       return heap_copytuple(cachetup);
+   else
+       return cachetup; /* NULL */
+}
+                   
 
 /*
  * SearchSysCacheTuple--
  *
- *   A layer on top of SearchSysCache that does the initialization and
- *   key-setting for you.
+ * A layer on top of SearchSysCache that does the initialization and
+ * key-setting for you.
  *
- * Returns the tuple if one is found, NULL if not.
+ * Returns the cache copy of the tuple if one is found, NULL if not.
+ * The tuple is the 'cache' copy.
  *
- * XXX The tuple that is returned is NOT supposed to be pfree'd!
+ * XXX The tuple that is returned is NOT supposed to be pfree'd!
  */
 HeapTuple
 SearchSysCacheTuple(int cacheId,/* cache selection code */
@@ -542,7 +623,6 @@ SearchSysCacheGetAttribute(int cacheId,
 
    if (isNull)
    {
-
        /*
         * Used to be an elog(DEBUG, ...) here and a claim that it should
         * be a FATAL error, I don't think either is warranted -mer 6/9/92
@@ -622,7 +702,6 @@ TypeDefaultRetrieve(Oid typId)
             cacheinfo[TYPOID].name, TYPOID);
 #endif                         /* defined(CACHEDEBUG) */
        return (NULL);
-
    }
 
    dataSize = VARSIZE(typDefault) - VARHDRSZ;
index e92878019b43e7f567581e5989709ffe27e7bb4e..d506ac1f57ac77f12fda7f8e72bade5cd5e32890 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.18 1998/06/15 19:29:42 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.19 1998/08/19 02:03:16 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -58,7 +58,7 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
               *probinstring;
    Datum       probinattr;
    func_ptr    user_fn;
-   Relation    rdesc;
+   Relation    rel;
    bool        isnull;
 
    if (procedureId == procedureId_save)
@@ -71,7 +71,8 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
     * The procedure isn't a builtin, so we'll have to do a catalog lookup
     * to find its pg_proc entry.
     */
-   procedureTuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(procedureId),
+   procedureTuple = SearchSysCacheTuple(PROOID,
+                                        ObjectIdGetDatum(procedureId),
                                         0, 0, 0);
    if (!HeapTupleIsValid(procedureTuple))
    {
@@ -87,13 +88,13 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
    /*
     * Extract the procedure info from the pg_proc tuple. Since probin is
     * varlena, do a amgetattr() on the procedure tuple.  To do that, we
-    * need the rdesc for the procedure relation, so...
+    * need the rel for the procedure relation, so...
     */
 
    /* open pg_procedure */
 
-   rdesc = heap_openr(ProcedureRelationName);
-   if (!RelationIsValid(rdesc))
+   rel = heap_openr(ProcedureRelationName);
+   if (!RelationIsValid(rel))
    {
        elog(ERROR, "fmgr: Could not open relation %s",
             ProcedureRelationName);
@@ -101,10 +102,10 @@ fmgr_dynamic(Oid procedureId, int *pronargs)
    }
    probinattr = heap_getattr(procedureTuple,
                              Anum_pg_proc_probin,
-                             RelationGetTupleDescriptor(rdesc), &isnull);
+                             RelationGetTupleDescriptor(rel), &isnull);
    if (!PointerIsValid(probinattr) /* || isnull */ )
    {
-       heap_close(rdesc);
+       heap_close(rel);
        elog(ERROR, "fmgr: Could not extract probin for %d from %s",
             procedureId, ProcedureRelationName);
        return ((func_ptr) NULL);
index c2a5b53aeb6571ba775140e84759c558cafc0274..217aa39a2b1b2e3dc0dab9f9e2552d3f60686245 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.17 1998/06/15 19:29:44 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.18 1998/08/19 02:03:18 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -172,7 +172,7 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
    if (!(fcp = fmgr_isbuiltin(procedureId)))
    {
        procedureTuple = SearchSysCacheTuple(PROOID,
-                                          ObjectIdGetDatum(procedureId),
+                                            ObjectIdGetDatum(procedureId),
                                             0, 0, 0);
        if (!HeapTupleIsValid(procedureTuple))
        {
index 375f7b6936f9e06856d446e8f062f1c1570d55c8..1a3d4bc8506156da284b0733324ce702062fdaa9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.19 1998/08/11 18:28:25 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.20 1998/08/19 02:03:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -468,8 +468,9 @@ SetUserId()
    }
 
    userName = GetPgUserName();
-   userTup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName),
-                                 0, 0, 0);
+   userTup = SearchSysCacheTuple(USENAME,
+                                   PointerGetDatum(userName),
+                                   0, 0, 0);
    if (!HeapTupleIsValid(userTup))
        elog(FATAL, "SetUserId: user \"%s\" is not in \"%s\"",
             userName,
index 9419004042dd445b297ba077ca69260d7bac3026..fa2bb2f1d8b835c20979b7a2b750123634febb9f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.15 1998/08/11 18:28:30 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.16 1998/08/19 02:03:24 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,7 +45,6 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
    Relation    dbrel;
    HeapTuple   dbtup;
    HeapTuple   tup;
-   Buffer      buf;
    HeapScanDesc scan;
    ScanKeyData scanKey;
 
@@ -64,13 +63,10 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
    /*
     * Since we're going to close the relation, copy the tuple.
     */
-   tup = heap_getnext(scan, 0, &buf);
+   tup = heap_getnext(scan, 0);
 
    if (HeapTupleIsValid(tup))
-   {
        dbtup = heap_copytuple(tup);
-       ReleaseBuffer(buf);
-   }
    else
        dbtup = tup;
 
index c2af5a182a7d08884bdef5b5e3fd8e6330ba0102..d5889b8733d47376b117255a16945c0ec3f24f61 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.5 1998/02/25 13:08:23 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.6 1998/08/19 02:03:25 momjian Exp $
  *
  * DESCRIPTION
  *   See superuser().
@@ -30,8 +30,9 @@ superuser(void)
 
    HeapTuple   utup;
 
-   utup = SearchSysCacheTuple(USENAME, PointerGetDatum(UserName),
-                              0, 0, 0);
+   utup = SearchSysCacheTuple(USENAME,
+                               PointerGetDatum(UserName),
+                               0, 0, 0);
    Assert(utup != NULL);
    return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
 }
index 14b961f066916714c68a5faa656b47cbeb40d342..6c08bd355f12433bb2dbb828ea52b15a8ec4b2ba 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.16 1998/06/15 19:29:58 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.17 1998/08/19 02:03:28 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,7 +40,7 @@ setheapoverride(bool on)
    if (on)
    {
        TransactionIdStore(GetCurrentTransactionId(),
-                          &HeapSpecialTransactionId);
+                           &HeapSpecialTransactionId);
        HeapSpecialCommandId = GetCurrentCommandId();
    }
    else
index c9ec32801953b3d4eb86f65354ee62368d789d4f..1494665b33e2cacda62de65212b7fd7a58515569 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: genam.h,v 1.13 1998/02/26 12:14:54 vadim Exp $
+ * $Id: genam.h,v 1.14 1998/08/19 02:03:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@ index_getprocid(Relation irel, AttrNumber attnum,
 extern Datum
 GetIndexValue(HeapTuple tuple, TupleDesc hTupDesc,
              int attOff, AttrNumber attrNums[], FuncIndexInfo *fInfo,
-             bool *attNull, Buffer buffer);
+             bool *attNull);
 
 /* in genam.c */
 extern IndexScanDesc
index f96936541c1e7ecacb397c2dab1b75bb2eac3c21..4c21adde10ec5df0c843986aea974b029d196278 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: hash.h,v 1.16 1998/04/26 04:08:41 momjian Exp $
+ * $Id: hash.h,v 1.17 1998/08/19 02:03:37 momjian Exp $
  *
  * NOTES
  *     modeled after Margo Seltzer's hash implementation for unix.
@@ -271,6 +271,7 @@ extern uint32 hashint4(uint32 key);
 extern uint32 hashfloat4(float32 keyp);
 extern uint32 hashfloat8(float64 keyp);
 extern uint32 hashoid(Oid key);
+extern uint32 hashoid8(Oid key[]);
 extern uint32 hashchar(char key);
 extern uint32 hashtext(struct varlena * key);
 extern uint32 hashname(NameData *n);
index a28d06db987c2fc25d3f9855275b841970dea0a4..777f1acbe3e7fccc915caea3af9579062e8c07f4 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: heapam.h,v 1.34 1998/07/27 19:38:29 vadim Exp $
+ * $Id: heapam.h,v 1.35 1998/08/19 02:03:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -249,17 +249,17 @@ extern void heap_close(Relation relation);
 extern HeapScanDesc
 heap_beginscan(Relation relation, int atend,
               Snapshot snapshot, unsigned nkeys, ScanKey key);
-extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key);
-extern void heap_endscan(HeapScanDesc sdesc);
-extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer *b);
-extern HeapTuple heap_fetch(Relation relation, Snapshot snapshot, ItemPointer tid, Buffer *b);
+extern void heap_rescan(HeapScanDesc scan, bool scanFromEnd, ScanKey key);
+extern void heap_endscan(HeapScanDesc scan);
+extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw);
+extern HeapTuple heap_fetch(Relation relation, Snapshot snapshot, ItemPointer tid, Buffer *userbuf);
 extern Oid heap_insert(Relation relation, HeapTuple tup);
 extern int heap_delete(Relation relation, ItemPointer tid);
 extern int
 heap_replace(Relation relation, ItemPointer otid,
             HeapTuple tup);
-extern void heap_markpos(HeapScanDesc sdesc);
-extern void heap_restrpos(HeapScanDesc sdesc);
+extern void heap_markpos(HeapScanDesc scan);
+extern void heap_restrpos(HeapScanDesc scan);
 
 /* in common/heaptuple.c */
 extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]);
@@ -279,8 +279,8 @@ extern HeapTuple
 heap_formtuple(TupleDesc tupleDescriptor,
               Datum value[], char nulls[]);
 extern HeapTuple
-heap_modifytuple(HeapTuple tuple, Buffer buffer,
-    Relation relation, Datum replValue[], char replNull[], char repl[]);
+heap_modifytuple(HeapTuple tuple,
+       Relation relation, Datum replValue[], char replNull[], char repl[]);
 HeapTuple  heap_addheader(uint32 natts, int structlen, char *structure);
 
 /* in common/heap/stats.c */
index add88f5e77d2bc92deedbdf839b45bb3e7c632de..402bab9229d08cbf7caca92342c3b2c6b5390461 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tupdesc.h,v 1.17 1998/07/12 21:29:26 momjian Exp $
+ * $Id: tupdesc.h,v 1.18 1998/08/19 02:03:40 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,7 +53,7 @@ typedef struct tupleDesc
    AttributeTupleForm *attrs;
    /* attrs[N] is a pointer to the description of Attribute Number N+1.  */
    TupleConstr *constr;
-}         *TupleDesc;
+} *TupleDesc;
 
 extern TupleDesc CreateTemplateTupleDesc(int natts);
 
index caf43a80106dbd6d02ba058914a54496b09007ed..7d5cd2eafdc9b2b97db6c2609ebceab189c2cbcd 100755 (executable)
@@ -5,7 +5,10 @@
 # finds oids that are duplicated in the system tables.
 #
 
-egrep '^DATA' pg_*.h | \
+# no multibytes files
+FILES=`ls pg_*.h |grep -v '_mb.h'`
+
+egrep '^DATA' $FILES | \
    sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \
    sort -n >/tmp/alloids.$$
 uniq /tmp/alloids.$$ >/tmp/uniqoids.$$
index 3caebe74449ff40decbfb5797cfe0455194c1b3b..f3369a3b39a0d7fff18b7c1672d114a9666f6f62 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: heap.h,v 1.13 1998/08/06 05:13:01 momjian Exp $
+ * $Id: heap.h,v 1.14 1998/08/19 02:03:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,7 @@ extern Oid    heap_create_with_catalog(char *relname,
                                     TupleDesc tupdesc, char relkind);
 
 extern void heap_destroy_with_catalog(char relname[]);
-extern void heap_destroy(Relation r);
+extern void heap_destroy(Relation rel);
 
 extern void InitTempRelList(void);
 extern void DestroyTempRels(void);
index 1667b75091d1eceab2f362d6032f488ed138ef3d..15d3663a5ad43eaecc8aaba977225f9a0692e06f 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: index.h,v 1.10 1998/02/26 04:40:40 momjian Exp $
+ * $Id: index.h,v 1.11 1998/08/19 02:03:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@ extern void index_destroy(Oid indexId);
 extern void
 FormIndexDatum(int numberOfAttributes,
               AttrNumber attributeNumber[], HeapTuple heapTuple,
-              TupleDesc heapDescriptor, Buffer buffer, Datum *datum,
+              TupleDesc heapDescriptor, Datum *datum,
               char *nullv, FuncIndexInfoPtr fInfo);
 
 extern void UpdateStats(Oid relid, long reltuples, bool hasindex);
index bd3c6127dd964eae582a42eb469c2daab825f517..003ae30c0e8ef3ddce806a41af4404bf596f167f 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: indexing.h,v 1.15 1998/02/26 04:40:42 momjian Exp $
+ * $Id: indexing.h,v 1.16 1998/08/19 02:03:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,7 +37,7 @@
 #define AttributeNumIndex  "pg_attribute_relid_attnum_index"
 #define AttributeRelidIndex "pg_attribute_attrelid_index"
 #define ProcedureOidIndex  "pg_proc_oid_index"
-#define ProcedureNameIndex "pg_proc_proname_index"
+#define ProcedureNameIndex "pg_proc_proname_narg_type_index"
 #define ProcedureSrcIndex  "pg_proc_prosrc_index"
 #define TypeOidIndex      "pg_type_oid_index"
 #define TypeNameIndex     "pg_type_typname_index"
@@ -85,7 +85,7 @@ AttributeNumIndexScan(Relation heapRelation,
 extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId);
 extern HeapTuple
 ProcedureNameIndexScan(Relation heapRelation,
-                      char *procName, int nargs, Oid *argTypes);
+                      char *procName, int2 nargs, Oid *argTypes);
 extern HeapTuple ProcedureSrcIndexScan(Relation heapRelation, text *procSrc);
 extern HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId);
 extern HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName);
@@ -100,12 +100,12 @@ extern HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId);
  * The keyword is DECLARE_INDEX every thing after that is just like in a
  * normal specification of the 'define index' POSTQUEL command.
  */
-DECLARE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(mkoidname(attrelid, attname) oidname_ops));
-DECLARE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(mkoidint2(attrelid, attnum) oidint2_ops));
+DECLARE_INDEX(pg_attribute_relid_attnam_index on pg_attribute using btree(attrelid oid_ops, attname name_ops));
+DECLARE_INDEX(pg_attribute_relid_attnum_index on pg_attribute using btree(attrelid oid_ops, attnum int2_ops));
 DECLARE_INDEX(pg_attribute_attrelid_index on pg_attribute using btree(attrelid oid_ops));
 
 DECLARE_INDEX(pg_proc_oid_index on pg_proc using btree(oid oid_ops));
-DECLARE_INDEX(pg_proc_proname_index on pg_proc using btree(proname name_ops));
+DECLARE_INDEX(pg_proc_proname_narg_type_index on pg_proc using btree(proname name_ops, pronargs int2_ops, proargtypes oid8_ops));
 DECLARE_INDEX(pg_proc_prosrc_index on pg_proc using btree(prosrc text_ops));
 
 DECLARE_INDEX(pg_type_oid_index on pg_type using btree(oid oid_ops));
index 2b1667c6b11f19887bb04d06e87b7c5112b33b29..05e9b797f8b9a125df0eee15b44216f57d03f63e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_am.h,v 1.7 1998/08/11 18:28:37 momjian Exp $
+ * $Id: pg_am.h,v 1.8 1998/08/19 02:03:48 momjian Exp $
  *
  * NOTES
  *     the genbki.sh script reads this file and generates .bki
@@ -99,13 +99,13 @@ typedef FormData_pg_am *Form_pg_am;
  * ----------------
  */
 
-DATA(insert OID = 405 (  hash PGUID "o"  1 1 hashgettuple hashinsert hashdelete - - - - hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos - - hashbuild - - ));
-DESCR("");
 DATA(insert OID = 402 (  rtree PGUID "o" 8 3 rtgettuple rtinsert rtdelete - - - - rtbeginscan rtrescan rtendscan rtmarkpos rtrestrpos - - rtbuild - - ));
 DESCR("");
 DATA(insert OID = 403 (  btree PGUID "o" 5 1 btgettuple btinsert btdelete - - - - btbeginscan btrescan btendscan btmarkpos btrestrpos - - btbuild - - ));
 DESCR("");
 #define BTREE_AM_OID 403
+DATA(insert OID = 405 (  hash PGUID "o"  1 1 hashgettuple hashinsert hashdelete - - - - hashbeginscan hashrescan hashendscan hashmarkpos hashrestrpos - - hashbuild - - ));
+DESCR("");
 DATA(insert OID = 783 (  gist PGUID "o" 100 7 gistgettuple gistinsert gistdelete - - - - gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos - - gistbuild - - ));
 DESCR("");
 
index 590753fc9900477899e7f850f5e906ea67595015..2044bff6ea258afa5743515ac21537d21f328adc 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_amop.h,v 1.13 1998/08/11 05:32:45 momjian Exp $
+ * $Id: pg_amop.h,v 1.14 1998/08/19 02:03:49 momjian Exp $
  *
  * NOTES
  *  the genbki.sh script reads this file and generates .bki
@@ -177,6 +177,16 @@ DATA(insert OID = 0 (  403 427 607 3 btreesel btreenpage ));
 DATA(insert OID = 0 (  403 427 612 4 btreesel btreenpage ));
 DATA(insert OID = 0 (  403 427 610 5 btreesel btreenpage ));
 
+/*
+ * nbtree oid8_ops
+ */
+
+DATA(insert OID = 0 (  403 435 645 1 btreesel btreenpage ));
+DATA(insert OID = 0 (  403 435  647 2 btreesel btreenpage ));
+DATA(insert OID = 0 (  403 435 649 3 btreesel btreenpage ));
+DATA(insert OID = 0 (  403 435  648 4 btreesel btreenpage ));
+DATA(insert OID = 0 (  403 435  646 5 btreesel btreenpage ));
+
 /*
  * nbtree float4_ops
  */
@@ -227,36 +237,6 @@ DATA(insert OID = 0 (  403 432 560 3 btreesel btreenpage ));
 DATA(insert OID = 0 (  403 432 565 4 btreesel btreenpage ));
 DATA(insert OID = 0 (  403 432 563 5 btreesel btreenpage ));
 
-/*
- * nbtree oidint4_ops
- */
-
-DATA(insert OID = 0 (  403 435 930 1 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 435 931 2 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 435 932 3 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 435 933 4 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 435 934 5 btreesel btreenpage ));
-
-/*
- * nbtree oidint2_ops
- */
-
-DATA(insert OID = 0 (  403 437 830 1 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 437 831 2 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 437 832 3 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 437 833 4 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 437 834 5 btreesel btreenpage ));
-
-/*
- * nbtree oidname_ops
- */
-
-DATA(insert OID = 0 (  403 436 676 1 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 436 677 2 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 436 678 3 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 436 679 4 btreesel btreenpage ));
-DATA(insert OID = 0 (  403 436 680 5 btreesel btreenpage ));
-
 /*
  * nbtree bpchar_ops
  */
@@ -330,6 +310,8 @@ DATA(insert OID = 0 (  405  423  670 1 hashsel hashnpage ));
 DATA(insert OID = 0 (  405 426   96 1 hashsel hashnpage ));
 /* oid_ops */
 DATA(insert OID = 0 (  405 427  607 1 hashsel hashnpage ));
+/* oid8_ops */
+DATA(insert OID = 0 (  405 435  679 1 hashsel hashnpage ));
 /* float4_ops */
 DATA(insert OID = 0 (  405 428  620 1 hashsel hashnpage ));
 /* char_ops */
index 3c4a192cfc1478176562a8177095d827d690ebb6..e1726a59619e79f4eea0687d11564e19bb7d1891 100644 (file)
@@ -9,7 +9,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_amproc.h,v 1.8 1998/08/11 05:32:46 momjian Exp $
+ * $Id: pg_amproc.h,v 1.9 1998/08/19 02:03:51 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -61,7 +61,8 @@ typedef FormData_pg_amproc *Form_pg_amproc;
  *     initial contents of pg_amproc
  * ----------------
  */
-
+/* rtree */
 DATA(insert OID = 0 (402  422  193 1));
 DATA(insert OID = 0 (402  422  194 2));
 DATA(insert OID = 0 (402  422  195 3));
@@ -71,6 +72,12 @@ DATA(insert OID = 0 (402  433  196 3));
 DATA(insert OID = 0 (402  434  197 1));
 DATA(insert OID = 0 (402  434  198 2));
 DATA(insert OID = 0 (402  434  199 3));
+
+
+/* btree */
+DATA(insert OID = 0 (403  406  689 1));
+DATA(insert OID = 0 (403  407  690 1));
+DATA(insert OID = 0 (403  408  691 1));
 DATA(insert OID = 0 (403  421  350 1));
 DATA(insert OID = 0 (403  423  355 1));
 DATA(insert OID = 0 (403  424  353 1));
@@ -79,39 +86,39 @@ DATA(insert OID = 0 (403  426  351 1));
 DATA(insert OID = 0 (403  427  356 1));
 DATA(insert OID = 0 (403  428  354 1));
 DATA(insert OID = 0 (403  429  358 1));
-DATA(insert OID = 0 (403  406  689 1));
-DATA(insert OID = 0 (403  407  690 1));
-DATA(insert OID = 0 (403  408  691 1));
-DATA(insert OID = 0 (403 1181  359 1));
 DATA(insert OID = 0 (403  430 1274 1));
 DATA(insert OID = 0 (403  431  360 1));
 DATA(insert OID = 0 (403  432  357 1));
-DATA(insert OID = 0 (403  435  928 1));
+DATA(insert OID = 0 (403  435  404 1));
 DATA(insert OID = 0 (403  436  948 1));
 DATA(insert OID = 0 (403  437  828 1));
 DATA(insert OID = 0 (403 1076 1078 1));
 DATA(insert OID = 0 (403 1077 1079 1));
 DATA(insert OID = 0 (403 1114 1092 1));
 DATA(insert OID = 0 (403 1115 1107 1));
+DATA(insert OID = 0 (403 1181  359 1));
 DATA(insert OID = 0 (403 1312 1314 1));
 DATA(insert OID = 0 (403 1313 1315 1));
 
+
+/* hash */
+DATA(insert OID = 0 (405  406  692 1));
+DATA(insert OID = 0 (405  407  693 1));
+DATA(insert OID = 0 (405  408  694 1));
 DATA(insert OID = 0 (405  421  449 1));
 DATA(insert OID = 0 (405  423  452 1));
 DATA(insert OID = 0 (405  426  450 1));
 DATA(insert OID = 0 (405  427  453 1));
 DATA(insert OID = 0 (405  428  451 1));
 DATA(insert OID = 0 (405  429  454 1));
-DATA(insert OID = 0 (405  406  692 1));
-DATA(insert OID = 0 (405  407  693 1));
-DATA(insert OID = 0 (405  408  694 1));
-DATA(insert OID = 0 (405 1181  455 1));
 DATA(insert OID = 0 (405  430 1281 1));
 DATA(insert OID = 0 (405  431  456 1));
+DATA(insert OID = 0 (405  435  457 1));
 DATA(insert OID = 0 (405 1076 1080 1));
 DATA(insert OID = 0 (405 1077 1081 1));
 DATA(insert OID = 0 (405 1114  450 1));
 DATA(insert OID = 0 (405 1115  452 1));
+DATA(insert OID = 0 (405 1181  455 1));
 DATA(insert OID = 0 (405 1312  452 1));
 DATA(insert OID = 0 (405 1313  452 1));
 
index 10a20f91d63e6046d333aafa61abd38fd95bf59e..882830be0bb22ffa7239d1f58efd276ed7988d26 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_opclass.h,v 1.9 1998/04/26 04:09:00 momjian Exp $
+ * $Id: pg_opclass.h,v 1.10 1998/08/19 02:03:52 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -62,8 +62,6 @@ typedef FormData_pg_opclass *Form_pg_opclass;
  * (see the README in this directory), so just put zeros
  * in, which are invalid OID's anyway.  --djm
  */
-DATA(insert OID = 1181 (   name_ops         19   ));
-DESCR("");
 DATA(insert OID =  421 (   int2_ops         21   ));
 DESCR("");
 DATA(insert OID =  422 (   box_ops         603   ));
@@ -91,11 +89,7 @@ DATA(insert OID =  433 ( bigbox_ops        0   ));
 DESCR("");
 DATA(insert OID =  434 (   poly_ops        604   ));
 DESCR("");
-DATA(insert OID =  435 (   oidint4_ops     910   ));
-DESCR("");
-DATA(insert OID =  436 (   oidname_ops     911   ));
-DESCR("");
-DATA(insert OID =  437 (   oidint2_ops     810   ));
+DATA(insert OID =  435 (   oid8_ops         30   ));
 DESCR("");
 DATA(insert OID =  714 (   circle_ops      718   ));
 DESCR("");
@@ -107,6 +101,8 @@ DATA(insert OID = 1114 (    date_ops       1082   ));
 DESCR("");
 DATA(insert OID = 1115 (   time_ops       1083   ));
 DESCR("");
+DATA(insert OID = 1181 (   name_ops         19   ));
+DESCR("");
 DATA(insert OID = 1312 (   datetime_ops   1184   ));
 DESCR("");
 DATA(insert OID = 1313 (   timespan_ops   1186   ));
index 0a3820459bf4dc9fe965c3870f24d42c360678d8..9e11a79ed68069975c12a759e019f4fdb6f93cd5 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_operator.h,v 1.33 1998/08/11 18:28:45 momjian Exp $
+ * $Id: pg_operator.h,v 1.34 1998/08/19 02:03:53 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -279,6 +279,14 @@ DATA(insert OID = 606 (  "<#>"     PGUID 0 b t f 702 702 704   0   0   0   0 mktinterval -
 DATA(insert OID = 607 (  "="      PGUID 0 b t t  26  26  16 607 608 97 97 oideq eqsel eqjoinsel ));
 #define OIDEqualOperator 607   /* XXX planner/prep/semanopt.c crock */
 DATA(insert OID = 608 (  "<>"     PGUID 0 b t f  26  26  16 608 607  0  0 oidne neqsel neqjoinsel ));
+
+DATA(insert OID = 644 (  "<>"     PGUID 0 b t f  30  30  16 644 649  0  0 oid8ne neqsel neqjoinsel ));
+DATA(insert OID = 645 (  "<"      PGUID 0 b t f  30  30  16 646 648  0  0 oid8lt intltsel intltjoinsel ));
+DATA(insert OID = 646 (  ">"      PGUID 0 b t f  30  30  16 645 647  0  0 oid8gt intgtsel intgtjoinsel ));
+DATA(insert OID = 647 (  "<="     PGUID 0 b t f  30  30  16 648 646  0  0 oid8le intltsel intltjoinsel ));
+DATA(insert OID = 648 (  ">="     PGUID 0 b t f  30  30  16 647 645  0  0 oid8ge intgtsel intgtjoinsel ));
+DATA(insert OID = 649 (  "="      PGUID 0 b t f  30  30  16 649 644  0  0 oid8eq eqsel eqjoinsel ));
+
 DATA(insert OID = 609 (  "<"      PGUID 0 b t f  26  26  16 610 612  0  0 int4lt intltsel intltjoinsel ));
 DATA(insert OID = 610 (  ">"      PGUID 0 b t f  26  26  16 609 611  0  0 int4gt intgtsel intgtjoinsel ));
 DATA(insert OID = 611 (  "<="     PGUID 0 b t f  26  26  16 612 610  0  0 int4le intltsel intltjoinsel ));
@@ -337,13 +345,6 @@ DATA(insert OID = 673 (  "<="     PGUID 0 b t f  701  701  16 675 674  0 0 float8le
 DATA(insert OID = 674 (  ">"      PGUID 0 b t f  701  701  16 672 673  0 0 float8gt intltsel intltjoinsel ));
 DATA(insert OID = 675 (  ">="     PGUID 0 b t f  701  701  16 673 672  0 0 float8ge intltsel intltjoinsel ));
 
-DATA(insert OID = 676 (  "<"      PGUID 0 b t f  911  911  16 680 679  0 0 oidnamelt intltsel intltjoinsel ));
-DATA(insert OID = 677 (  "<="     PGUID 0 b t f  911  911  16 679 680  0 0 oidnamele intltsel intltjoinsel ));
-DATA(insert OID = 678 (  "="      PGUID 0 b t f  911  911  16 678 681  0 0 oidnameeq intltsel intltjoinsel ));
-DATA(insert OID = 679 (  ">="     PGUID 0 b t f  911  911  16 677 676  0 0 oidnamege intltsel intltjoinsel ));
-DATA(insert OID = 680 (  ">"      PGUID 0 b t f  911  911  16 676 677  0 0 oidnamegt intltsel intltjoinsel ));
-DATA(insert OID = 681 (  "<>"     PGUID 0 b t f  911  911  16 681 678  0 0 oidnamene intltsel intltjoinsel ));
-
 DATA(insert OID = 684 (  "+"      PGUID 0 b t f  20  20  20 684   0   0   0 int8pl - - ));
 DATA(insert OID = 685 (  "-"      PGUID 0 b t f  20  20  20 685   0   0   0 int8mi - - ));
 DATA(insert OID = 686 (  "*"      PGUID 0 b t f  20  20  20 686   0   0   0 int8mul - - ));
@@ -407,13 +408,6 @@ DATA(insert OID = 814 (  ">"      PGUID 0 b t f 704 704  16 814   0   0   0 interv
 DATA(insert OID = 815 (  "<="     PGUID 0 b t f 704 704  16 815   0   0   0 intervalle - - ));
 DATA(insert OID = 816 (  ">="     PGUID 0 b t f 704 704  16 816   0   0   0 intervalge - - ));
 
-DATA(insert OID = 830 (  "<"      PGUID 0 b t f  810  810  16 834 833  0 0 oidint2lt intltsel intltjoinsel ));
-DATA(insert OID = 831 (  "<="     PGUID 0 b t f  810  810  16 833 834  0 0 oidint2le intltsel intltjoinsel ));
-DATA(insert OID = 832 (  "="      PGUID 0 b t f  810  810  16 832 835  0 0 oidint2eq intltsel intltjoinsel ));
-DATA(insert OID = 833 (  ">="     PGUID 0 b t f  810  810  16 831 830  0 0 oidint2ge intltsel intltjoinsel ));
-DATA(insert OID = 834 (  ">"      PGUID 0 b t f  810  810  16 830 831  0 0 oidint2gt intltsel intltjoinsel ));
-DATA(insert OID = 835 (  "<>"     PGUID 0 b t f  810  810  16 835 832  0 0 oidint2ne intltsel intltjoinsel ));
-
 DATA(insert OID = 843 (  "*"      PGUID 0 b t f  790  700  790 845   0   0   0 cash_mul_flt4 - - ));
 DATA(insert OID = 844 (  "/"      PGUID 0 b t f  790  700  790   0   0   0   0 cash_div_flt4 - - ));
 DATA(insert OID = 845 (  "*"      PGUID 0 b t f  700  790  790 843   0   0   0 flt4_mul_cash - - ));
@@ -436,13 +430,6 @@ DATA(insert OID = 916 (  "*"      PGUID 0 b t f  701  790  790 908   0   0   0 flt8
 DATA(insert OID = 917 (  "*"      PGUID 0 b t f  23  790   790 912   0   0   0 int4_mul_cash - - ));
 DATA(insert OID = 918 (  "*"      PGUID 0 b t f  21  790   790 914   0   0   0 int2_mul_cash - - ));
 
-DATA(insert OID = 930 (  "<"      PGUID 0 b t f  910  910  16 934 933  0 0 oidint4lt intltsel intltjoinsel ));
-DATA(insert OID = 931 (  "<="     PGUID 0 b t f  910  910  16 933 934  0 0 oidint4le intltsel intltjoinsel ));
-DATA(insert OID = 932 (  "="      PGUID 0 b t f  910  910  16 932 935  0 0 oidint4eq intltsel intltjoinsel ));
-DATA(insert OID = 933 (  ">="     PGUID 0 b t f  910  910  16 931 930  0 0 oidint4ge intltsel intltjoinsel ));
-DATA(insert OID = 934 (  ">"      PGUID 0 b t f  910  910  16 930 931  0 0 oidint4gt intltsel intltjoinsel ));
-DATA(insert OID = 935 (  "<>"     PGUID 0 b t f  910  910  16 935 932  0 0 oidint4ne intltsel intltjoinsel ));
-
 DATA(insert OID = 965 (  "^"      PGUID 0 b t f  701  701  701 0 0 0 0 dpow - - ));
 DATA(insert OID = 966 (  "+"      PGUID 0 b t f 1034 1033 1034 0 0 0 0 aclinsert   intltsel intltjoinsel ));
 DATA(insert OID = 967 (  "-"      PGUID 0 b t f 1034 1033 1034 0 0 0 0 aclremove   intltsel intltjoinsel ));
index af78e4b1eb30b9494d8ab6f92e6519b7d2390d45..94f7439679085d922a45ea8be8d9834b4d867bc5 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.65 1998/08/15 06:47:39 thomas Exp $
+ * $Id: pg_proc.h,v 1.66 1998/08/19 02:03:54 momjian Exp $
  *
  * NOTES
  *   The script catalog/genbki.sh reads this file and generates .bki
@@ -745,6 +745,8 @@ DATA(insert OID = 355 (  btfloat8cmp       PGUID 11 f t f 2 f 23 "701 701" 100 0 0
 DESCR("btree less-equal-greater");
 DATA(insert OID = 356 (  btoidcmp         PGUID 11 f t f 2 f 23 "26 26" 100 0 0 100  foo bar ));
 DESCR("btree less-equal-greater");
+DATA(insert OID = 404 (  btoid8cmp        PGUID 11 f t f 2 f 23 "30 30" 100 0 0 100  foo bar ));
+DESCR("btree less-equal-greater");
 DATA(insert OID = 357 (  btabstimecmp     PGUID 11 f t f 2 f 23 "702 702" 100 0 0 100  foo bar ));
 DESCR("btree less-equal-greater");
 DATA(insert OID = 358 (  btcharcmp        PGUID 11 f t f 2 f 23 "18 18" 100 0 0 100  foo bar ));
@@ -825,6 +827,8 @@ DATA(insert OID = 452 (  hashfloat8        PGUID 11 f t f 2 f 23 "701 701" 100 0 0
 DESCR("hash");
 DATA(insert OID = 453 (  hashoid          PGUID 11 f t f 2 f 23 "26 26" 100 0 0 100  foo bar ));
 DESCR("hash");
+DATA(insert OID = 457 (  hashoid8         PGUID 11 f t f 2 f 23 "30 30" 100 0 0 100  foo bar ));
+DESCR("hash");
 DATA(insert OID = 454 (  hashchar         PGUID 11 f t f 2 f 23 "18 18" 100 0 0 100  foo bar ));
 DESCR("hash");
 DATA(insert OID = 455 (  hashname         PGUID 11 f t f 2 f 23 "19 19" 100 0 0 100  foo bar ));
@@ -907,10 +911,18 @@ DESCR("not equal");
 DATA(insert OID = 668 (  bpchar               PGUID 11 f t f 2 f 1042 "1042 23" 100 0 0 100  foo bar ));
 DATA(insert OID = 669 (  varchar          PGUID 11 f t f 2 f 1043 "1043 23" 100 0 0 100  foo bar ));
 
-DATA(insert OID = 682 (  mktinterval      PGUID 11 f t f 2 f 704 "702 702" 100 0 0 100 foo bar ));
+DATA(insert OID = 676 (  mktinterval      PGUID 11 f t f 2 f 704 "702 702" 100 0 0 100 foo bar ));
 DESCR("convert to interval");
-DATA(insert OID = 683 (  oid8eq               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
+DATA(insert OID = 677 (  oid8lt               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
+DESCR("less-than");
+DATA(insert OID = 678 (  oid8le               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
+DESCR("less-than-or-equal");
+DATA(insert OID = 679 (  oid8eq               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
 DESCR("equal");
+DATA(insert OID = 680 (  oid8ge               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
+DESCR("greater-than-or-equal");
+DATA(insert OID = 681 (  oid8gt               PGUID 11 f t f 2 f 16 "30 30" 100 0 0 100  foo bar ));
+DESCR("greater-than");
 
 /* OIDS 700 - 799 */
 DATA(insert OID = 710 (  getpgusername    PGUID 11 f t f 0 f 19 "0" 100 0 0 100  foo bar ));
@@ -1053,27 +1065,6 @@ DESCR("convert");
 DATA(insert OID = 819 (  text_int4        PGUID 11 f t f 1 f 23 "25" 100 0 0 100  foo bar));
 DESCR("convert");
 
-DATA(insert OID = 820 (  oidint2in        PGUID 11 f t f 1 f 810 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 821 (  oidint2out           PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 822 (  oidint2lt        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("less-than");
-DATA(insert OID = 823 (  oidint2le        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("less-than-or-equal");
-DATA(insert OID = 824 (  oidint2eq        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("equal");
-DATA(insert OID = 825 (  oidint2ge        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("greater-than-or-equal");
-DATA(insert OID = 826 (  oidint2gt        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("greater-than");
-DATA(insert OID = 827 (  oidint2ne        PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100  foo bar));
-DESCR("not equal");
-DATA(insert OID = 828 (  oidint2cmp           PGUID 11 f t f 2 f 21 "810 810" 100 0 0 100  foo bar));
-DESCR("less-equal-greater");
-DATA(insert OID = 829 (  mkoidint2        PGUID 11 f t f 2 f 810 "26 21" 100 0 0 100  foo bar));
-DESCR("");
-
 DATA(insert OID =  849 (  textpos         PGUID 11 f t f 2 f 23 "25 25" 100 0 1 0 foo bar ));
 DESCR("return position of substring");
 DATA(insert OID =  850 (  textlike        PGUID 11 f t f 2 f 16 "25 25" 100 0 1 0 foo bar ));
@@ -1159,27 +1150,6 @@ DESCR("multiply");
 
 /* OIDS 900 - 999 */
 
-DATA(insert OID = 920 (  oidint4in        PGUID 11 f t f 1 f 910 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 921 (  oidint4out           PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 922 (  oidint4lt        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("less-than");
-DATA(insert OID = 923 (  oidint4le        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("less-than-or-equal");
-DATA(insert OID = 924 (  oidint4eq        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("equal");
-DATA(insert OID = 925 (  oidint4ge        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("greater-than-or-equal");
-DATA(insert OID = 926 (  oidint4gt        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("greater-than");
-DATA(insert OID = 927 (  oidint4ne        PGUID 11 f t f 2 f 16 "910 910" 100 0 0 100  foo bar));
-DESCR("not equal");
-DATA(insert OID = 928 (  oidint4cmp           PGUID 11 f t f 2 f 23 "910 910" 100 0 0 100  foo bar));
-DESCR("less-equal-greater");
-DATA(insert OID = 929 (  mkoidint4        PGUID 11 f t f 2 f 910 "26 23" 100 0 0 100  foo bar));
-DESCR("");
-
 /* isoldpath, upgradepath, upgradepoly, revertpoly are used to update pre-v6.1 to v6.1 - tgl 97/06/03 */
 DATA(insert OID = 936 (  isoldpath        PGUID 11 f t f 1 f  16 "602" 100 0 0 100  foo bar ));
 DESCR("");
@@ -1190,27 +1160,6 @@ DESCR("");
 DATA(insert OID = 939 (  revertpoly           PGUID 11 f t f 1 f 604 "604" 100 0 0 100  foo bar ));
 DESCR("");
 
-DATA(insert OID = 940 (  oidnamein        PGUID 11 f t f 1 f 911 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 941 (  oidnameout           PGUID 11 f t f 1 f 19 "0" 100 0 0 100  foo bar));
-DESCR("(internal)");
-DATA(insert OID = 942 (  oidnamelt        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("less-than");
-DATA(insert OID = 943 (  oidnamele        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("less-than-or-equal");
-DATA(insert OID = 944 (  oidnameeq        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("equal");
-DATA(insert OID = 945 (  oidnamege        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("greater-than-or-equal");
-DATA(insert OID = 946 (  oidnamegt        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("greater-than");
-DATA(insert OID = 947 (  oidnamene        PGUID 11 f t f 2 f 16 "911 911" 100 0 0 100  foo bar));
-DESCR("not equal");
-DATA(insert OID = 948 (  oidnamecmp           PGUID 11 f t f 2 f 23 "911 911" 100 0 0 100  foo bar));
-DESCR("less-equal-greater");
-DATA(insert OID = 949 (  mkoidname        PGUID 11 f t f 2 f 911 "26 19" 100 0 0 100  foo bar));
-DESCR("");
-
 DATA(insert OID = 950 (  istrue               PGUID 11 f t f 1 f 16 "16" 100 0 0 100  foo bar ));
 DESCR("");
 DATA(insert OID = 951 (  isfalse          PGUID 11 f t f 1 f 16 "16" 100 0 0 100  foo bar ));
@@ -1508,7 +1457,7 @@ DESCR("date difference preserving months and years");
 
 /* OIDS 1200 - 1299 */
 
-DATA(insert OID = 1200 (  int42reltime    PGUID 11 f t f 1 f  703 "21" 100 0 0 100  foo bar ));
+DATA(insert OID = 1200 (  int4reltime     PGUID 11 f t f 1 f  703 "23" 100 0 0 100  foo bar ));
 DESCR("convert");
 
 DATA(insert OID = 1217 (  datetime_trunc   PGUID 11 f t f 2 f 1184 "25 1184" 100 0 0 100  foo bar ));
index bfda556afe048cd3e682c305c4597dda40c55284..85ca3eb313ceef6970dab28fe740de844bd663fb 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_type.h,v 1.43 1998/08/11 18:28:49 momjian Exp $
+ * $Id: pg_type.h,v 1.44 1998/08/19 02:03:56 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -298,14 +298,8 @@ DESCR("money '$d,ddd.cc'");
 DATA(insert OID = 791 (  _money    PGUID  -1 -1 f b t \054 0  790 array_in array_out array_in array_out i _null_ ));
 
 /* OIDS 800 - 899 */
-DATA(insert OID = 810 (  oidint2   PGUID  6  20 f b t \054 0   0 oidint2in oidint2out oidint2in oidint2out i _null_ ));
-DESCR("oid and int2 composed");
 
 /* OIDS 900 - 999 */
-DATA(insert OID = 910 (  oidint4   PGUID  8  20 f b t \054 0   0 oidint4in oidint4out oidint4in oidint4out i _null_ ));
-DESCR("oid and int4 composed");
-DATA(insert OID = 911 (  oidname   PGUID  OIDNAMELEN OIDNAMELEN f b t \054 0   0 oidnamein oidnameout oidnamein oidnameout i _null_ ));
-DESCR("oid and name composed");
 
 /* OIDS 1000 - 1099 */
 DATA(insert OID = 1000 (  _bool         PGUID -1  -1 f b t \054 0  16 array_in array_out array_in array_out i _null_ ));
index f6cbc47c55ecdaf61f2c4b140e64c118f34f6403..6b659347fa0b2a00862d1258a3731b738610e997 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1995, Regents of the University of California
  *
- * $Id: postgres.h,v 1.17 1998/07/03 04:24:10 momjian Exp $
+ * $Id: postgres.h,v 1.18 1998/08/19 02:03:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,6 @@
  *             int28     oid8
  *             bytea      text
  *             NameData   Name
- *             oidint4    oidint2    oidname
  *
  *  TABLE OF CONTENTS
  *     1)      simple type definitions
@@ -99,48 +98,6 @@ typedef struct nameData
 } NameData;
 typedef NameData *Name;
 
-/* ----------------
- *     oidint4
- *
- *     this is a new system type used by the file interface.
- * ----------------
- */
-typedef struct OidInt4Data
-{
-   Oid         oi_oid;
-   int32       oi_int4;
-} OidInt4Data;
-
-typedef struct OidInt4Data *OidInt4;
-
-/* ----------------
- *     oidint2
- *
- *     this is a new system type used to define indices on two attrs.
- * ----------------
- */
-typedef struct OidInt2Data
-{
-   Oid         oi_oid;
-   int16       oi_int2;
-} OidInt2Data;
-
-typedef struct OidInt2Data *OidInt2;
-
-/* ----------------
- *     oidname
- *
- *     this is a new system type used to define indices on two attrs.
- * ----------------
- */
-typedef struct OidNameData
-{
-   Oid         id;
-   NameData    name;
-} OidNameData;
-
-typedef struct OidNameData *OidName;
-
 /* ----------------------------------------------------------------
  *             Section 3: TransactionId and CommandId
  * ----------------------------------------------------------------
index 9b590227b5a91e27dc3c5bd81374b8fe151bd68b..60acb866348906b68de4aa64c2de83d1548a4701 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: bufmgr.h,v 1.20 1998/06/15 18:40:02 momjian Exp $
+ * $Id: bufmgr.h,v 1.21 1998/08/19 02:03:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -147,7 +147,7 @@ extern void FlushBufferPool(int StableMainMemoryFlag);
 extern BlockNumber BufferGetBlockNumber(Buffer buffer);
 extern Relation BufferGetRelation(Buffer buffer);
 extern BlockNumber RelationGetNumberOfBlocks(Relation relation);
-extern void ReleaseRelationBuffers(Relation rdesc);
+extern void ReleaseRelationBuffers(Relation rel);
 extern void DropBuffers(Oid dbid);
 extern void PrintBufferDescs(void);
 extern void PrintPinnedBufs(void);
index e359c526f00e254698222fb3aa61f2149542bdeb..26453ddae45f4cc6ca6636d935a3280a4ada1b3c 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: builtins.h,v 1.46 1998/07/12 21:29:38 momjian Exp $
+ * $Id: builtins.h,v 1.47 1998/08/19 02:04:03 momjian Exp $
  *
  * NOTES
  *   This should normally only be included by fmgr.h.
@@ -165,6 +165,7 @@ extern int32 btint42cmp(int32 a, int16 b);
 extern int32 btfloat4cmp(float32 a, float32 b);
 extern int32 btfloat8cmp(float64 a, float64 b);
 extern int32 btoidcmp(Oid a, Oid b);
+extern int32 btoid8cmp(Oid a[], Oid b[]);
 extern int32 btabstimecmp(AbsoluteTime a, AbsoluteTime b);
 extern int32 btcharcmp(char a, char b);
 extern int32 btnamecmp(NameData *a, NameData *b);
@@ -334,6 +335,10 @@ extern char *oidout(Oid o);
 extern bool oideq(Oid arg1, Oid arg2);
 extern bool oidne(Oid arg1, Oid arg2);
 extern bool oid8eq(Oid arg1[], Oid arg2[]);
+extern bool oid8lt(Oid arg1[], Oid arg2[]);
+extern bool oid8le(Oid arg1[], Oid arg2[]);
+extern bool oid8ge(Oid arg1[], Oid arg2[]);
+extern bool oid8gt(Oid arg1[], Oid arg2[]);
 extern bool oideqint4(Oid arg1, int32 arg2);
 extern bool int4eqoid(int32 arg1, Oid arg2);
 extern text *oid_text(Oid arg1);
@@ -484,7 +489,7 @@ extern bool time_gt(TimeADT *time1, TimeADT *time2);
 extern bool time_ge(TimeADT *time1, TimeADT *time2);
 extern int time_cmp(TimeADT *time1, TimeADT *time2);
 extern TimeADT *datetime_time(DateTime *datetime);
-extern int32 int42reltime(int32 timevalue);
+extern int32 int4reltime(int32 timevalue);
 
 /* like.c */
 extern bool namelike(NameData *n, struct varlena * p);
diff --git a/src/include/utils/oidcompos.h b/src/include/utils/oidcompos.h
deleted file mode 100644 (file)
index 5f58d11..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * oidcompos.h--
- *   prototype file for the oid {name,int4} composite type functions.
- *
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- * $Id: oidcompos.h,v 1.6 1998/04/26 04:09:28 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#ifndef OIDCOMPOS_H
-#define OIDCOMPOS_H
-
-/* oidint4.c */
-OidInt4        oidint4in(char *o);
-char      *oidint4out(OidInt4 o);
-bool       oidint4lt(OidInt4 o1, OidInt4 o2);
-bool       oidint4le(OidInt4 o1, OidInt4 o2);
-bool       oidint4eq(OidInt4 o1, OidInt4 o2);
-bool       oidint4ge(OidInt4 o1, OidInt4 o2);
-bool       oidint4gt(OidInt4 o1, OidInt4 o2);
-bool       oidint4ne(OidInt4 o1, OidInt4 o2);
-int            oidint4cmp(OidInt4 o1, OidInt4 o2);
-OidInt4        mkoidint4(Oid v_oid, uint32 v_int4);
-
-/* oidint2.c */
-OidInt2        oidint2in(char *o);
-char      *oidint2out(OidInt2 o);
-bool       oidint2lt(OidInt2 o1, OidInt2 o2);
-bool       oidint2le(OidInt2 o1, OidInt2 o2);
-bool       oidint2eq(OidInt2 o1, OidInt2 o2);
-bool       oidint2ge(OidInt2 o1, OidInt2 o2);
-bool       oidint2gt(OidInt2 o1, OidInt2 o2);
-bool       oidint2ne(OidInt2 o1, OidInt2 o2);
-int            oidint2cmp(OidInt2 o1, OidInt2 o2);
-OidInt2        mkoidint2(Oid v_oid, uint16 v_int2);
-
-/* oidname.c */
-OidName        oidnamein(char *inStr);
-char      *oidnameout(OidName oidname);
-bool       oidnamelt(OidName o1, OidName o2);
-bool       oidnamele(OidName o1, OidName o2);
-bool       oidnameeq(OidName o1, OidName o2);
-bool       oidnamene(OidName o1, OidName o2);
-bool       oidnamege(OidName o1, OidName o2);
-bool       oidnamegt(OidName o1, OidName o2);
-int            oidnamecmp(OidName o1, OidName o2);
-OidName        mkoidname(Oid id, char *name);
-
-#endif                         /* OIDCOMPOS_H */
index 8b1d45edb1583e19f3c45dc2c6e2d9eb9a9c702a..edfd5d47b8e41716f7ef4b850fbbfebb79b52a61 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: rel.h,v 1.17 1998/02/26 04:44:09 momjian Exp $
+ * $Id: rel.h,v 1.18 1998/08/19 02:04:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -146,12 +146,12 @@ typedef Relation *RelationPtr;
 
 
 /*
- * RelationGetRelationId --
+ * RelationGetRelid --
  *
  * returns the object id of the relation
  *
  */
-#define RelationGetRelationId(relation) ((relation)->rd_id)
+#define RelationGetRelid(relation) ((relation)->rd_id)
 
 /*
  * RelationGetFile --
index 712345614be0b089123d2b1e340cfac518dadd33..add859e5eae3805d5f6f894431de9730640fed05 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: syscache.h,v 1.10 1998/02/26 04:44:11 momjian Exp $
+ * $Id: syscache.h,v 1.11 1998/08/19 02:04:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,6 +15,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
  /* #define CACHEDEBUG *//* turns DEBUG elogs on */
 
@@ -67,8 +69,7 @@
  */
 struct cachedesc
 {
-   char       *name;           /* this is Name * so that we can
-                                * initialize it */
+   char       *name;           /* this is Name so that we can initialize it */
    int         nkeys;
    int         key[4];
    int         size;           /* sizeof(appropriate struct) */
@@ -80,18 +81,18 @@ struct cachedesc
 extern void zerocaches(void);
 extern void InitCatalogCache(void);
 extern HeapTuple
-SearchSysCacheTuple(int cacheId, Datum key1, Datum key2,
-                   Datum key3, Datum key4);
+SearchSysCacheTupleCopy(int cacheId,
+                   Datum key1, Datum key2, Datum key3, Datum key4);
+extern HeapTuple
+SearchSysCacheTuple(int cacheId,
+                   Datum key1, Datum key2, Datum key3, Datum key4);
 extern int32
 SearchSysCacheStruct(int cacheId, char *returnStruct,
                     Datum key1, Datum key2, Datum key3, Datum key4);
 extern void *
 SearchSysCacheGetAttribute(int cacheId,
                           AttrNumber attributeNumber,
-                          Datum key1,
-                          Datum key2,
-                          Datum key3,
-                          Datum key4);
+                          Datum key1, Datum key2, Datum key3, Datum key4);
 extern void *TypeDefaultRetrieve(Oid typId);
 
 #endif                         /* SYSCACHE_H */
index 835f50b359f2b6e8df86728e79b46ec4237f9b67..4f24043444ca30040abafff0a11530fa33f18d0d 100644 (file)
@@ -75,7 +75,7 @@ struct when
    char        *str;
 };
 
-struct index
+struct RelationGetRelidindex
 {
     int index1;
     int index2;
index 0d63590878121ee58cdac865d2069f4e431d303f..a0a5f4651a37e3752e1fc267ab69c257abe00dc3 100644 (file)
@@ -1,6 +1,6 @@
 .\" This is -*-nroff-*-
 .\" XXX standard disclaimer belongs here....
-.\" $Header: /cvsroot/pgsql/src/man/Attic/create_index.l,v 1.11 1998/04/26 04:09:39 momjian Exp $
+.\" $Header: /cvsroot/pgsql/src/man/Attic/create_index.l,v 1.12 1998/08/19 02:04:12 momjian Exp $
 .TH "CREATE INDEX" SQL 11/05/95 PostgreSQL PostgreSQL
 .SH NAME
 create index - construct a secondary index
@@ -149,21 +149,6 @@ btree   |oid_ops    |<=
 btree   |oid_ops    |=       
 btree   |oid_ops    |>       
 btree   |oid_ops    |>=      
-btree   |oidint2_ops|<       
-btree   |oidint2_ops|<=      
-btree   |oidint2_ops|=       
-btree   |oidint2_ops|>       
-btree   |oidint2_ops|>=      
-btree   |oidint4_ops|<       
-btree   |oidint4_ops|<=      
-btree   |oidint4_ops|=       
-btree   |oidint4_ops|>       
-btree   |oidint4_ops|>=      
-btree   |oidname_ops|<       
-btree   |oidname_ops|<=      
-btree   |oidname_ops|=       
-btree   |oidname_ops|>       
-btree   |oidname_ops|>=      
 btree   |text_ops   |<       
 btree   |text_ops   |<=      
 btree   |text_ops   |=       
@@ -226,15 +211,6 @@ Similarly,
 support indices on int4 data that is to be compared against int2 data
 in queries.
 .PP
-The operator classes
-.IR oidint2_ops ,
-.IR oidint4_ops ,
-and
-.IR oidname_ops
-represent the use of 
-.IR "functional indices"
-to simulate multi-key indices.
-These are no longer needed now that multi-key indexes are supported.
 .PP
 The Postgres query optimizer will consider using btree indices in a scan
 whenever an indexed attribute is involved in a comparison using one of:
index 751a243b40792834664580084a0d3d9ed84bb5ed..a0736dbcdac63ee2fd1959e4faf78169bde7b211 100644 (file)
@@ -3,7 +3,7 @@
  *           procedural language (PL)
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.3 1998/06/15 19:30:27 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.4 1998/08/19 02:04:14 momjian Exp $
  *
  *   This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -514,7 +514,7 @@ pltcl_func_handler(FmgrInfo *proinfo,
         * return value.
         ************************************************************/
        typeTup = SearchSysCacheTuple(TYPOID,
-                               ObjectIdGetDatum(procStruct->prorettype),
+                                   ObjectIdGetDatum(procStruct->prorettype),
                                      0, 0, 0);
        if (!HeapTupleIsValid(typeTup))
        {
@@ -544,7 +544,7 @@ pltcl_func_handler(FmgrInfo *proinfo,
        for (i = 0; i < proinfo->fn_nargs; i++)
        {
            typeTup = SearchSysCacheTuple(TYPOID,
-                           ObjectIdGetDatum(procStruct->proargtypes[i]),
+                               ObjectIdGetDatum(procStruct->proargtypes[i]),
                                          0, 0, 0);
            if (!HeapTupleIsValid(typeTup))
            {
@@ -1139,7 +1139,7 @@ pltcl_trigger_handler(FmgrInfo *proinfo)
         * for the input function
         ************************************************************/
        typeTup = SearchSysCacheTuple(TYPOID,
-                 ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid),
+                     ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid),
                                      0, 0, 0);
        if (!HeapTupleIsValid(typeTup))
        {
@@ -2156,7 +2156,7 @@ pltcl_set_tuple_values(Tcl_Interp * interp, char *arrayname,
         * for the output function
         ************************************************************/
        typeTup = SearchSysCacheTuple(TYPOID,
-                          ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
+                              ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
                                      0, 0, 0);
        if (!HeapTupleIsValid(typeTup))
        {
@@ -2229,7 +2229,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
         * for the output function
         ************************************************************/
        typeTup = SearchSysCacheTuple(TYPOID,
-                          ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
+                              ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
                                      0, 0, 0);
        if (!HeapTupleIsValid(typeTup))
        {
index c0dd5f6b1d0841a76031df9795a469797a3f1371..5e0338276b42c472e2b4c57b2c0d179c6a318b3b 100755 (executable)
@@ -797,6 +797,7 @@ do
 # workaround indent bug
    sed 's;^static[     ][  ]*;static ;g' |
    sed 's;^}[  ][  ]*/\*;}   /*;' |
+   sed 's;^#endif[     ][  ]*/\*;#endif   /*;' |
    detab -t8 -qc |
    entab -t4 -qc |
 # move trailing * in function return type