setheapoverride() is history. Uses replaced with CommandCounterIncrement()
authorTom Lane
Mon, 17 Jan 2000 23:57:48 +0000 (23:57 +0000)
committerTom Lane
Mon, 17 Jan 2000 23:57:48 +0000 (23:57 +0000)
where necessary --- several of them didn't really need it, though.
tqual-checking macros simplified accordingly.

13 files changed:
src/backend/access/gist/gist.c
src/backend/catalog/aclchk.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_type.c
src/backend/commands/_deadcode/recipe.c
src/backend/commands/comment.c
src/backend/executor/execMain.c
src/backend/utils/adt/sets.c
src/backend/utils/cache/catcache.c
src/backend/utils/time/tqual.c
src/include/utils/tqual.h

index 6b873ab84afa5a4d579d3dd0f54dc1839f7eec4c..9c9e8aeee7f0b30104dc9c9819ba8241be590f8f 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.48 1999/12/10 03:55:42 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.49 2000/01/17 23:57:41 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -98,9 +98,9 @@ gistbuild(Relation heap,
 
    /* no locking is needed */
 
-   setheapoverride(true);      /* so we can see the new pg_index tuple */
+   CommandCounterIncrement();      /* so we can see the new pg_index tuple */
+
    initGISTstate(&giststate, index);
-   setheapoverride(false);
 
    pred = predInfo->pred;
    oldPred = predInfo->oldPred;
index 09aa138cf7c598c0c2101f84ccafe03ecb114584..0e1a98d07cd7fb7ab18f7d6c7575aa7796378be4 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.35 2000/01/16 20:04:54 petere Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.36 2000/01/17 23:57:43 tgl Exp $
  *
  * NOTES
  *   See acl.h.
@@ -149,10 +149,8 @@ ChangeAcl(char *relname,
    replaces[Anum_pg_class_relacl - 1] = 'r';
    values[Anum_pg_class_relacl - 1] = (Datum) new_acl;
    tuple = heap_modifytuple(tuple, relation, values, nulls, replaces);
-   /* XXX handle index on pg_class? */
-   setheapoverride(true);
+
    heap_update(relation, &tuple->t_self, tuple, NULL);
-   setheapoverride(false);
 
    /* keep the catalog indices up to date */
    CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices,
index 0476f2c8223bc73c4fad0762ded612e0763717af..d61df6561b6da58412ad66dde11cbb5cad035b0e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.116 2000/01/17 02:04:12 tgl Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.117 2000/01/17 23:57:43 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -1065,7 +1065,7 @@ DeleteRelationTuple(Relation rel)
    pg_class_desc = heap_openr(RelationRelationName, RowExclusiveLock);
 
    tup = SearchSysCacheTupleCopy(RELOID,
-                      ObjectIdGetDatum(rel->rd_att->attrs[0]->attrelid),
+                                 ObjectIdGetDatum(rel->rd_id),
                                  0, 0, 0);
    if (!HeapTupleIsValid(tup))
    {
@@ -1509,31 +1509,25 @@ heap_drop_with_catalog(char *relname)
    DeleteAttributeTuples(rel);
 
    /* ----------------
-    *  delete comments
+    *  delete comments, statistics, and constraints
     * ----------------
     */
    DeleteComments(RelationGetRelid(rel));
 
-   /* ----------------
-    *  delete statistics
-    * ----------------
-    */
    RemoveStatistics(rel);
 
+   RemoveConstraints(rel);
+
    /* ----------------
-    *  delete type tuple.  here we want to see the effects
-    *  of the deletions we just did, so we use setheapoverride().
+    *  delete type tuple
     * ----------------
     */
-   setheapoverride(true);
    DeleteTypeTuple(rel);
-   setheapoverride(false);
 
    /* ----------------
     *  delete relation tuple
     * ----------------
     */
-   /* must delete fake tuple in cache */
    DeleteRelationTuple(rel);
 
    /*
@@ -1541,8 +1535,6 @@ heap_drop_with_catalog(char *relname)
     */
    ReleaseRelationBuffers(rel);
 
-   RemoveConstraints(rel);
-
    /* ----------------
     *  unlink the relation's physical file and finish up.
     * ----------------
index 7c7ffa3250d45fa270c7b34ea5326ae198631d9a..84009d6282b636656099bd0396db8d3432a16fff 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.101 1999/12/20 10:40:40 wieck Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.102 2000/01/17 23:57:43 tgl Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -904,19 +904,16 @@ InitIndexStrategy(int numatts,
 
    /* ----------------
     *  fill in the index strategy structure with information
-    *  from the catalogs.  Note: we use heap override mode
-    *  in order to be allowed to see the correct information in the
-    *  catalogs, even though our transaction has not yet committed.
+    *  from the catalogs.  First we must advance the command counter
+    *  so that we will see the newly-entered index catalog tuples.
     * ----------------
     */
-   setheapoverride(true);
+   CommandCounterIncrement();
 
    IndexSupportInitialize(strategy, support,
                           attrelid, accessMethodObjectId,
                           amstrategies, amsupport, numatts);
 
-   setheapoverride(false);
-
    /* ----------------
     *  store the strategy information in the index reldesc
     * ----------------
index a143c807c777787e0aad3e4e3b90f29fd321de15..45c284cd9d073cca764dc8ed987565317ad7b635 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.47 2000/01/10 17:14:31 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.48 2000/01/17 23:57:43 tgl Exp $
  *
  * NOTES
  *   these routines moved here from commands/define.c and somewhat cleaned up.
@@ -775,6 +775,9 @@ OperatorDef(char *operatorName,
        opKey[1].sk_argument = ObjectIdGetDatum(leftTypeId);
        opKey[2].sk_argument = ObjectIdGetDatum(rightTypeId);
 
+       /* Make sure we can see the shell even if it is new in current cmd */
+       CommandCounterIncrement();
+
        pg_operator_scan = heap_beginscan(pg_operator_desc,
                                          0,
                                          SnapshotSelf, /* no cache? */
@@ -790,9 +793,7 @@ OperatorDef(char *operatorName,
                                   nulls,
                                   replaces);
 
-           setheapoverride(true);
            heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
-           setheapoverride(false);
        }
        else
            elog(ERROR, "OperatorDef: no operator %u", operatorObjectId);
@@ -875,7 +876,13 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 
    pg_operator_desc = heap_openr(OperatorRelationName, RowExclusiveLock);
 
-   /* check and update the commutator, if necessary */
+   /*
+    * check and update the commutator & negator, if necessary
+    *
+    * First make sure we can see them...
+    */
+   CommandCounterIncrement();
+
    opKey[0].sk_argument = ObjectIdGetDatum(commId);
 
    pg_operator_scan = heap_beginscan(pg_operator_desc,
@@ -920,9 +927,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                                       nulls,
                                       replaces);
 
-               setheapoverride(true);
                heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
-               setheapoverride(false);
 
                if (RelationGetForm(pg_operator_desc)->relhasindex)
                {
@@ -954,9 +959,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                               nulls,
                               replaces);
 
-       setheapoverride(true);
        heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
-       setheapoverride(false);
 
        if (RelationGetForm(pg_operator_desc)->relhasindex)
        {
@@ -994,9 +997,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
                               nulls,
                               replaces);
 
-       setheapoverride(true);
        heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
-       setheapoverride(false);
 
        if (RelationGetForm(pg_operator_desc)->relhasindex)
        {
index 2b9e9d6eccd82e73ce1c511e12c9115711cb1c4d..3de8020595c766b45e24e056013cf5ab00072991 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.46 2000/01/10 20:23:28 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.47 2000/01/17 23:57:43 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -481,9 +481,7 @@ TypeCreate(char *typeName,
                               nulls,
                               replaces);
 
-       setheapoverride(true);
        heap_update(pg_type_desc, &tup->t_self, tup, NULL);
-       setheapoverride(false);
 
        typeObjectId = tup->t_data->t_oid;
    }
@@ -558,9 +556,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
 
    namestrcpy(&(((Form_pg_type) GETSTRUCT(oldtup))->typname), newTypeName);
 
-   setheapoverride(true);
    heap_update(pg_type_desc, &oldtup->t_self, oldtup, NULL);
-   setheapoverride(false);
 
    /* update the system catalog indices */
    CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs);
index dc0928fe97b0f2197b02d7811e3cdbe4eda7601a..9a5eda6906fa124a2f703b07d4cb65788644ae37 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.8 2000/01/10 17:14:33 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.9 2000/01/17 23:57:44 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -211,9 +211,10 @@ beginRecipe(RecipeStmt *stmt)
        /*
         * before we plan, we want to see all the changes we did, during
         * the rewrite phase, such as creating the tee tables,
-        * setheapoverride() allows us to see the changes
+        * CommandCounterIncrement() allows us to see the changes
         */
-       setheapoverride(true);
+       CommandCounterIncrement();
+
        plan = planner(parsetree);
 
        /* ----------------------------------------------------------
@@ -265,8 +266,6 @@ beginRecipe(RecipeStmt *stmt)
 
        }                       /* if (teeInfo) */
 
-       setheapoverride(false);
-
        /* define a portal for this viewer input */
        /* for now, eyes can only have one input */
        snprintf(portalName, 1024, "%s%d", e->nodeName, 0);
index 93feb9e8054f8cd2cfc28e757fcb86ec19730994..9ebf207199c4f895300c58d43821a317903bb694 100644 (file)
@@ -165,9 +165,7 @@ void CreateComments(Oid oid, char *comment) {
     } else {
       desctuple = heap_modifytuple(searchtuple, description, values,
                   nulls, replaces);
-      setheapoverride(true);
       heap_update(description, &searchtuple->t_self, desctuple, NULL);
-      setheapoverride(false);
       modified = TRUE;
     }
 
index 352e368d99a6ca7f1928a2a864fd921658297608..fa98950ac1ff237606af513fbd5d04a360c1e3c1 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.104 2000/01/05 18:23:46 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.105 2000/01/17 23:57:45 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -723,18 +723,13 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
                FreeTupleDesc(tupdesc);
 
                /*
-                * XXX rather than having to call setheapoverride(true)
-                * and then back to false, we should change the arguments
-                * to heap_open() instead..
-                *
-                * XXX no, we should use commandCounterIncrement...
+                * Advance command counter so that the newly-created
+                * relation's catalog tuples will be visible to heap_open.
                 */
-               setheapoverride(true);
+               CommandCounterIncrement();
 
                intoRelationDesc = heap_open(intoRelationId,
                                             AccessExclusiveLock);
-
-               setheapoverride(false);
            }
        }
    }
index ba94496cea5758aeefcfea8e9aef204c4f1db06a..baa4e67b33d30b4292590e7dddf24396aae0f0da 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.28 1999/11/24 00:44:35 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.29 2000/01/17 23:57:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -113,9 +113,7 @@ SetDefine(char *querystr, char *typename)
                                      replNull,
                                      repl);
 
-           setheapoverride(true);
            heap_update(procrel, &tup->t_self, newtup, NULL);
-           setheapoverride(false);
 
            setoid = newtup->t_data->t_oid;
        }
index c9f26f38ad0934e94e77144af6b3620678df6ec5..aa76d46862f3e7fa059a23c0404bde64d53359b3 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.56 2000/01/10 16:13:15 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.57 2000/01/17 23:57:46 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1047,8 +1047,7 @@ SearchSysCache(struct catcache * cache,
     *  if this isn't bootstrap (initdb) time, use the index.
     * ----------------
     */
-   CACHE2_elog(DEBUG, "SearchSysCache: performing scan (override==%d)",
-               heapisoverride());
+   CACHE1_elog(DEBUG, "SearchSysCache: performing scan");
 
    if ((RelationGetForm(relation))->relhasindex
        && !IsBootstrapProcessingMode())
index 4a96c5736cfbc94da7cb1bb64a7b473116647377..32479fb278085bf7ff998c0d7580543e30252c5e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.33 1999/12/10 12:34:14 wieck Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.34 2000/01/17 23:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -26,31 +26,6 @@ Snapshot SerializableSnapshot = NULL;
 
 bool       ReferentialIntegritySnapshotOverride = false;
 
-/*
- * XXX Transaction system override hacks start here
- */
-#ifndef GOODAMI
-
-TransactionId HeapSpecialTransactionId = InvalidTransactionId;
-CommandId  HeapSpecialCommandId = FirstCommandId;
-
-void
-setheapoverride(bool on)
-{
-   if (on)
-   {
-       TransactionIdStore(GetCurrentTransactionId(),
-                          &HeapSpecialTransactionId);
-       HeapSpecialCommandId = GetCurrentCommandId();
-   }
-   else
-       HeapSpecialTransactionId = InvalidTransactionId;
-}
-
-#endif  /* !defined(GOODAMI) */
-/*
- * XXX Transaction system override hacks end here
- */
 
 /*
  * HeapTupleSatisfiesItself
@@ -311,7 +286,7 @@ HeapTupleSatisfiesUpdate(HeapTuple tuple)
        }
        else if (TransactionIdIsCurrentTransactionId(th->t_xmin))
        {
-           if (CommandIdGEScanCommandId(th->t_cmin) && !heapisoverride())
+           if (CommandIdGEScanCommandId(th->t_cmin))
                return HeapTupleInvisible;      /* inserted after scan
                                                 * started */
 
index 89314764ea60cf5c8240c860febf8c24d078faef..311b479a0746dbc033f87abe3e9a6dbb7775560e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tqual.h,v 1.26 1999/12/10 12:34:15 wieck Exp $
+ * $Id: tqual.h,v 1.27 2000/01/17 23:57:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "access/htup.h"
 #include "access/xact.h"
 
+
 typedef struct SnapshotData
 {
-   TransactionId xmin;         /* XID < xmin are visible to me */
-   TransactionId xmax;         /* XID >= xmax are invisible to me */
-   uint32      xcnt;           /* # of xact below */
-   TransactionId *xip;         /* array of xacts in progress */
-   ItemPointerData tid;        /* required for Dirty snapshot -:( */
+   TransactionId   xmin;       /* XID < xmin are visible to me */
+   TransactionId   xmax;       /* XID >= xmax are invisible to me */
+   uint32          xcnt;       /* # of xact below */
+   TransactionId  *xip;        /* array of xacts in progress */
+   ItemPointerData tid;        /* required for Dirty snapshot -:( */
 } SnapshotData;
 
 typedef SnapshotData *Snapshot;
@@ -38,20 +39,19 @@ extern Snapshot SerializableSnapshot;
 
 extern bool ReferentialIntegritySnapshotOverride;
 
-#define IsSnapshotNow(snapshot)        ((Snapshot) snapshot == SnapshotNow)
-#define IsSnapshotSelf(snapshot)   ((Snapshot) snapshot == SnapshotSelf)
-#define IsSnapshotAny(snapshot)        ((Snapshot) snapshot == SnapshotAny)
-#define IsSnapshotDirty(snapshot)  ((Snapshot) snapshot == SnapshotDirty)
+#define IsSnapshotNow(snapshot)        ((Snapshot) (snapshot) == SnapshotNow)
+#define IsSnapshotSelf(snapshot)   ((Snapshot) (snapshot) == SnapshotSelf)
+#define IsSnapshotAny(snapshot)        ((Snapshot) (snapshot) == SnapshotAny)
+#define IsSnapshotDirty(snapshot)  ((Snapshot) (snapshot) == SnapshotDirty)
 
-extern TransactionId HeapSpecialTransactionId;
-extern CommandId HeapSpecialCommandId;
 
 /*
  * HeapTupleSatisfiesVisibility
  *     True iff heap tuple satsifies a time qual.
  *
- * Note:
+ * Notes:
  *     Assumes heap tuple is valid.
+ *     Beware of multiple evaluations of arguments.
  */
 #define HeapTupleSatisfiesVisibility(tuple, snapshot) \
 ( \
@@ -59,16 +59,16 @@ extern CommandId HeapSpecialCommandId;
        false \
    : \
    ( \
-       (IsSnapshotAny(snapshot) || heapisoverride()) ? \
+       IsSnapshotAny(snapshot) ? \
            true \
        : \
-           ((IsSnapshotSelf(snapshot) || heapisoverride()) ? \
+           (IsSnapshotSelf(snapshot) ? \
                HeapTupleSatisfiesItself((tuple)->t_data) \
            : \
-               ((IsSnapshotDirty(snapshot)) ? \
+               (IsSnapshotDirty(snapshot) ? \
                    HeapTupleSatisfiesDirty((tuple)->t_data) \
                : \
-                   ((IsSnapshotNow(snapshot)) ? \
+                   (IsSnapshotNow(snapshot) ? \
                        HeapTupleSatisfiesNow((tuple)->t_data) \
                    : \
                        HeapTupleSatisfiesSnapshot((tuple)->t_data, snapshot) \
@@ -78,24 +78,6 @@ extern CommandId HeapSpecialCommandId;
    ) \
 )
 
-#define heapisoverride() \
-( \
-   (!TransactionIdIsValid(HeapSpecialTransactionId)) ? \
-       false \
-   : \
-   ( \
-       (!TransactionIdEquals(GetCurrentTransactionId(), \
-                            HeapSpecialTransactionId) || \
-        GetCurrentCommandId() != HeapSpecialCommandId) ? \
-       ( \
-           HeapSpecialTransactionId = InvalidTransactionId, \
-           false \
-       ) \
-       : \
-           true \
-   ) \
-)
-
 #define HeapTupleMayBeUpdated      0
 #define HeapTupleInvisible         1
 #define HeapTupleSelfUpdated       2
@@ -105,11 +87,10 @@ extern CommandId HeapSpecialCommandId;
 extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
 extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
 extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple);
-extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot);
+extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
+                                      Snapshot snapshot);
 extern int HeapTupleSatisfiesUpdate(HeapTuple tuple);
 
-extern void setheapoverride(bool on);
-
 extern Snapshot GetSnapshotData(bool serializable);
 extern void SetQuerySnapshot(void);
 extern void FreeXactSnapshot(void);