mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Pgindent run for 8.0.
This commit is contained in:
8
src/backend/utils/cache/catcache.c
vendored
8
src/backend/utils/cache/catcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.115 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.116 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -519,9 +519,9 @@ CreateCacheMemoryContext(void)
|
||||
if (!CacheMemoryContext)
|
||||
CacheMemoryContext = AllocSetContextCreate(TopMemoryContext,
|
||||
"CacheMemoryContext",
|
||||
ALLOCSET_DEFAULT_MINSIZE,
|
||||
ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
ALLOCSET_DEFAULT_MINSIZE,
|
||||
ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
}
|
||||
|
||||
|
||||
|
52
src/backend/utils/cache/inval.c
vendored
52
src/backend/utils/cache/inval.c
vendored
@ -34,7 +34,7 @@
|
||||
* the other backends won't see our updated tuples as good.
|
||||
*
|
||||
* When a subtransaction aborts, we can process and discard any events
|
||||
* it has queued. When a subtransaction commits, we just add its events
|
||||
* it has queued. When a subtransaction commits, we just add its events
|
||||
* to the pending lists of the parent transaction.
|
||||
*
|
||||
* In short, we need to remember until xact end every insert or delete
|
||||
@ -80,7 +80,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.65 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.66 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -146,7 +146,7 @@ typedef struct TransInvalidationInfo
|
||||
InvalidationListHeader PriorCmdInvalidMsgs;
|
||||
|
||||
/* init file must be invalidated? */
|
||||
bool RelcacheInitFileInval;
|
||||
bool RelcacheInitFileInval;
|
||||
} TransInvalidationInfo;
|
||||
|
||||
static TransInvalidationInfo *transInvalInfo = NULL;
|
||||
@ -304,7 +304,7 @@ AddRelcacheInvalidationMessage(InvalidationListHeader *hdr,
|
||||
/* relfilenode fields must be checked to support reassignment */
|
||||
ProcessMessageList(hdr->rclist,
|
||||
if (msg->rc.relId == relId &&
|
||||
RelFileNodeEquals(msg->rc.physId, physId)) return);
|
||||
RelFileNodeEquals(msg->rc.physId, physId)) return);
|
||||
|
||||
/* OK, add the item */
|
||||
msg.rc.id = SHAREDINVALRELCACHE_ID;
|
||||
@ -411,9 +411,9 @@ LocalExecuteInvalidationMessage(SharedInvalidationMessage *msg)
|
||||
else if (msg->id == SHAREDINVALRELCACHE_ID)
|
||||
{
|
||||
/*
|
||||
* If the message includes a valid relfilenode, we must ensure that
|
||||
* smgr cache entry gets zapped. The relcache will handle this if
|
||||
* called, otherwise we must do it directly.
|
||||
* If the message includes a valid relfilenode, we must ensure
|
||||
* that smgr cache entry gets zapped. The relcache will handle
|
||||
* this if called, otherwise we must do it directly.
|
||||
*/
|
||||
if (msg->rc.dbId == MyDatabaseId || msg->rc.dbId == InvalidOid)
|
||||
{
|
||||
@ -483,7 +483,7 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
|
||||
Oid tupleRelId;
|
||||
Oid databaseId;
|
||||
Oid relationId;
|
||||
RelFileNode rnode;
|
||||
RelFileNode rnode;
|
||||
|
||||
/* Do nothing during bootstrap */
|
||||
if (IsBootstrapProcessingMode())
|
||||
@ -531,12 +531,14 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
|
||||
rnode.spcNode = MyDatabaseTableSpace;
|
||||
rnode.dbNode = databaseId;
|
||||
rnode.relNode = classtup->relfilenode;
|
||||
|
||||
/*
|
||||
* Note: during a pg_class row update that assigns a new relfilenode
|
||||
* or reltablespace value, we will be called on both the old and new
|
||||
* tuples, and thus will broadcast invalidation messages showing both
|
||||
* the old and new RelFileNode values. This ensures that other
|
||||
* backends will close smgr references to the old file.
|
||||
* Note: during a pg_class row update that assigns a new
|
||||
* relfilenode or reltablespace value, we will be called on both
|
||||
* the old and new tuples, and thus will broadcast invalidation
|
||||
* messages showing both the old and new RelFileNode values. This
|
||||
* ensures that other backends will close smgr references to the
|
||||
* old file.
|
||||
*/
|
||||
}
|
||||
else if (tupleRelId == RelOid_pg_attribute)
|
||||
@ -544,13 +546,15 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
|
||||
Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple);
|
||||
|
||||
relationId = atttup->attrelid;
|
||||
|
||||
/*
|
||||
* KLUGE ALERT: we always send the relcache event with MyDatabaseId,
|
||||
* even if the rel in question is shared (which we can't easily tell).
|
||||
* This essentially means that only backends in this same database
|
||||
* will react to the relcache flush request. This is in fact
|
||||
* appropriate, since only those backends could see our pg_attribute
|
||||
* change anyway. It looks a bit ugly though.
|
||||
* KLUGE ALERT: we always send the relcache event with
|
||||
* MyDatabaseId, even if the rel in question is shared (which we
|
||||
* can't easily tell). This essentially means that only backends
|
||||
* in this same database will react to the relcache flush request.
|
||||
* This is in fact appropriate, since only those backends could
|
||||
* see our pg_attribute change anyway. It looks a bit ugly
|
||||
* though.
|
||||
*/
|
||||
databaseId = MyDatabaseId;
|
||||
/* We assume no smgr cache flush is needed, either */
|
||||
@ -659,7 +663,7 @@ AtEOXact_Inval(bool isCommit)
|
||||
RelationCacheInitFileInvalidate(true);
|
||||
|
||||
AppendInvalidationMessages(&transInvalInfo->PriorCmdInvalidMsgs,
|
||||
&transInvalInfo->CurrentCmdInvalidMsgs);
|
||||
&transInvalInfo->CurrentCmdInvalidMsgs);
|
||||
|
||||
ProcessInvalidationMessages(&transInvalInfo->PriorCmdInvalidMsgs,
|
||||
SendSharedInvalidMessage);
|
||||
@ -690,7 +694,7 @@ AtEOXact_Inval(bool isCommit)
|
||||
* We can forget about CurrentCmdInvalidMsgs too, since those changes haven't
|
||||
* touched the caches yet.
|
||||
*
|
||||
* In any case, pop the transaction stack. We need not physically free memory
|
||||
* In any case, pop the transaction stack. We need not physically free memory
|
||||
* here, since CurTransactionContext is about to be emptied anyway
|
||||
* (if aborting).
|
||||
*/
|
||||
@ -748,8 +752,8 @@ CommandEndInvalidationMessages(void)
|
||||
{
|
||||
/*
|
||||
* You might think this shouldn't be called outside any transaction,
|
||||
* but bootstrap does it, and also ABORT issued when not in a transaction.
|
||||
* So just quietly return if no state to work on.
|
||||
* but bootstrap does it, and also ABORT issued when not in a
|
||||
* transaction. So just quietly return if no state to work on.
|
||||
*/
|
||||
if (transInvalInfo == NULL)
|
||||
return;
|
||||
@ -808,7 +812,7 @@ CacheInvalidateRelcacheByTuple(HeapTuple classTuple)
|
||||
Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple);
|
||||
Oid databaseId;
|
||||
Oid relationId;
|
||||
RelFileNode rnode;
|
||||
RelFileNode rnode;
|
||||
|
||||
relationId = HeapTupleGetOid(classTuple);
|
||||
if (classtup->relisshared)
|
||||
|
4
src/backend/utils/cache/lsyscache.c
vendored
4
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.115 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.116 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -1409,7 +1409,7 @@ get_typdefault(Oid typid)
|
||||
/* Convert C string to a value of the given type */
|
||||
datum = OidFunctionCall3(type->typinput,
|
||||
CStringGetDatum(strDefaultVal),
|
||||
ObjectIdGetDatum(getTypeIOParam(typeTuple)),
|
||||
ObjectIdGetDatum(getTypeIOParam(typeTuple)),
|
||||
Int32GetDatum(-1));
|
||||
/* Build a Const node containing the value */
|
||||
expr = (Node *) makeConst(typid,
|
||||
|
108
src/backend/utils/cache/relcache.c
vendored
108
src/backend/utils/cache/relcache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.209 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.210 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -72,7 +72,7 @@
|
||||
*/
|
||||
#define RELCACHE_INIT_FILENAME "pg_internal.init"
|
||||
|
||||
#define RELCACHE_INIT_FILEMAGIC 0x573262 /* version ID value */
|
||||
#define RELCACHE_INIT_FILEMAGIC 0x573262 /* version ID value */
|
||||
|
||||
/*
|
||||
* hardcoded tuple descriptors. see include/catalog/pg_attribute.h
|
||||
@ -572,7 +572,7 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo,
|
||||
constr->num_check = relation->rd_rel->relchecks;
|
||||
constr->check = (ConstrCheck *)
|
||||
MemoryContextAllocZero(CacheMemoryContext,
|
||||
constr->num_check * sizeof(ConstrCheck));
|
||||
constr->num_check * sizeof(ConstrCheck));
|
||||
CheckConstraintFetch(relation);
|
||||
}
|
||||
else
|
||||
@ -1010,8 +1010,8 @@ RelationInitIndexAccessInfo(Relation relation)
|
||||
relation->rd_supportinfo = supportinfo;
|
||||
|
||||
/*
|
||||
* Fill the operator and support procedure OID arrays.
|
||||
* (supportinfo is left as zeroes, and is filled on-the-fly when used)
|
||||
* Fill the operator and support procedure OID arrays. (supportinfo is
|
||||
* left as zeroes, and is filled on-the-fly when used)
|
||||
*/
|
||||
IndexSupportInitialize(relation->rd_index,
|
||||
operator, support,
|
||||
@ -1201,8 +1201,8 @@ LookupOpclassInfo(Oid operatorClassOid,
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan pg_amproc to obtain support procs for the opclass. We only fetch
|
||||
* the default ones (those with subtype zero).
|
||||
* Scan pg_amproc to obtain support procs for the opclass. We only
|
||||
* fetch the default ones (those with subtype zero).
|
||||
*/
|
||||
if (numSupport > 0)
|
||||
{
|
||||
@ -1323,8 +1323,8 @@ formrdesc(const char *relationName,
|
||||
* because it will never be replaced. The input values must be
|
||||
* correctly defined by macros in src/include/catalog/ headers.
|
||||
*
|
||||
* Note however that rd_att's tdtypeid, tdtypmod, tdhasoid fields are
|
||||
* not right at this point. They will be fixed later when the real
|
||||
* Note however that rd_att's tdtypeid, tdtypmod, tdhasoid fields are not
|
||||
* right at this point. They will be fixed later when the real
|
||||
* pg_class row is loaded.
|
||||
*/
|
||||
relation->rd_att = CreateTemplateTupleDesc(natts, false);
|
||||
@ -1586,7 +1586,7 @@ RelationClose(Relation relation)
|
||||
/*
|
||||
* RelationReloadClassinfo - reload the pg_class row (only)
|
||||
*
|
||||
* This function is used only for nailed indexes. Since a REINDEX can
|
||||
* This function is used only for nailed indexes. Since a REINDEX can
|
||||
* change the relfilenode value for a nailed index, we have to reread
|
||||
* the pg_class row anytime we get an SI invalidation on a nailed index
|
||||
* (without throwing away the whole relcache entry, since we'd be unable
|
||||
@ -1612,6 +1612,7 @@ RelationReloadClassinfo(Relation relation)
|
||||
/* Read the pg_class row */
|
||||
buildinfo.infotype = INFO_RELID;
|
||||
buildinfo.i.info_id = relation->rd_id;
|
||||
|
||||
/*
|
||||
* Don't try to use an indexscan of pg_class_oid_index to reload the
|
||||
* info for pg_class_oid_index ...
|
||||
@ -1662,22 +1663,22 @@ RelationClearRelation(Relation relation, bool rebuild)
|
||||
/*
|
||||
* Never, never ever blow away a nailed-in system relation, because
|
||||
* we'd be unable to recover. However, we must reset rd_targblock, in
|
||||
* case we got called because of a relation cache flush that was triggered
|
||||
* by VACUUM.
|
||||
* case we got called because of a relation cache flush that was
|
||||
* triggered by VACUUM.
|
||||
*
|
||||
* If it's a nailed index, then we need to re-read the pg_class row to see
|
||||
* if its relfilenode changed. We can't necessarily do that here, because
|
||||
* we might be in a failed transaction. We assume it's okay to do it if
|
||||
* there are open references to the relcache entry (cf notes for
|
||||
* AtEOXact_RelationCache). Otherwise just mark the entry as possibly
|
||||
* invalid, and it'll be fixed when next opened.
|
||||
* If it's a nailed index, then we need to re-read the pg_class row to
|
||||
* see if its relfilenode changed. We can't necessarily do that here,
|
||||
* because we might be in a failed transaction. We assume it's okay
|
||||
* to do it if there are open references to the relcache entry (cf
|
||||
* notes for AtEOXact_RelationCache). Otherwise just mark the entry
|
||||
* as possibly invalid, and it'll be fixed when next opened.
|
||||
*/
|
||||
if (relation->rd_isnailed)
|
||||
{
|
||||
relation->rd_targblock = InvalidBlockNumber;
|
||||
if (relation->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
relation->rd_isvalid = false; /* needs to be revalidated */
|
||||
relation->rd_isvalid = false; /* needs to be revalidated */
|
||||
if (relation->rd_refcnt > 1)
|
||||
RelationReloadClassinfo(relation);
|
||||
}
|
||||
@ -1735,12 +1736,12 @@ RelationClearRelation(Relation relation, bool rebuild)
|
||||
{
|
||||
/*
|
||||
* When rebuilding an open relcache entry, must preserve ref count
|
||||
* and rd_createxact state. Also attempt to preserve the tupledesc
|
||||
* and rewrite-rule substructures in place.
|
||||
* and rd_createxact state. Also attempt to preserve the
|
||||
* tupledesc and rewrite-rule substructures in place.
|
||||
*
|
||||
* Note that this process does not touch CurrentResourceOwner;
|
||||
* which is good because whatever ref counts the entry may have
|
||||
* do not necessarily belong to that resource owner.
|
||||
* Note that this process does not touch CurrentResourceOwner; which
|
||||
* is good because whatever ref counts the entry may have do not
|
||||
* necessarily belong to that resource owner.
|
||||
*/
|
||||
int old_refcnt = relation->rd_refcnt;
|
||||
TransactionId old_createxact = relation->rd_createxact;
|
||||
@ -1856,8 +1857,8 @@ RelationForgetRelation(Oid rid)
|
||||
*
|
||||
* Ordinarily, if rnode is supplied then it will match the relfilenode of
|
||||
* the target relid. However, it's possible for rnode to be different if
|
||||
* someone is engaged in a relfilenode change. In that case we want to
|
||||
* make sure we clear the right cache entries. This has to be done here
|
||||
* someone is engaged in a relfilenode change. In that case we want to
|
||||
* make sure we clear the right cache entries. This has to be done here
|
||||
* to keep things in sync between relcache and smgr cache --- we can't have
|
||||
* someone flushing an smgr cache entry that a relcache entry still points
|
||||
* to.
|
||||
@ -1897,7 +1898,7 @@ RelationCacheInvalidateEntry(Oid relationId, RelFileNode *rnode)
|
||||
/*
|
||||
* RelationCacheInvalidate
|
||||
* Blow away cached relation descriptors that have zero reference counts,
|
||||
* and rebuild those with positive reference counts. Also reset the smgr
|
||||
* and rebuild those with positive reference counts. Also reset the smgr
|
||||
* relation cache.
|
||||
*
|
||||
* This is currently used only to recover from SI message buffer overflow,
|
||||
@ -2024,13 +2025,12 @@ AtEOXact_RelationCache(bool isCommit)
|
||||
/*
|
||||
* Is it a relation created in the current transaction?
|
||||
*
|
||||
* During commit, reset the flag to zero, since we are now out of
|
||||
* the creating transaction. During abort, simply delete the
|
||||
* relcache entry --- it isn't interesting any longer. (NOTE: if
|
||||
* we have forgotten the new-ness of a new relation due to a
|
||||
* forced cache flush, the entry will get deleted anyway by
|
||||
* shared-cache-inval processing of the aborted pg_class
|
||||
* insertion.)
|
||||
* During commit, reset the flag to zero, since we are now out of the
|
||||
* creating transaction. During abort, simply delete the relcache
|
||||
* entry --- it isn't interesting any longer. (NOTE: if we have
|
||||
* forgotten the new-ness of a new relation due to a forced cache
|
||||
* flush, the entry will get deleted anyway by shared-cache-inval
|
||||
* processing of the aborted pg_class insertion.)
|
||||
*/
|
||||
if (TransactionIdIsValid(relation->rd_createxact))
|
||||
{
|
||||
@ -2697,7 +2697,7 @@ RelationGetIndexList(Relation relation)
|
||||
static List *
|
||||
insert_ordered_oid(List *list, Oid datum)
|
||||
{
|
||||
ListCell *prev;
|
||||
ListCell *prev;
|
||||
|
||||
/* Does the datum belong at the front? */
|
||||
if (list == NIL || datum < linitial_oid(list))
|
||||
@ -2706,10 +2706,10 @@ insert_ordered_oid(List *list, Oid datum)
|
||||
prev = list_head(list);
|
||||
for (;;)
|
||||
{
|
||||
ListCell *curr = lnext(prev);
|
||||
ListCell *curr = lnext(prev);
|
||||
|
||||
if (curr == NULL || datum < lfirst_oid(curr))
|
||||
break; /* it belongs after 'prev', before 'curr' */
|
||||
break; /* it belongs after 'prev', before 'curr' */
|
||||
|
||||
prev = curr;
|
||||
}
|
||||
@ -2722,7 +2722,7 @@ insert_ordered_oid(List *list, Oid datum)
|
||||
* RelationSetIndexList -- externally force the index list contents
|
||||
*
|
||||
* This is used to temporarily override what we think the set of valid
|
||||
* indexes is. The forcing will be valid only until transaction commit
|
||||
* indexes is. The forcing will be valid only until transaction commit
|
||||
* or abort.
|
||||
*
|
||||
* This should only be applied to nailed relations, because in a non-nailed
|
||||
@ -2744,7 +2744,7 @@ RelationSetIndexList(Relation relation, List *indexIds)
|
||||
/* Okay to replace old list */
|
||||
list_free(relation->rd_indexlist);
|
||||
relation->rd_indexlist = indexIds;
|
||||
relation->rd_indexvalid = 2; /* mark list as forced */
|
||||
relation->rd_indexvalid = 2; /* mark list as forced */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2794,10 +2794,11 @@ RelationGetIndexExpressions(Relation relation)
|
||||
pfree(exprsString);
|
||||
|
||||
/*
|
||||
* Run the expressions through flatten_andors and eval_const_expressions.
|
||||
* This is not just an optimization, but is necessary, because the planner
|
||||
* will be comparing them to similarly-processed qual clauses, and may
|
||||
* fail to detect valid matches without this.
|
||||
* Run the expressions through flatten_andors and
|
||||
* eval_const_expressions. This is not just an optimization, but is
|
||||
* necessary, because the planner will be comparing them to
|
||||
* similarly-processed qual clauses, and may fail to detect valid
|
||||
* matches without this.
|
||||
*/
|
||||
result = (List *) flatten_andors((Node *) result);
|
||||
|
||||
@ -2868,10 +2869,11 @@ RelationGetIndexPredicate(Relation relation)
|
||||
pfree(predString);
|
||||
|
||||
/*
|
||||
* Run the expression through canonicalize_qual and eval_const_expressions.
|
||||
* This is not just an optimization, but is necessary, because the planner
|
||||
* will be comparing it to similarly-processed qual clauses, and may fail
|
||||
* to detect valid matches without this.
|
||||
* Run the expression through canonicalize_qual and
|
||||
* eval_const_expressions. This is not just an optimization, but is
|
||||
* necessary, because the planner will be comparing it to
|
||||
* similarly-processed qual clauses, and may fail to detect valid
|
||||
* matches without this.
|
||||
*/
|
||||
result = (List *) canonicalize_qual((Expr *) result);
|
||||
|
||||
@ -3035,7 +3037,7 @@ load_relcache_init_file(void)
|
||||
rel->rd_att = CreateTemplateTupleDesc(relform->relnatts,
|
||||
relform->relhasoids);
|
||||
rel->rd_att->tdtypeid = relform->reltype;
|
||||
rel->rd_att->tdtypmod = -1; /* unnecessary, but... */
|
||||
rel->rd_att->tdtypmod = -1; /* unnecessary, but... */
|
||||
|
||||
/* next read all the attribute tuple form data entries */
|
||||
has_not_null = false;
|
||||
@ -3174,8 +3176,8 @@ load_relcache_init_file(void)
|
||||
|
||||
/*
|
||||
* Recompute lock and physical addressing info. This is needed in
|
||||
* case the pg_internal.init file was copied from some other database
|
||||
* by CREATE DATABASE.
|
||||
* case the pg_internal.init file was copied from some other
|
||||
* database by CREATE DATABASE.
|
||||
*/
|
||||
RelationInitLockInfo(rel);
|
||||
RelationInitPhysicalAddr(rel);
|
||||
@ -3200,7 +3202,7 @@ load_relcache_init_file(void)
|
||||
RelationCacheInsert(rels[relno]);
|
||||
/* also make a list of their OIDs, for RelationIdIsInInitFile */
|
||||
initFileRelationIds = lcons_oid(RelationGetRelid(rels[relno]),
|
||||
initFileRelationIds);
|
||||
initFileRelationIds);
|
||||
}
|
||||
|
||||
pfree(rels);
|
||||
@ -3266,7 +3268,7 @@ write_relcache_init_file(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a magic number to serve as a file version identifier. We can
|
||||
* Write a magic number to serve as a file version identifier. We can
|
||||
* change the magic number whenever the relcache layout changes.
|
||||
*/
|
||||
magic = RELCACHE_INIT_FILEMAGIC;
|
||||
@ -3359,7 +3361,7 @@ write_relcache_init_file(void)
|
||||
/* also make a list of their OIDs, for RelationIdIsInInitFile */
|
||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||
initFileRelationIds = lcons_oid(RelationGetRelid(rel),
|
||||
initFileRelationIds);
|
||||
initFileRelationIds);
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
|
||||
|
5
src/backend/utils/cache/syscache.c
vendored
5
src/backend/utils/cache/syscache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.94 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.95 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -436,7 +436,8 @@ static const struct cachedesc cacheinfo[] = {
|
||||
}}
|
||||
};
|
||||
|
||||
static CatCache *SysCache[lengthof(cacheinfo)];
|
||||
static CatCache *SysCache[
|
||||
lengthof(cacheinfo)];
|
||||
static int SysCacheSize = lengthof(cacheinfo);
|
||||
static bool CacheInitialized = false;
|
||||
|
||||
|
34
src/backend/utils/cache/typcache.c
vendored
34
src/backend/utils/cache/typcache.c
vendored
@ -36,7 +36,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.9 2004/08/29 04:12:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.10 2004/08/29 05:06:50 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -71,7 +71,7 @@ static HTAB *TypeCacheHash = NULL;
|
||||
*
|
||||
* Stored record types are remembered in a linear array of TupleDescs,
|
||||
* which can be indexed quickly with the assigned typmod. There is also
|
||||
* a hash table to speed searches for matching TupleDescs. The hash key
|
||||
* a hash table to speed searches for matching TupleDescs. The hash key
|
||||
* uses just the first N columns' type OIDs, and so we may have multiple
|
||||
* entries with the same hash key.
|
||||
*/
|
||||
@ -80,7 +80,7 @@ static HTAB *TypeCacheHash = NULL;
|
||||
typedef struct RecordCacheEntry
|
||||
{
|
||||
/* the hash lookup key MUST BE FIRST */
|
||||
Oid hashkey[REC_HASH_KEYS]; /* column type IDs, zero-filled */
|
||||
Oid hashkey[REC_HASH_KEYS]; /* column type IDs, zero-filled */
|
||||
|
||||
/* list of TupleDescs for record types with this hashkey */
|
||||
List *tupdescs;
|
||||
@ -93,7 +93,7 @@ static int32 RecordCacheArrayLen = 0; /* allocated length of array */
|
||||
static int32 NextRecordTypmod = 0; /* number of entries used */
|
||||
|
||||
|
||||
static Oid lookup_default_opclass(Oid type_id, Oid am_id);
|
||||
static Oid lookup_default_opclass(Oid type_id, Oid am_id);
|
||||
|
||||
|
||||
/*
|
||||
@ -194,9 +194,9 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If we find a btree opclass where previously we only found
|
||||
* a hash opclass, forget the hash equality operator so we
|
||||
* can use the btree operator instead.
|
||||
* If we find a btree opclass where previously we only found a
|
||||
* hash opclass, forget the hash equality operator so we can
|
||||
* use the btree operator instead.
|
||||
*/
|
||||
typentry->eq_opr = InvalidOid;
|
||||
typentry->eq_opr_finfo.fn_oid = InvalidOid;
|
||||
@ -229,7 +229,7 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
if (typentry->btree_opc != InvalidOid)
|
||||
typentry->gt_opr = get_opclass_member(typentry->btree_opc,
|
||||
InvalidOid,
|
||||
BTGreaterStrategyNumber);
|
||||
BTGreaterStrategyNumber);
|
||||
}
|
||||
if ((flags & (TYPECACHE_CMP_PROC | TYPECACHE_CMP_PROC_FINFO)) &&
|
||||
typentry->cmp_proc == InvalidOid)
|
||||
@ -244,14 +244,14 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
* Set up fmgr lookup info as requested
|
||||
*
|
||||
* Note: we tell fmgr the finfo structures live in CacheMemoryContext,
|
||||
* which is not quite right (they're really in DynaHashContext) but this
|
||||
* will do for our purposes.
|
||||
* which is not quite right (they're really in DynaHashContext) but
|
||||
* this will do for our purposes.
|
||||
*/
|
||||
if ((flags & TYPECACHE_EQ_OPR_FINFO) &&
|
||||
typentry->eq_opr_finfo.fn_oid == InvalidOid &&
|
||||
typentry->eq_opr != InvalidOid)
|
||||
{
|
||||
Oid eq_opr_func;
|
||||
Oid eq_opr_func;
|
||||
|
||||
eq_opr_func = get_opcode(typentry->eq_opr);
|
||||
if (eq_opr_func != InvalidOid)
|
||||
@ -275,11 +275,12 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
{
|
||||
Relation rel;
|
||||
|
||||
if (!OidIsValid(typentry->typrelid)) /* should not happen */
|
||||
if (!OidIsValid(typentry->typrelid)) /* should not happen */
|
||||
elog(ERROR, "invalid typrelid for composite type %u",
|
||||
typentry->type_id);
|
||||
rel = relation_open(typentry->typrelid, AccessShareLock);
|
||||
Assert(rel->rd_rel->reltype == typentry->type_id);
|
||||
|
||||
/*
|
||||
* Notice that we simply store a link to the relcache's tupdesc.
|
||||
* Since we are relying on relcache to detect cache flush events,
|
||||
@ -297,7 +298,7 @@ lookup_type_cache(Oid type_id, int flags)
|
||||
* lookup_default_opclass
|
||||
*
|
||||
* Given the OIDs of a datatype and an access method, find the default
|
||||
* operator class, if any. Returns InvalidOid if there is none.
|
||||
* operator class, if any. Returns InvalidOid if there is none.
|
||||
*/
|
||||
static Oid
|
||||
lookup_default_opclass(Oid type_id, Oid am_id)
|
||||
@ -324,7 +325,8 @@ lookup_default_opclass(Oid type_id, Oid am_id)
|
||||
* than one exact match, then someone put bogus entries in pg_opclass.
|
||||
*
|
||||
* This is the same logic as GetDefaultOpClass() in indexcmds.c, except
|
||||
* that we consider all opclasses, regardless of the current search path.
|
||||
* that we consider all opclasses, regardless of the current search
|
||||
* path.
|
||||
*/
|
||||
rel = heap_openr(OperatorClassRelationName, AccessShareLock);
|
||||
|
||||
@ -510,10 +512,10 @@ assign_record_type_typmod(TupleDesc tupDesc)
|
||||
}
|
||||
else if (NextRecordTypmod >= RecordCacheArrayLen)
|
||||
{
|
||||
int32 newlen = RecordCacheArrayLen * 2;
|
||||
int32 newlen = RecordCacheArrayLen * 2;
|
||||
|
||||
RecordCacheArray = (TupleDesc *) repalloc(RecordCacheArray,
|
||||
newlen * sizeof(TupleDesc));
|
||||
newlen * sizeof(TupleDesc));
|
||||
RecordCacheArrayLen = newlen;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user