where necessary --- several of them didn't really need it, though.
tqual-checking macros simplified accordingly.
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/* 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;
*
*
* 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.
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,
*
*
* 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
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))
{
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);
/*
*/
ReleaseRelationBuffers(rel);
- RemoveConstraints(rel);
-
/* ----------------
* unlink the relation's physical file and finish up.
* ----------------
*
*
* 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
/* ----------------
* 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
* ----------------
*
*
* 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.
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? */
nulls,
replaces);
- setheapoverride(true);
heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
- setheapoverride(false);
}
else
elog(ERROR, "OperatorDef: no operator %u", operatorObjectId);
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,
nulls,
replaces);
- setheapoverride(true);
heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
- setheapoverride(false);
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
nulls,
replaces);
- setheapoverride(true);
heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
- setheapoverride(false);
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
nulls,
replaces);
- setheapoverride(true);
heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
- setheapoverride(false);
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
nulls,
replaces);
- setheapoverride(true);
heap_update(pg_type_desc, &tup->t_self, tup, NULL);
- setheapoverride(false);
typeObjectId = tup->t_data->t_oid;
}
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);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* 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);
/* ----------------------------------------------------------
} /* 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);
} else {
desctuple = heap_modifytuple(searchtuple, description, values,
nulls, replaces);
- setheapoverride(true);
heap_update(description, &searchtuple->t_self, desctuple, NULL);
- setheapoverride(false);
modified = TRUE;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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);
}
}
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
replNull,
repl);
- setheapoverride(true);
heap_update(procrel, &tup->t_self, newtup, NULL);
- setheapoverride(false);
setoid = newtup->t_data->t_oid;
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* 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())
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
}
else if (TransactionIdIsCurrentTransactionId(th->t_xmin))
{
- if (CommandIdGEScanCommandId(th->t_cmin) && !heapisoverride())
+ if (CommandIdGEScanCommandId(th->t_cmin))
return HeapTupleInvisible; /* inserted after scan
* started */
*
* 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;
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) \
( \
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) \
) \
)
-#define heapisoverride() \
-( \
- (!TransactionIdIsValid(HeapSpecialTransactionId)) ? \
- false \
- : \
- ( \
- (!TransactionIdEquals(GetCurrentTransactionId(), \
- HeapSpecialTransactionId) || \
- GetCurrentCommandId() != HeapSpecialCommandId) ? \
- ( \
- HeapSpecialTransactionId = InvalidTransactionId, \
- false \
- ) \
- : \
- true \
- ) \
-)
-
#define HeapTupleMayBeUpdated 0
#define HeapTupleInvisible 1
#define HeapTupleSelfUpdated 2
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);