1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

pgindent run for 9.0

This commit is contained in:
Bruce Momjian
2010-02-26 02:01:40 +00:00
parent 16040575a0
commit 65e806cba1
403 changed files with 6786 additions and 6530 deletions

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/attoptcache.c,v 1.2 2010/02/14 18:42:17 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/attoptcache.c,v 1.3 2010/02/26 02:01:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -48,7 +48,7 @@ typedef struct
* Flush all cache entries when pg_attribute is updated.
*
* When pg_attribute is updated, we must flush the cache entry at least
* for that attribute. Currently, we just flush them all. Since attribute
* for that attribute. Currently, we just flush them all. Since attribute
* options are not currently used in performance-critical paths (such as
* query execution), this seems OK.
*/
@ -78,7 +78,7 @@ InvalidateAttoptCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr)
static void
InitializeAttoptCache(void)
{
HASHCTL ctl;
HASHCTL ctl;
/* Initialize the hash table. */
MemSet(&ctl, 0, sizeof(ctl));
@ -87,7 +87,7 @@ InitializeAttoptCache(void)
ctl.hash = tag_hash;
AttoptCacheHash =
hash_create("Attopt cache", 256, &ctl,
HASH_ELEM | HASH_FUNCTION);
HASH_ELEM | HASH_FUNCTION);
/* Make sure we've initialized CacheMemoryContext. */
if (!CacheMemoryContext)
@ -108,18 +108,19 @@ get_attribute_options(Oid attrelid, int attnum)
{
AttoptCacheKey key;
AttoptCacheEntry *attopt;
AttributeOpts *result;
AttributeOpts *result;
HeapTuple tp;
/* Find existing cache entry, if any. */
if (!AttoptCacheHash)
InitializeAttoptCache();
memset(&key, 0, sizeof(key)); /* make sure any padding bits are unset */
memset(&key, 0, sizeof(key)); /* make sure any padding bits are
* unset */
key.attrelid = attrelid;
key.attnum = attnum;
attopt =
(AttoptCacheEntry *) hash_search(AttoptCacheHash,
(void *) &key,
(void *) &key,
HASH_FIND,
NULL);
@ -141,8 +142,8 @@ get_attribute_options(Oid attrelid, int attnum)
opts = NULL;
else
{
Datum datum;
bool isNull;
Datum datum;
bool isNull;
datum = SysCacheGetAttr(ATTNUM,
tp,
@ -152,7 +153,8 @@ get_attribute_options(Oid attrelid, int attnum)
opts = NULL;
else
{
bytea *bytea_opts = attribute_reloptions(datum, false);
bytea *bytea_opts = attribute_reloptions(datum, false);
opts = MemoryContextAlloc(CacheMemoryContext,
VARSIZE(bytea_opts));
memcpy(opts, bytea_opts, VARSIZE(bytea_opts));
@ -161,13 +163,13 @@ get_attribute_options(Oid attrelid, int attnum)
}
/*
* It's important to create the actual cache entry only after
* reading pg_attribute, since the read could cause a cache flush.
* It's important to create the actual cache entry only after reading
* pg_attribute, since the read could cause a cache flush.
*/
attopt = (AttoptCacheEntry *) hash_search(AttoptCacheHash,
(void *) &key,
HASH_ENTER,
NULL);
(void *) &key,
HASH_ENTER,
NULL);
attopt->opts = opts;
}

View File

@ -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.97 2010/02/14 18:42:17 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.98 2010/02/26 02:01:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -158,8 +158,8 @@ typedef struct TransInvalidationInfo
static TransInvalidationInfo *transInvalInfo = NULL;
static SharedInvalidationMessage *SharedInvalidMessagesArray;
static int numSharedInvalidMessagesArray;
static int maxSharedInvalidMessagesArray;
static int numSharedInvalidMessagesArray;
static int maxSharedInvalidMessagesArray;
/*
@ -775,7 +775,7 @@ MakeSharedInvalidMessagesArray(const SharedInvalidationMessage *msgs, int n)
* We're so close to EOXact that we now we're going to lose it anyhow.
*/
SharedInvalidMessagesArray = palloc(maxSharedInvalidMessagesArray
* sizeof(SharedInvalidationMessage));
* sizeof(SharedInvalidationMessage));
}
if ((numSharedInvalidMessagesArray + n) > maxSharedInvalidMessagesArray)
@ -784,15 +784,15 @@ MakeSharedInvalidMessagesArray(const SharedInvalidationMessage *msgs, int n)
maxSharedInvalidMessagesArray *= 2;
SharedInvalidMessagesArray = repalloc(SharedInvalidMessagesArray,
maxSharedInvalidMessagesArray
* sizeof(SharedInvalidationMessage));
maxSharedInvalidMessagesArray
* sizeof(SharedInvalidationMessage));
}
/*
* Append the next chunk onto the array
*/
memcpy(SharedInvalidMessagesArray + numSharedInvalidMessagesArray,
msgs, n * sizeof(SharedInvalidationMessage));
msgs, n * sizeof(SharedInvalidationMessage));
numSharedInvalidMessagesArray += n;
}
@ -820,18 +820,18 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
/*
* Relcache init file invalidation requires processing both before and
* after we send the SI messages. However, we need not do anything
* unless we committed.
* after we send the SI messages. However, we need not do anything unless
* we committed.
*/
*RelcacheInitFileInval = transInvalInfo->RelcacheInitFileInval;
/*
* Walk through TransInvalidationInfo to collect all the messages
* into a single contiguous array of invalidation messages. It must
* be contiguous so we can copy directly into WAL message. Maintain the
* order that they would be processed in by AtEOXact_Inval(), to ensure
* emulated behaviour in redo is as similar as possible to original.
* We want the same bugs, if any, not new ones.
* Walk through TransInvalidationInfo to collect all the messages into a
* single contiguous array of invalidation messages. It must be contiguous
* so we can copy directly into WAL message. Maintain the order that they
* would be processed in by AtEOXact_Inval(), to ensure emulated behaviour
* in redo is as similar as possible to original. We want the same bugs,
* if any, not new ones.
*/
oldcontext = MemoryContextSwitchTo(CurTransactionContext);
@ -877,7 +877,7 @@ ProcessCommittedInvalidationMessages(SharedInvalidationMessage *msgs,
return;
elog(trace_recovery(DEBUG4), "replaying commit with %d messages%s", nmsgs,
(RelcacheInitFileInval ? " and relcache file invalidation" : ""));
(RelcacheInitFileInval ? " and relcache file invalidation" : ""));
if (RelcacheInitFileInval)
RecoveryRelationCacheInitFileInvalidate(dbid, tsid, true);
@ -1149,7 +1149,7 @@ CacheInvalidateRelcacheByRelid(Oid relid)
*
* Sending this type of invalidation msg forces other backends to close open
* smgr entries for the rel. This should be done to flush dangling open-file
* references when the physical rel is being dropped or truncated. Because
* references when the physical rel is being dropped or truncated. Because
* these are nontransactional (i.e., not-rollback-able) operations, we just
* send the inval message immediately without any queuing.
*

View File

@ -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.167 2010/02/14 18:42:17 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.168 2010/02/26 02:01:11 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@ -622,7 +622,7 @@ get_op_btree_interpretation(Oid opno, List **opfamilies, List **opstrats)
{
op_negated = true;
ReleaseSysCacheList(catlist);
catlist = SearchSysCacheList1(AMOPOPID,
catlist = SearchSysCacheList1(AMOPOPID,
ObjectIdGetDatum(op_negator));
}
}

View File

@ -35,7 +35,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.34 2010/01/15 22:36:34 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.35 2010/02/26 02:01:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -284,7 +284,7 @@ FastCreateCachedPlan(Node *raw_parse_tree,
* CachedPlanSetParserHook: set up to use parser callback hooks
*
* Use this when a caller wants to manage parameter information via parser
* callbacks rather than a fixed parameter-types list. Beware that the
* callbacks rather than a fixed parameter-types list. Beware that the
* information pointed to by parserSetupArg must be valid for as long as
* the cached plan might be replanned!
*/
@ -360,9 +360,9 @@ StoreCachedPlan(CachedPlanSource *plansource,
if (plansource->fully_planned)
{
/*
* Planner already extracted dependencies, we don't have to ...
* except in the case of EXPLAIN. We assume here that EXPLAIN
* can't appear in a list with other commands.
* Planner already extracted dependencies, we don't have to ... except
* in the case of EXPLAIN. We assume here that EXPLAIN can't appear
* in a list with other commands.
*/
plan->relationOids = plan->invalItems = NIL;
@ -552,12 +552,12 @@ RevalidateCachedPlan(CachedPlanSource *plansource, bool useResOwner)
/*
* Generate plans for queries.
*
* The planner may try to call SPI-using functions, which causes
* a problem if we're already inside one. Rather than expect
* all SPI-using code to do SPI_push whenever a replan could
* happen, it seems best to take care of the case here.
* The planner may try to call SPI-using functions, which causes a
* problem if we're already inside one. Rather than expect all
* SPI-using code to do SPI_push whenever a replan could happen,
* it seems best to take care of the case here.
*/
bool pushed;
bool pushed;
pushed = SPI_push_conditional();
@ -1134,9 +1134,9 @@ ResetPlanCache(void)
* aborted transactions when we can't revalidate them (cf bug #5269).
* In general there is no point in invalidating utility statements
* since they have no plans anyway. So mark it dead only if it
* contains at least one non-utility statement. (EXPLAIN counts as
* a non-utility statement, though, since it contains an analyzed
* query that might have dependencies.)
* contains at least one non-utility statement. (EXPLAIN counts as a
* non-utility statement, though, since it contains an analyzed query
* that might have dependencies.)
*/
if (plan->fully_planned)
{

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.307 2010/02/17 04:19:39 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.308 2010/02/26 02:01:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -977,7 +977,7 @@ RelationInitIndexAccessInfo(Relation relation)
* honestly rather than just treating it as a Form_pg_index struct.
*/
tuple = SearchSysCache1(INDEXRELID,
ObjectIdGetDatum(RelationGetRelid(relation)));
ObjectIdGetDatum(RelationGetRelid(relation)));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
@ -1427,9 +1427,9 @@ formrdesc(const char *relationName, Oid relationReltype,
*
* The data we insert here is pretty incomplete/bogus, but it'll serve to
* get us launched. RelationCacheInitializePhase3() will read the real
* data from pg_class and replace what we've done here. Note in particular
* that relowner is left as zero; this cues RelationCacheInitializePhase3
* that the real data isn't there yet.
* data from pg_class and replace what we've done here. Note in
* particular that relowner is left as zero; this cues
* RelationCacheInitializePhase3 that the real data isn't there yet.
*/
relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE);
@ -1707,11 +1707,11 @@ RelationReloadIndexInfo(Relation relation)
relation->rd_amcache = NULL;
/*
* If it's a shared index, we might be called before backend startup
* has finished selecting a database, in which case we have no way to
* read pg_class yet. However, a shared index can never have any
* significant schema updates, so it's okay to ignore the invalidation
* signal. Just mark it valid and return without doing anything more.
* If it's a shared index, we might be called before backend startup has
* finished selecting a database, in which case we have no way to read
* pg_class yet. However, a shared index can never have any significant
* schema updates, so it's okay to ignore the invalidation signal. Just
* mark it valid and return without doing anything more.
*/
if (relation->rd_rel->relisshared && !criticalRelcachesBuilt)
{
@ -1755,7 +1755,7 @@ RelationReloadIndexInfo(Relation relation)
Form_pg_index index;
tuple = SearchSysCache1(INDEXRELID,
ObjectIdGetDatum(RelationGetRelid(relation)));
ObjectIdGetDatum(RelationGetRelid(relation)));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for index %u",
RelationGetRelid(relation));
@ -1793,8 +1793,8 @@ RelationDestroyRelation(Relation relation)
RelationCloseSmgr(relation);
/*
* Free all the subsidiary data structures of the relcache entry,
* then the entry itself.
* Free all the subsidiary data structures of the relcache entry, then the
* entry itself.
*/
if (relation->rd_rel)
pfree(relation->rd_rel);
@ -1908,21 +1908,21 @@ RelationClearRelation(Relation relation, bool rebuild)
else
{
/*
* Our strategy for rebuilding an open relcache entry is to build
* a new entry from scratch, swap its contents with the old entry,
* and finally delete the new entry (along with any infrastructure
* swapped over from the old entry). This is to avoid trouble in case
* an error causes us to lose control partway through. The old entry
* Our strategy for rebuilding an open relcache entry is to build a
* new entry from scratch, swap its contents with the old entry, and
* finally delete the new entry (along with any infrastructure swapped
* over from the old entry). This is to avoid trouble in case an
* error causes us to lose control partway through. The old entry
* will still be marked !rd_isvalid, so we'll try to rebuild it again
* on next access. Meanwhile it's not any less valid than it was
* on next access. Meanwhile it's not any less valid than it was
* before, so any code that might expect to continue accessing it
* isn't hurt by the rebuild failure. (Consider for example a
* subtransaction that ALTERs a table and then gets cancelled partway
* through the cache entry rebuild. The outer transaction should
* still see the not-modified cache entry as valid.) The worst
* consequence of an error is leaking the necessarily-unreferenced
* new entry, and this shouldn't happen often enough for that to be
* a big problem.
* consequence of an error is leaking the necessarily-unreferenced new
* entry, and this shouldn't happen often enough for that to be a big
* problem.
*
* When rebuilding an open relcache entry, we must preserve ref count,
* rd_createSubid/rd_newRelfilenodeSubid, and rd_toastoid state. Also
@ -1959,13 +1959,13 @@ RelationClearRelation(Relation relation, bool rebuild)
/*
* Perform swapping of the relcache entry contents. Within this
* process the old entry is momentarily invalid, so there *must*
* be no possibility of CHECK_FOR_INTERRUPTS within this sequence.
* Do it in all-in-line code for safety.
* process the old entry is momentarily invalid, so there *must* be no
* possibility of CHECK_FOR_INTERRUPTS within this sequence. Do it in
* all-in-line code for safety.
*
* Since the vast majority of fields should be swapped, our method
* is to swap the whole structures and then re-swap those few fields
* we didn't want swapped.
* Since the vast majority of fields should be swapped, our method is
* to swap the whole structures and then re-swap those few fields we
* didn't want swapped.
*/
#define SWAPFIELD(fldtype, fldname) \
do { \
@ -2536,8 +2536,8 @@ RelationBuildLocalRelation(const char *relname,
* Insert relation physical and logical identifiers (OIDs) into the right
* places. Note that the physical ID (relfilenode) is initially the same
* as the logical ID (OID); except that for a mapped relation, we set
* relfilenode to zero and rely on RelationInitPhysicalAddr to consult
* the map.
* relfilenode to zero and rely on RelationInitPhysicalAddr to consult the
* map.
*/
rel->rd_rel->relisshared = shared_relation;
rel->rd_rel->relistemp = rel->rd_istemp;
@ -2648,8 +2648,8 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid)
/*
* Now update the pg_class row. However, if we're dealing with a mapped
* index, pg_class.relfilenode doesn't change; instead we have to send
* the update to the relation mapper.
* index, pg_class.relfilenode doesn't change; instead we have to send the
* update to the relation mapper.
*/
if (RelationIsMapped(relation))
RelationMapUpdateMap(RelationGetRelid(relation),
@ -2660,7 +2660,7 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid)
classform->relfilenode = newrelfilenode;
/* These changes are safe even for a mapped relation */
classform->relpages = 0; /* it's empty until further notice */
classform->relpages = 0; /* it's empty until further notice */
classform->reltuples = 0;
classform->relfrozenxid = freezeXid;
@ -2679,8 +2679,8 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid)
/*
* Mark the rel as having been given a new relfilenode in the current
* (sub) transaction. This is a hint that can be used to optimize
* later operations on the rel in the same transaction.
* (sub) transaction. This is a hint that can be used to optimize later
* operations on the rel in the same transaction.
*/
relation->rd_newRelfilenodeSubid = GetCurrentSubTransactionId();
/* ... and now we have eoxact cleanup work to do */
@ -2761,8 +2761,8 @@ RelationCacheInitializePhase2(void)
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
/*
* Try to load the shared relcache cache file. If unsuccessful,
* bootstrap the cache with a pre-made descriptor for pg_database.
* Try to load the shared relcache cache file. If unsuccessful, bootstrap
* the cache with a pre-made descriptor for pg_database.
*/
if (!load_relcache_init_file(true))
{
@ -2808,9 +2808,9 @@ RelationCacheInitializePhase3(void)
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
/*
* Try to load the local relcache cache file. If unsuccessful,
* bootstrap the cache with pre-made descriptors for the critical
* "nailed-in" system catalogs.
* Try to load the local relcache cache file. If unsuccessful, bootstrap
* the cache with pre-made descriptors for the critical "nailed-in" system
* catalogs.
*/
if (IsBootstrapProcessingMode() ||
!load_relcache_init_file(false))
@ -2826,7 +2826,7 @@ RelationCacheInitializePhase3(void)
formrdesc("pg_type", TypeRelation_Rowtype_Id, false,
true, Natts_pg_type, Desc_pg_type);
#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */
#define NUM_CRITICAL_LOCAL_RELS 4 /* fix if you change list above */
}
MemoryContextSwitchTo(oldcxt);
@ -2881,7 +2881,7 @@ RelationCacheInitializePhase3(void)
load_critical_index(TriggerRelidNameIndexId,
TriggerRelationId);
#define NUM_CRITICAL_LOCAL_INDEXES 9 /* fix if you change list above */
#define NUM_CRITICAL_LOCAL_INDEXES 9 /* fix if you change list above */
criticalRelcachesBuilt = true;
}
@ -2889,10 +2889,10 @@ RelationCacheInitializePhase3(void)
/*
* Process critical shared indexes too.
*
* DatabaseNameIndexId isn't critical for relcache loading, but rather
* for initial lookup of MyDatabaseId, without which we'll never find
* any non-shared catalogs at all. Autovacuum calls InitPostgres with
* a database OID, so it instead depends on DatabaseOidIndexId.
* DatabaseNameIndexId isn't critical for relcache loading, but rather for
* initial lookup of MyDatabaseId, without which we'll never find any
* non-shared catalogs at all. Autovacuum calls InitPostgres with a
* database OID, so it instead depends on DatabaseOidIndexId.
*/
if (!criticalSharedRelcachesBuilt)
{
@ -2901,7 +2901,7 @@ RelationCacheInitializePhase3(void)
load_critical_index(DatabaseOidIndexId,
DatabaseRelationId);
#define NUM_CRITICAL_SHARED_INDEXES 2 /* fix if you change list above */
#define NUM_CRITICAL_SHARED_INDEXES 2 /* fix if you change list above */
criticalSharedRelcachesBuilt = true;
}
@ -2914,8 +2914,8 @@ RelationCacheInitializePhase3(void)
* relcache entries have rules or triggers, load that info the hard way
* since it isn't recorded in the cache file.
*
* Whenever we access the catalogs to read data, there is a possibility
* of a shared-inval cache flush causing relcache entries to be removed.
* Whenever we access the catalogs to read data, there is a possibility of
* a shared-inval cache flush causing relcache entries to be removed.
* Since hash_seq_search only guarantees to still work after the *current*
* entry is removed, it's unsafe to continue the hashtable scan afterward.
* We handle this by restarting the scan from scratch after each access.
@ -2943,7 +2943,7 @@ RelationCacheInitializePhase3(void)
Form_pg_class relp;
htup = SearchSysCache1(RELOID,
ObjectIdGetDatum(RelationGetRelid(relation)));
ObjectIdGetDatum(RelationGetRelid(relation)));
if (!HeapTupleIsValid(htup))
elog(FATAL, "cache lookup failed for relation %u",
RelationGetRelid(relation));
@ -2962,9 +2962,9 @@ RelationCacheInitializePhase3(void)
/*
* Check the values in rd_att were set up correctly. (We cannot
* just copy them over now: formrdesc must have set up the
* rd_att data correctly to start with, because it may already
* have been copied into one or more catcache entries.)
* just copy them over now: formrdesc must have set up the rd_att
* data correctly to start with, because it may already have been
* copied into one or more catcache entries.)
*/
Assert(relation->rd_att->tdtypeid == relp->reltype);
Assert(relation->rd_att->tdtypmod == -1);
@ -3701,8 +3701,8 @@ RelationGetExclusionInfo(Relation indexRelation,
Oid *funcs;
uint16 *strats;
Relation conrel;
SysScanDesc conscan;
ScanKeyData skey[1];
SysScanDesc conscan;
ScanKeyData skey[1];
HeapTuple htup;
bool found;
MemoryContext oldcxt;
@ -3723,9 +3723,9 @@ RelationGetExclusionInfo(Relation indexRelation,
}
/*
* Search pg_constraint for the constraint associated with the index.
* To make this not too painfully slow, we use the index on conrelid;
* that will hold the parent relation's OID not the index's own OID.
* Search pg_constraint for the constraint associated with the index. To
* make this not too painfully slow, we use the index on conrelid; that
* will hold the parent relation's OID not the index's own OID.
*/
ScanKeyInit(&skey[0],
Anum_pg_constraint_conrelid,
@ -3739,7 +3739,7 @@ RelationGetExclusionInfo(Relation indexRelation,
while (HeapTupleIsValid(htup = systable_getnext(conscan)))
{
Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
Form_pg_constraint conform = (Form_pg_constraint) GETSTRUCT(htup);
Datum val;
bool isnull;
ArrayType *arr;
@ -4483,7 +4483,7 @@ RelationCacheInitFileInvalidate(bool beforeSend)
*
* We used to keep the init files across restarts, but that is unsafe in PITR
* scenarios, and even in simple crash-recovery cases there are windows for
* the init files to become out-of-sync with the database. So now we just
* the init files to become out-of-sync with the database. So now we just
* remove them during startup and expect the first backend launch to rebuild
* them. Of course, this has to happen in each database of the cluster.
*/

View File

@ -23,7 +23,7 @@
* mapped catalogs can only be relocated by operations such as VACUUM FULL
* and CLUSTER, which make no transactionally-significant changes: it must be
* safe for the new file to replace the old, even if the transaction itself
* aborts. An important factor here is that the indexes and toast table of
* aborts. An important factor here is that the indexes and toast table of
* a mapped catalog must also be mapped, so that the rewrites/relocations of
* all these files commit in a single map file update rather than being tied
* to transaction commit.
@ -33,7 +33,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relmapper.c,v 1.2 2010/02/07 22:00:53 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/relmapper.c,v 1.3 2010/02/26 02:01:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -58,21 +58,21 @@
/*
* The map file is critical data: we have no automatic method for recovering
* from loss or corruption of it. We use a CRC so that we can detect
* corruption. To minimize the risk of failed updates, the map file should
* corruption. To minimize the risk of failed updates, the map file should
* be kept to no more than one standard-size disk sector (ie 512 bytes),
* and we use overwrite-in-place rather than playing renaming games.
* The struct layout below is designed to occupy exactly 512 bytes, which
* might make filesystem updates a bit more efficient.
*
* Entries in the mappings[] array are in no particular order. We could
* Entries in the mappings[] array are in no particular order. We could
* speed searching by insisting on OID order, but it really shouldn't be
* worth the trouble given the intended size of the mapping sets.
*/
#define RELMAPPER_FILENAME "pg_filenode.map"
#define RELMAPPER_FILEMAGIC 0x592717 /* version ID value */
#define RELMAPPER_FILEMAGIC 0x592717 /* version ID value */
#define MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */
#define MAX_MAPPINGS 62 /* 62 * 8 + 16 = 512 */
typedef struct RelMapping
{
@ -91,7 +91,7 @@ typedef struct RelMapFile
/*
* The currently known contents of the shared map file and our database's
* local map file are stored here. These can be reloaded from disk
* local map file are stored here. These can be reloaded from disk
* immediately whenever we receive an update sinval message.
*/
static RelMapFile shared_map;
@ -118,9 +118,9 @@ static RelMapFile pending_local_updates;
/* non-export function prototypes */
static void apply_map_update(RelMapFile *map, Oid relationId, Oid fileNode,
bool add_okay);
bool add_okay);
static void merge_map_updates(RelMapFile *map, const RelMapFile *updates,
bool add_okay);
bool add_okay);
static void load_relmap_file(bool shared);
static void write_relmap_file(bool shared, RelMapFile *newmap,
bool write_wal, bool send_sinval, bool preserve_files,
@ -208,9 +208,9 @@ RelationMapUpdateMap(Oid relationId, Oid fileNode, bool shared,
else
{
/*
* We don't currently support map changes within subtransactions.
* This could be done with more bookkeeping infrastructure, but it
* doesn't presently seem worth it.
* We don't currently support map changes within subtransactions. This
* could be done with more bookkeeping infrastructure, but it doesn't
* presently seem worth it.
*/
if (GetCurrentTransactionNestLevel() > 1)
elog(ERROR, "cannot change relation mapping within subtransaction");
@ -294,7 +294,7 @@ merge_map_updates(RelMapFile *map, const RelMapFile *updates, bool add_okay)
* RelationMapRemoveMapping
*
* Remove a relation's entry in the map. This is only allowed for "active"
* (but not committed) local mappings. We need it so we can back out the
* (but not committed) local mappings. We need it so we can back out the
* entry for the transient target file when doing VACUUM FULL/CLUSTER on
* a mapped relation.
*/
@ -322,7 +322,7 @@ RelationMapRemoveMapping(Oid relationId)
* RelationMapInvalidate
*
* This routine is invoked for SI cache flush messages. We must re-read
* the indicated map file. However, we might receive a SI message in a
* the indicated map file. However, we might receive a SI message in a
* process that hasn't yet, and might never, load the mapping files;
* for example the autovacuum launcher, which *must not* try to read
* a local map since it is attached to no particular database.
@ -390,7 +390,7 @@ AtCCI_RelationMap(void)
*
* During commit, this must be called as late as possible before the actual
* transaction commit, so as to minimize the window where the transaction
* could still roll back after committing map changes. Although nothing
* could still roll back after committing map changes. Although nothing
* critically bad happens in such a case, we still would prefer that it
* not happen, since we'd possibly be losing useful updates to the relations'
* pg_class row(s).
@ -457,7 +457,7 @@ AtPrepare_RelationMap(void)
/*
* CheckPointRelationMap
*
* This is called during a checkpoint. It must ensure that any relation map
* This is called during a checkpoint. It must ensure that any relation map
* updates that were WAL-logged before the start of the checkpoint are
* securely flushed to disk and will not need to be replayed later. This
* seems unlikely to be a performance-critical issue, so we use a simple
@ -599,10 +599,9 @@ load_relmap_file(bool shared)
/*
* Note: we could take RelationMappingLock in shared mode here, but it
* seems unnecessary since our read() should be atomic against any
* concurrent updater's write(). If the file is updated shortly after
* we look, the sinval signaling mechanism will make us re-read it
* before we are able to access any relation that's affected by the
* change.
* concurrent updater's write(). If the file is updated shortly after we
* look, the sinval signaling mechanism will make us re-read it before we
* are able to access any relation that's affected by the change.
*/
if (read(fd, map, sizeof(RelMapFile)) != sizeof(RelMapFile))
ereport(FATAL,
@ -627,8 +626,8 @@ load_relmap_file(bool shared)
if (!EQ_CRC32(crc, map->crc))
ereport(FATAL,
(errmsg("relation mapping file \"%s\" contains incorrect checksum",
mapfilename)));
(errmsg("relation mapping file \"%s\" contains incorrect checksum",
mapfilename)));
}
/*
@ -648,7 +647,7 @@ load_relmap_file(bool shared)
*
* Because this may be called during WAL replay when MyDatabaseId,
* DatabasePath, etc aren't valid, we require the caller to pass in suitable
* values. The caller is also responsible for being sure no concurrent
* values. The caller is also responsible for being sure no concurrent
* map update could be happening.
*/
static void
@ -676,10 +675,10 @@ write_relmap_file(bool shared, RelMapFile *newmap,
* critical section, so that an open() failure need not force PANIC.
*
* Note: since we use BasicOpenFile, we are nominally responsible for
* ensuring the fd is closed on error. In practice, this isn't important
* because either an error happens inside the critical section, or we
* are in bootstrap or WAL replay; so an error past this point is always
* fatal anyway.
* ensuring the fd is closed on error. In practice, this isn't important
* because either an error happens inside the critical section, or we are
* in bootstrap or WAL replay; so an error past this point is always fatal
* anyway.
*/
if (shared)
{
@ -773,11 +772,11 @@ write_relmap_file(bool shared, RelMapFile *newmap,
CacheInvalidateRelmap(dbid);
/*
* Make sure that the files listed in the map are not deleted if the
* outer transaction aborts. This had better be within the critical
* section too: it's not likely to fail, but if it did, we'd arrive
* at transaction abort with the files still vulnerable. PANICing
* will leave things in a good state on-disk.
* Make sure that the files listed in the map are not deleted if the outer
* transaction aborts. This had better be within the critical section
* too: it's not likely to fail, but if it did, we'd arrive at transaction
* abort with the files still vulnerable. PANICing will leave things in a
* good state on-disk.
*
* Note: we're cheating a little bit here by assuming that mapped files
* are either in pg_global or the database's default tablespace.
@ -816,13 +815,13 @@ perform_relmap_update(bool shared, const RelMapFile *updates)
RelMapFile newmap;
/*
* Anyone updating a relation's mapping info should take exclusive lock
* on that rel and hold it until commit. This ensures that there will
* not be concurrent updates on the same mapping value; but there could
* easily be concurrent updates on different values in the same file.
* We cover that by acquiring the RelationMappingLock, re-reading the
* target file to ensure it's up to date, applying the updates, and
* writing the data before releasing RelationMappingLock.
* Anyone updating a relation's mapping info should take exclusive lock on
* that rel and hold it until commit. This ensures that there will not be
* concurrent updates on the same mapping value; but there could easily be
* concurrent updates on different values in the same file. We cover that
* by acquiring the RelationMappingLock, re-reading the target file to
* ensure it's up to date, applying the updates, and writing the data
* before releasing RelationMappingLock.
*
* There is only one RelationMappingLock. In principle we could try to
* have one per mapping file, but it seems unlikely to be worth the
@ -866,8 +865,8 @@ relmap_redo(XLogRecPtr lsn, XLogRecord *record)
if (info == XLOG_RELMAP_UPDATE)
{
xl_relmap_update *xlrec = (xl_relmap_update *) XLogRecGetData(record);
RelMapFile newmap;
char *dbpath;
RelMapFile newmap;
char *dbpath;
if (xlrec->nbytes != sizeof(RelMapFile))
elog(PANIC, "relmap_redo: wrong size %u in relmap update record",
@ -878,14 +877,13 @@ relmap_redo(XLogRecPtr lsn, XLogRecord *record)
dbpath = GetDatabasePath(xlrec->dbid, xlrec->tsid);
/*
* Write out the new map and send sinval, but of course don't
* write a new WAL entry. There's no surrounding transaction
* to tell to preserve files, either.
* Write out the new map and send sinval, but of course don't write a
* new WAL entry. There's no surrounding transaction to tell to
* preserve files, either.
*
* There shouldn't be anyone else updating relmaps during WAL replay,
* so we don't bother to take the RelationMappingLock. We would
* need to do so if load_relmap_file needed to interlock against
* writers.
* so we don't bother to take the RelationMappingLock. We would need
* to do so if load_relmap_file needed to interlock against writers.
*/
write_relmap_file((xlrec->dbid == InvalidOid), &newmap,
false, true, false,

View File

@ -4,7 +4,7 @@
* Tablespace cache management.
*
* We cache the parsed version of spcoptions for each tablespace to avoid
* needing to reparse on every lookup. Right now, there doesn't appear to
* needing to reparse on every lookup. Right now, there doesn't appear to
* be a measurable performance gain from doing this, but that might change
* in the future as we add more options.
*
@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.5 2010/02/14 18:42:17 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/spccache.c,v 1.6 2010/02/26 02:01:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -75,7 +75,7 @@ InvalidateTableSpaceCacheCallback(Datum arg, int cacheid, ItemPointer tuplePtr)
static void
InitializeTableSpaceCache(void)
{
HASHCTL ctl;
HASHCTL ctl;
/* Initialize the hash table. */
MemSet(&ctl, 0, sizeof(ctl));
@ -84,7 +84,7 @@ InitializeTableSpaceCache(void)
ctl.hash = oid_hash;
TableSpaceCacheHash =
hash_create("TableSpace cache", 16, &ctl,
HASH_ELEM | HASH_FUNCTION);
HASH_ELEM | HASH_FUNCTION);
/* Make sure we've initialized CacheMemoryContext. */
if (!CacheMemoryContext)
@ -128,18 +128,18 @@ get_tablespace(Oid spcid)
return spc;
/*
* Not found in TableSpace cache. Check catcache. If we don't find a
* Not found in TableSpace cache. Check catcache. If we don't find a
* valid HeapTuple, it must mean someone has managed to request tablespace
* details for a non-existent tablespace. We'll just treat that case as if
* no options were specified.
* details for a non-existent tablespace. We'll just treat that case as
* if no options were specified.
*/
tp = SearchSysCache1(TABLESPACEOID, ObjectIdGetDatum(spcid));
if (!HeapTupleIsValid(tp))
opts = NULL;
else
{
Datum datum;
bool isNull;
Datum datum;
bool isNull;
datum = SysCacheGetAttr(TABLESPACEOID,
tp,
@ -149,7 +149,8 @@ get_tablespace(Oid spcid)
opts = NULL;
else
{
bytea *bytea_opts = tablespace_reloptions(datum, false);
bytea *bytea_opts = tablespace_reloptions(datum, false);
opts = MemoryContextAlloc(CacheMemoryContext, VARSIZE(bytea_opts));
memcpy(opts, bytea_opts, VARSIZE(bytea_opts));
}
@ -157,7 +158,7 @@ get_tablespace(Oid spcid)
}
/*
* Now create the cache entry. It's important to do this only after
* Now create the cache entry. It's important to do this only after
* reading the pg_tablespace entry, since doing so could cause a cache
* flush.
*/