*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.29 1999/11/17 23:51:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.30 1999/11/21 01:58:22 tgl Exp $
*
* Note - this code is real crufty...
*
#include "catalog/catalog.h"
#include "catalog/catname.h"
#include "catalog/heap.h"
+#include "catalog/pg_class.h"
#include "miscadmin.h"
#include "storage/sinval.h"
#include "utils/catcache.h"
#include "utils/inval.h"
#include "utils/relcache.h"
-static InvalidationEntry InvalidationEntryAllocate(uint16 size);
-static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ());
-static LocalInvalid LocalInvalidRegister(LocalInvalid invalid,
- InvalidationEntry entry);
-static void getmyrelids(void);
-
/* ----------------
* private invalidation structures
* ----------------
*/
+
+typedef struct InvalidationUserData
+{
+ struct InvalidationUserData *dataP[1]; /* VARIABLE LENGTH */
+} InvalidationUserData; /* VARIABLE LENGTH STRUCTURE */
+
+typedef struct InvalidationEntryData
+{
+ InvalidationUserData *nextP;
+ InvalidationUserData userData; /* VARIABLE LENGTH ARRAY */
+} InvalidationEntryData; /* VARIABLE LENGTH STRUCTURE */
+
+typedef Pointer InvalidationEntry;
+
+typedef InvalidationEntry LocalInvalid;
+
+#define EmptyLocalInvalid NULL
+
typedef struct CatalogInvalidationData
{
Index cacheId;
* variables and macros
* ----------------
*/
-static LocalInvalid Invalid = EmptyLocalInvalid; /* XXX global */
+static LocalInvalid Invalid = EmptyLocalInvalid; /* head of linked list */
-Oid MyRelationRelationId = InvalidOid;
-Oid MyAttributeRelationId = InvalidOid;
-Oid MyAMRelationId = InvalidOid;
-Oid MyAMOPRelationId = InvalidOid;
-#define ValidateHacks() \
- if (!OidIsValid(MyRelationRelationId)) getmyrelids()
+static InvalidationEntry InvalidationEntryAllocate(uint16 size);
+static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ());
+static LocalInvalid LocalInvalidRegister(LocalInvalid invalid,
+ InvalidationEntry entry);
+
/* ----------------------------------------------------------------
* "local" invalidation support functions
/* --------------------------------
* LocalInvalidRegister
- * Returns a new local cache invalidation state containing a new entry.
+ * Link an invalidation entry into a chain of them. Really ugly
+ * coding here.
* --------------------------------
*/
static LocalInvalid
/* --------------------------------
* LocalInvalidInvalidate
* Processes, then frees all entries in a local cache
- * invalidation state.
+ * invalidation list.
* --------------------------------
*/
static void
ItemPointerCopy(pointer, &message->any.catalog.pointerData);
/* ----------------
- * Note: Invalid is a global variable
+ * Add message to linked list of unprocessed messages.
* ----------------
*/
Invalid = LocalInvalidRegister(Invalid, (InvalidationEntry) message);
message->any.relation.objectId = objectId;
/* ----------------
- * Note: Invalid is a global variable
+ * Add message to linked list of unprocessed messages.
* ----------------
*/
Invalid = LocalInvalidRegister(Invalid, (InvalidationEntry) message);
}
-/* --------------------------------
- * getmyrelids
- * --------------------------------
- */
-static void
-getmyrelids()
-{
- MyRelationRelationId = RelnameFindRelid(RelationRelationName);
- Assert(RelationRelationName != InvalidOid);
-
- MyAttributeRelationId = RelnameFindRelid(AttributeRelationName);
- Assert(AttributeRelationName != InvalidOid);
-
- MyAMRelationId = RelnameFindRelid(AccessMethodRelationName);
- Assert(MyAMRelationId != InvalidOid);
-
- MyAMOPRelationId = RelnameFindRelid(AccessMethodOperatorRelationName);
- Assert(MyAMOPRelationId != InvalidOid);
-}
-
/* --------------------------------
* CacheIdInvalidate
*
CacheIdInvalidate_DEBUG1;
- ValidateHacks(); /* XXX */
-
/* ----------------
- * if the cacheId is the oid of any of the tuples in the
- * following system relations, then assume we are invalidating
- * a relation descriptor
+ * if the cacheId is the oid of any of the following system relations,
+ * then assume we are invalidating a relation descriptor
* ----------------
*/
- if (cacheId == MyRelationRelationId)
+ if (cacheId == RelOid_pg_class)
{
RelationIdInvalidateRelationCacheByRelationId(hashIndex);
return;
}
- if (cacheId == MyAttributeRelationId)
+ if (cacheId == RelOid_pg_attribute)
{
RelationIdInvalidateRelationCacheByRelationId(hashIndex);
return;
}
- if (cacheId == MyAMRelationId)
- {
- RelationIdInvalidateRelationCacheByAccessMethodId(hashIndex);
- return;
- }
-
- if (cacheId == MyAMOPRelationId)
- {
- RelationIdInvalidateRelationCacheByAccessMethodId(InvalidOid);
- return;
- }
-
/* ----------------
* Yow! the caller asked us to invalidate something else.
* ----------------
void (*function) ())
{
Oid relationId;
- Oid objectId = (Oid) 0;
+ Oid objectId;
/* ----------------
* get the relation object id
* ----------------
*/
- ValidateHacks(); /* XXX */
relationId = RelationGetRelid(relation);
/* ----------------
- *
+ * is it one of the ones we need to send an SI message for?
* ----------------
*/
- if (relationId == MyRelationRelationId)
+ if (relationId == RelOid_pg_class)
objectId = tuple->t_data->t_oid;
- else if (relationId == MyAttributeRelationId)
+ else if (relationId == RelOid_pg_attribute)
objectId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid;
- else if (relationId == MyAMRelationId)
- objectId = tuple->t_data->t_oid;
- else if (relationId == MyAMOPRelationId)
- {
- ; /* objectId is unused */
- }
else
return;
}
-/*
- * InitLocalInvalidateData
- *
- * Setup this before anything could ever get invalid!
- * Called by InitPostgres();
- */
-void
-InitLocalInvalidateData()
-{
- ValidateHacks();
-}
-
-
/*
* DiscardInvalid
* Causes the invalidated cache state to be discarded.
void
RegisterInvalid(bool send)
{
+ LocalInvalid invalid;
+
/* ----------------
* debugging stuff
* ----------------
#endif /* defined(INVALIDDEBUG) */
/* ----------------
- * Note: Invalid is a global variable
+ * Process and free the current list of inval messages.
* ----------------
*/
+ invalid = Invalid;
+ Invalid = EmptyLocalInvalid; /* anything added now is part of a new list */
+
if (send)
- LocalInvalidInvalidate(Invalid,
+ LocalInvalidInvalidate(invalid,
InvalidationMessageRegisterSharedInvalid);
else
- LocalInvalidInvalidate(Invalid,
+ LocalInvalidInvalidate(invalid,
InvalidationMessageCacheInvalidate);
- Invalid = EmptyLocalInvalid;
}
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.79 1999/11/18 13:56:28 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.80 1999/11/21 01:58:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static void formrdesc(char *relationName, u_int natts,
FormData_pg_attribute *att);
-#ifdef NOT_USED /* See comments at line 1304 */
-static void RelationFlushIndexes(Relation *r, Oid accessMethodId);
-
-#endif
-
static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo);
static HeapTuple scan_pg_rel_seq(RelationBuildDescInfo buildinfo);
static HeapTuple scan_pg_rel_ind(RelationBuildDescInfo buildinfo);
}
}
-#if NOT_USED /* See comments at line 1304 */
-/* --------------------------------
- * RelationIdInvalidateRelationCacheByAccessMethodId
- *
- * RelationFlushIndexes is needed for use with HashTableWalk..
- * --------------------------------
+#if NOT_USED
+/* only used by RelationIdInvalidateRelationCacheByAccessMethodId,
+ * which is dead code.
*/
static void
RelationFlushIndexes(Relation *r,
#endif
+#if NOT_USED
void
RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId)
{
-#ifdef NOT_USED
-
/*
* 25 aug 1992: mao commented out the ht walk below. it should be
* doing the right thing, in theory, but flushing reldescs for index
* don't want to introduce new bugs. this code never executed before,
* so i'm turning it off for now. after the release is cut, i'll fix
* this up.
+ *
+ * 20 nov 1999: this code has still never done anything, so I'm
+ * cutting the routine out of the system entirely. tgl
*/
HashTableWalk(RelationNameCache, (HashtFunc) RelationFlushIndexes,
accessMethodId);
-#else
- return;
-#endif
}
+#endif
/*
* RelationCacheInvalidate