mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
pgindent run for release 9.3
This is the first run of the Perl-based pgindent script. Also update pgindent instructions.
This commit is contained in:
16
src/backend/utils/cache/catcache.c
vendored
16
src/backend/utils/cache/catcache.c
vendored
@ -291,7 +291,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
|
||||
static void
|
||||
CatCachePrintStats(int code, Datum arg)
|
||||
{
|
||||
slist_iter iter;
|
||||
slist_iter iter;
|
||||
long cc_searches = 0;
|
||||
long cc_hits = 0;
|
||||
long cc_neg_hits = 0;
|
||||
@ -444,7 +444,7 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl)
|
||||
void
|
||||
CatalogCacheIdInvalidate(int cacheId, uint32 hashValue)
|
||||
{
|
||||
slist_iter cache_iter;
|
||||
slist_iter cache_iter;
|
||||
|
||||
CACHE1_elog(DEBUG2, "CatalogCacheIdInvalidate: called");
|
||||
|
||||
@ -554,12 +554,12 @@ AtEOXact_CatCache(bool isCommit)
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
if (assert_enabled)
|
||||
{
|
||||
slist_iter cache_iter;
|
||||
slist_iter cache_iter;
|
||||
|
||||
slist_foreach(cache_iter, &CacheHdr->ch_caches)
|
||||
{
|
||||
CatCache *ccp = slist_container(CatCache, cc_next, cache_iter.cur);
|
||||
dlist_iter iter;
|
||||
dlist_iter iter;
|
||||
int i;
|
||||
|
||||
/* Check CatCLists */
|
||||
@ -649,7 +649,7 @@ ResetCatalogCache(CatCache *cache)
|
||||
void
|
||||
ResetCatalogCaches(void)
|
||||
{
|
||||
slist_iter iter;
|
||||
slist_iter iter;
|
||||
|
||||
CACHE1_elog(DEBUG2, "ResetCatalogCaches called");
|
||||
|
||||
@ -679,7 +679,7 @@ ResetCatalogCaches(void)
|
||||
void
|
||||
CatalogCacheFlushCatalog(Oid catId)
|
||||
{
|
||||
slist_iter iter;
|
||||
slist_iter iter;
|
||||
|
||||
CACHE2_elog(DEBUG2, "CatalogCacheFlushCatalog called for %u", catId);
|
||||
|
||||
@ -1343,7 +1343,7 @@ SearchCatCacheList(CatCache *cache,
|
||||
{
|
||||
ScanKeyData cur_skey[CATCACHE_MAXKEYS];
|
||||
uint32 lHashValue;
|
||||
dlist_iter iter;
|
||||
dlist_iter iter;
|
||||
CatCList *cl;
|
||||
CatCTup *ct;
|
||||
List *volatile ctlist;
|
||||
@ -1789,7 +1789,7 @@ PrepareToInvalidateCacheTuple(Relation relation,
|
||||
HeapTuple newtuple,
|
||||
void (*function) (int, uint32, Oid))
|
||||
{
|
||||
slist_iter iter;
|
||||
slist_iter iter;
|
||||
Oid reloid;
|
||||
|
||||
CACHE1_elog(DEBUG2, "PrepareToInvalidateCacheTuple: called");
|
||||
|
42
src/backend/utils/cache/evtcache.c
vendored
42
src/backend/utils/cache/evtcache.c
vendored
@ -40,7 +40,7 @@ typedef enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
EventTriggerEvent event;
|
||||
EventTriggerEvent event;
|
||||
List *triggerlist;
|
||||
} EventTriggerCacheEntry;
|
||||
|
||||
@ -51,7 +51,7 @@ static EventTriggerCacheStateType EventTriggerCacheState = ETCS_NEEDS_REBUILD;
|
||||
static void BuildEventTriggerCache(void);
|
||||
static void InvalidateEventCacheCallback(Datum arg,
|
||||
int cacheid, uint32 hashvalue);
|
||||
static int DecodeTextArrayToCString(Datum array, char ***cstringp);
|
||||
static int DecodeTextArrayToCString(Datum array, char ***cstringp);
|
||||
|
||||
/*
|
||||
* Search the event cache by trigger event.
|
||||
@ -77,12 +77,12 @@ EventCacheLookup(EventTriggerEvent event)
|
||||
static void
|
||||
BuildEventTriggerCache(void)
|
||||
{
|
||||
HASHCTL ctl;
|
||||
HTAB *cache;
|
||||
MemoryContext oldcontext;
|
||||
Relation rel;
|
||||
Relation irel;
|
||||
SysScanDesc scan;
|
||||
HASHCTL ctl;
|
||||
HTAB *cache;
|
||||
MemoryContext oldcontext;
|
||||
Relation rel;
|
||||
Relation irel;
|
||||
SysScanDesc scan;
|
||||
|
||||
if (EventTriggerCacheContext != NULL)
|
||||
{
|
||||
@ -96,8 +96,8 @@ BuildEventTriggerCache(void)
|
||||
else
|
||||
{
|
||||
/*
|
||||
* This is our first time attempting to build the cache, so we need
|
||||
* to set up the memory context and register a syscache callback to
|
||||
* This is our first time attempting to build the cache, so we need to
|
||||
* set up the memory context and register a syscache callback to
|
||||
* capture future invalidation events.
|
||||
*/
|
||||
if (CacheMemoryContext == NULL)
|
||||
@ -129,24 +129,24 @@ BuildEventTriggerCache(void)
|
||||
HASH_ELEM | HASH_FUNCTION | HASH_CONTEXT);
|
||||
|
||||
/*
|
||||
* Prepare to scan pg_event_trigger in name order. We use an MVCC
|
||||
* snapshot to avoid getting inconsistent results if the table is
|
||||
* being concurrently updated.
|
||||
* Prepare to scan pg_event_trigger in name order. We use an MVCC
|
||||
* snapshot to avoid getting inconsistent results if the table is being
|
||||
* concurrently updated.
|
||||
*/
|
||||
rel = relation_open(EventTriggerRelationId, AccessShareLock);
|
||||
irel = index_open(EventTriggerNameIndexId, AccessShareLock);
|
||||
scan = systable_beginscan_ordered(rel, irel, GetLatestSnapshot(), 0, NULL);
|
||||
|
||||
/*
|
||||
* Build a cache item for each pg_event_trigger tuple, and append each
|
||||
* one to the appropriate cache entry.
|
||||
* Build a cache item for each pg_event_trigger tuple, and append each one
|
||||
* to the appropriate cache entry.
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
HeapTuple tup;
|
||||
Form_pg_event_trigger form;
|
||||
HeapTuple tup;
|
||||
Form_pg_event_trigger form;
|
||||
char *evtevent;
|
||||
EventTriggerEvent event;
|
||||
EventTriggerEvent event;
|
||||
EventTriggerCacheItem *item;
|
||||
Datum evttags;
|
||||
bool evttags_isnull;
|
||||
@ -257,9 +257,9 @@ static void
|
||||
InvalidateEventCacheCallback(Datum arg, int cacheid, uint32 hashvalue)
|
||||
{
|
||||
/*
|
||||
* If the cache isn't valid, then there might be a rebuild in progress,
|
||||
* so we can't immediately blow it away. But it's advantageous to do
|
||||
* this when possible, so as to immediately free memory.
|
||||
* If the cache isn't valid, then there might be a rebuild in progress, so
|
||||
* we can't immediately blow it away. But it's advantageous to do this
|
||||
* when possible, so as to immediately free memory.
|
||||
*/
|
||||
if (EventTriggerCacheState == ETCS_VALID)
|
||||
{
|
||||
|
14
src/backend/utils/cache/plancache.c
vendored
14
src/backend/utils/cache/plancache.c
vendored
@ -216,7 +216,7 @@ CreateCachedPlan(Node *raw_parse_tree,
|
||||
* in that context.
|
||||
*
|
||||
* A one-shot plan cannot be saved or copied, since we make no effort to
|
||||
* preserve the raw parse tree unmodified. There is also no support for
|
||||
* preserve the raw parse tree unmodified. There is also no support for
|
||||
* invalidation, so plan use must be completed in the current transaction,
|
||||
* and DDL that might invalidate the querytree_list must be avoided as well.
|
||||
*
|
||||
@ -373,9 +373,9 @@ CompleteCachedPlan(CachedPlanSource *plansource,
|
||||
&plansource->invalItems);
|
||||
|
||||
/*
|
||||
* Also save the current search_path in the query_context. (This
|
||||
* Also save the current search_path in the query_context. (This
|
||||
* should not generate much extra cruft either, since almost certainly
|
||||
* the path is already valid.) Again, we don't really need this for
|
||||
* the path is already valid.) Again, we don't really need this for
|
||||
* one-shot plans; and we *must* skip this for transaction control
|
||||
* commands, because this could result in catalog accesses.
|
||||
*/
|
||||
@ -554,9 +554,9 @@ RevalidateCachedQuery(CachedPlanSource *plansource)
|
||||
/*
|
||||
* For one-shot plans, we do not support revalidation checking; it's
|
||||
* assumed the query is parsed, planned, and executed in one transaction,
|
||||
* so that no lock re-acquisition is necessary. Also, there is never
|
||||
* any need to revalidate plans for transaction control commands (and
|
||||
* we mustn't risk any catalog accesses when handling those).
|
||||
* so that no lock re-acquisition is necessary. Also, there is never any
|
||||
* need to revalidate plans for transaction control commands (and we
|
||||
* mustn't risk any catalog accesses when handling those).
|
||||
*/
|
||||
if (plansource->is_oneshot || IsTransactionStmtPlan(plansource))
|
||||
{
|
||||
@ -725,7 +725,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource)
|
||||
&plansource->invalItems);
|
||||
|
||||
/*
|
||||
* Also save the current search_path in the query_context. (This should
|
||||
* Also save the current search_path in the query_context. (This should
|
||||
* not generate much extra cruft either, since almost certainly the path
|
||||
* is already valid.)
|
||||
*/
|
||||
|
193
src/backend/utils/cache/relcache.c
vendored
193
src/backend/utils/cache/relcache.c
vendored
@ -2313,7 +2313,7 @@ AtEOXact_RelationCache(bool isCommit)
|
||||
* For simplicity, eoxact_list[] entries are not deleted till end of
|
||||
* top-level transaction, even though we could remove them at
|
||||
* subtransaction end in some cases, or remove relations from the list if
|
||||
* they are cleared for other reasons. Therefore we should expect the
|
||||
* they are cleared for other reasons. Therefore we should expect the
|
||||
* case that list entries are not found in the hashtable; if not, there's
|
||||
* nothing to do for them.
|
||||
*/
|
||||
@ -2354,66 +2354,66 @@ AtEOXact_RelationCache(bool isCommit)
|
||||
static void
|
||||
AtEOXact_cleanup(Relation relation, bool isCommit)
|
||||
{
|
||||
/*
|
||||
* The relcache entry's ref count should be back to its normal
|
||||
* not-in-a-transaction state: 0 unless it's nailed in cache.
|
||||
*
|
||||
* In bootstrap mode, this is NOT true, so don't check it --- the
|
||||
* bootstrap code expects relations to stay open across start/commit
|
||||
* transaction calls. (That seems bogus, but it's not worth fixing.)
|
||||
*
|
||||
* Note: ideally this check would be applied to every relcache entry,
|
||||
* not just those that have eoxact work to do. But it's not worth
|
||||
* forcing a scan of the whole relcache just for this. (Moreover,
|
||||
* doing so would mean that assert-enabled testing never tests the
|
||||
* hash_search code path above, which seems a bad idea.)
|
||||
*/
|
||||
/*
|
||||
* The relcache entry's ref count should be back to its normal
|
||||
* not-in-a-transaction state: 0 unless it's nailed in cache.
|
||||
*
|
||||
* In bootstrap mode, this is NOT true, so don't check it --- the
|
||||
* bootstrap code expects relations to stay open across start/commit
|
||||
* transaction calls. (That seems bogus, but it's not worth fixing.)
|
||||
*
|
||||
* Note: ideally this check would be applied to every relcache entry, not
|
||||
* just those that have eoxact work to do. But it's not worth forcing a
|
||||
* scan of the whole relcache just for this. (Moreover, doing so would
|
||||
* mean that assert-enabled testing never tests the hash_search code path
|
||||
* above, which seems a bad idea.)
|
||||
*/
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
if (!IsBootstrapProcessingMode())
|
||||
{
|
||||
int expected_refcnt;
|
||||
if (!IsBootstrapProcessingMode())
|
||||
{
|
||||
int expected_refcnt;
|
||||
|
||||
expected_refcnt = relation->rd_isnailed ? 1 : 0;
|
||||
Assert(relation->rd_refcnt == expected_refcnt);
|
||||
}
|
||||
expected_refcnt = relation->rd_isnailed ? 1 : 0;
|
||||
Assert(relation->rd_refcnt == expected_refcnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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.)
|
||||
*/
|
||||
if (relation->rd_createSubid != InvalidSubTransactionId)
|
||||
/*
|
||||
* 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.)
|
||||
*/
|
||||
if (relation->rd_createSubid != InvalidSubTransactionId)
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_createSubid = InvalidSubTransactionId;
|
||||
else
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_createSubid = InvalidSubTransactionId;
|
||||
else
|
||||
{
|
||||
RelationClearRelation(relation, false);
|
||||
return;
|
||||
}
|
||||
RelationClearRelation(relation, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Likewise, reset the hint about the relfilenode being new.
|
||||
*/
|
||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
||||
/*
|
||||
* Likewise, reset the hint about the relfilenode being new.
|
||||
*/
|
||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
||||
|
||||
/*
|
||||
* Flush any temporary index list.
|
||||
*/
|
||||
if (relation->rd_indexvalid == 2)
|
||||
{
|
||||
list_free(relation->rd_indexlist);
|
||||
relation->rd_indexlist = NIL;
|
||||
relation->rd_oidindex = InvalidOid;
|
||||
relation->rd_indexvalid = 0;
|
||||
}
|
||||
/*
|
||||
* Flush any temporary index list.
|
||||
*/
|
||||
if (relation->rd_indexvalid == 2)
|
||||
{
|
||||
list_free(relation->rd_indexlist);
|
||||
relation->rd_indexlist = NIL;
|
||||
relation->rd_oidindex = InvalidOid;
|
||||
relation->rd_indexvalid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2474,45 +2474,44 @@ static void
|
||||
AtEOSubXact_cleanup(Relation relation, bool isCommit,
|
||||
SubTransactionId mySubid, SubTransactionId parentSubid)
|
||||
{
|
||||
/*
|
||||
* Is it a relation created in the current subtransaction?
|
||||
*
|
||||
* During subcommit, mark it as belonging to the parent, instead.
|
||||
* During subabort, simply delete the relcache entry.
|
||||
*/
|
||||
if (relation->rd_createSubid == mySubid)
|
||||
/*
|
||||
* Is it a relation created in the current subtransaction?
|
||||
*
|
||||
* During subcommit, mark it as belonging to the parent, instead. During
|
||||
* subabort, simply delete the relcache entry.
|
||||
*/
|
||||
if (relation->rd_createSubid == mySubid)
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_createSubid = parentSubid;
|
||||
else
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_createSubid = parentSubid;
|
||||
else
|
||||
{
|
||||
RelationClearRelation(relation, false);
|
||||
return;
|
||||
}
|
||||
RelationClearRelation(relation, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Likewise, update or drop any new-relfilenode-in-subtransaction
|
||||
* hint.
|
||||
*/
|
||||
if (relation->rd_newRelfilenodeSubid == mySubid)
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_newRelfilenodeSubid = parentSubid;
|
||||
else
|
||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
||||
}
|
||||
/*
|
||||
* Likewise, update or drop any new-relfilenode-in-subtransaction hint.
|
||||
*/
|
||||
if (relation->rd_newRelfilenodeSubid == mySubid)
|
||||
{
|
||||
if (isCommit)
|
||||
relation->rd_newRelfilenodeSubid = parentSubid;
|
||||
else
|
||||
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush any temporary index list.
|
||||
*/
|
||||
if (relation->rd_indexvalid == 2)
|
||||
{
|
||||
list_free(relation->rd_indexlist);
|
||||
relation->rd_indexlist = NIL;
|
||||
relation->rd_oidindex = InvalidOid;
|
||||
relation->rd_indexvalid = 0;
|
||||
}
|
||||
/*
|
||||
* Flush any temporary index list.
|
||||
*/
|
||||
if (relation->rd_indexvalid == 2)
|
||||
{
|
||||
list_free(relation->rd_indexlist);
|
||||
relation->rd_indexlist = NIL;
|
||||
relation->rd_oidindex = InvalidOid;
|
||||
relation->rd_indexvalid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2699,8 +2698,8 @@ RelationBuildLocalRelation(const char *relname,
|
||||
RelationCacheInsert(rel);
|
||||
|
||||
/*
|
||||
* Flag relation as needing eoxact cleanup (to clear rd_createSubid).
|
||||
* We can't do this before storing relid in it.
|
||||
* Flag relation as needing eoxact cleanup (to clear rd_createSubid). We
|
||||
* can't do this before storing relid in it.
|
||||
*/
|
||||
EOXactListAdd(rel);
|
||||
|
||||
@ -3847,8 +3846,8 @@ RelationGetIndexAttrBitmap(Relation relation, bool keyAttrs)
|
||||
|
||||
/* Can this index be referenced by a foreign key? */
|
||||
isKey = indexInfo->ii_Unique &&
|
||||
indexInfo->ii_Expressions == NIL &&
|
||||
indexInfo->ii_Predicate == NIL;
|
||||
indexInfo->ii_Expressions == NIL &&
|
||||
indexInfo->ii_Predicate == NIL;
|
||||
|
||||
/* Collect simple attribute references */
|
||||
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
|
||||
@ -3861,7 +3860,7 @@ RelationGetIndexAttrBitmap(Relation relation, bool keyAttrs)
|
||||
attrnum - FirstLowInvalidHeapAttributeNumber);
|
||||
if (isKey)
|
||||
uindexattrs = bms_add_member(uindexattrs,
|
||||
attrnum - FirstLowInvalidHeapAttributeNumber);
|
||||
attrnum - FirstLowInvalidHeapAttributeNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4030,7 +4029,7 @@ errtable(Relation rel)
|
||||
get_namespace_name(RelationGetNamespace(rel)));
|
||||
err_generic_string(PG_DIAG_TABLE_NAME, RelationGetRelationName(rel));
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4061,7 +4060,7 @@ errtablecol(Relation rel, int attnum)
|
||||
* given directly rather than extracted from the relation's catalog data.
|
||||
*
|
||||
* Don't use this directly unless errtablecol() is inconvenient for some
|
||||
* reason. This might possibly be needed during intermediate states in ALTER
|
||||
* reason. This might possibly be needed during intermediate states in ALTER
|
||||
* TABLE, for instance.
|
||||
*/
|
||||
int
|
||||
@ -4070,7 +4069,7 @@ errtablecolname(Relation rel, const char *colname)
|
||||
errtable(rel);
|
||||
err_generic_string(PG_DIAG_COLUMN_NAME, colname);
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4083,7 +4082,7 @@ errtableconstraint(Relation rel, const char *conname)
|
||||
errtable(rel);
|
||||
err_generic_string(PG_DIAG_CONSTRAINT_NAME, conname);
|
||||
|
||||
return 0; /* return value does not matter */
|
||||
return 0; /* return value does not matter */
|
||||
}
|
||||
|
||||
|
||||
|
4
src/backend/utils/cache/syscache.c
vendored
4
src/backend/utils/cache/syscache.c
vendored
@ -382,7 +382,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
},
|
||||
256
|
||||
},
|
||||
{EventTriggerRelationId, /* EVENTTRIGGERNAME */
|
||||
{EventTriggerRelationId, /* EVENTTRIGGERNAME */
|
||||
EventTriggerNameIndexId,
|
||||
1,
|
||||
{
|
||||
@ -393,7 +393,7 @@ static const struct cachedesc cacheinfo[] = {
|
||||
},
|
||||
8
|
||||
},
|
||||
{EventTriggerRelationId, /* EVENTTRIGGEROID */
|
||||
{EventTriggerRelationId, /* EVENTTRIGGEROID */
|
||||
EventTriggerOidIndexId,
|
||||
1,
|
||||
{
|
||||
|
Reference in New Issue
Block a user