summaryrefslogtreecommitdiff
path: root/src/backend/access/transam
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r--src/backend/access/transam/clog.c22
-rw-r--r--src/backend/access/transam/multixact.c380
-rw-r--r--src/backend/access/transam/slru.c132
-rw-r--r--src/backend/access/transam/subtrans.c21
-rw-r--r--src/backend/access/transam/transam.c40
-rw-r--r--src/backend/access/transam/twophase.c310
-rw-r--r--src/backend/access/transam/twophase_rmgr.c38
-rw-r--r--src/backend/access/transam/varsup.c138
-rw-r--r--src/backend/access/transam/xact.c639
-rw-r--r--src/backend/access/transam/xlog.c1129
-rw-r--r--src/backend/access/transam/xlogutils.c28
11 files changed, 1412 insertions, 1465 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c
index 4a2e1f5592..f29f460ade 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -24,7 +24,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.32 2005/08/20 23:26:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.33 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -222,14 +222,14 @@ StartupCLOG(void)
/*
* Zero out the remainder of the current clog page. Under normal
* circumstances it should be zeroes already, but it seems at least
- * theoretically possible that XLOG replay will have settled on a
- * nextXID value that is less than the last XID actually used and
- * marked by the previous database lifecycle (since subtransaction
- * commit writes clog but makes no WAL entry). Let's just be safe.
- * (We need not worry about pages beyond the current one, since those
- * will be zeroed when first used. For the same reason, there is no
- * need to do anything when nextXid is exactly at a page boundary; and
- * it's likely that the "current" page doesn't exist yet in that case.)
+ * theoretically possible that XLOG replay will have settled on a nextXID
+ * value that is less than the last XID actually used and marked by the
+ * previous database lifecycle (since subtransaction commit writes clog
+ * but makes no WAL entry). Let's just be safe. (We need not worry about
+ * pages beyond the current one, since those will be zeroed when first
+ * used. For the same reason, there is no need to do anything when
+ * nextXid is exactly at a page boundary; and it's likely that the
+ * "current" page doesn't exist yet in that case.)
*/
if (TransactionIdToPgIndex(xid) != 0)
{
@@ -325,8 +325,8 @@ TruncateCLOG(TransactionId oldestXact)
int cutoffPage;
/*
- * The cutoff point is the start of the segment containing oldestXact.
- * We pass the *page* containing oldestXact to SimpleLruTruncate.
+ * The cutoff point is the start of the segment containing oldestXact. We
+ * pass the *page* containing oldestXact to SimpleLruTruncate.
*/
cutoffPage = TransactionIdToPage(oldestXact);
diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 1adaebb6d8..ffe14ed6bf 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -4,15 +4,15 @@
* PostgreSQL multi-transaction-log manager
*
* The pg_multixact manager is a pg_clog-like manager that stores an array
- * of TransactionIds for each MultiXactId. It is a fundamental part of the
- * shared-row-lock implementation. A share-locked tuple stores a
+ * of TransactionIds for each MultiXactId. It is a fundamental part of the
+ * shared-row-lock implementation. A share-locked tuple stores a
* MultiXactId in its Xmax, and a transaction that needs to wait for the
* tuple to be unlocked can sleep on the potentially-several TransactionIds
* that compose the MultiXactId.
*
* We use two SLRU areas, one for storing the offsets at which the data
* starts for each MultiXactId in the other one. This trick allows us to
- * store variable length arrays of TransactionIds. (We could alternatively
+ * store variable length arrays of TransactionIds. (We could alternatively
* use one area containing counts and TransactionIds, with valid MultiXactId
* values pointing at slots containing counts; but that way seems less robust
* since it would get completely confused if someone inquired about a bogus
@@ -32,7 +32,7 @@
*
* Like clog.c, and unlike subtrans.c, we have to preserve state across
* crashes and ensure that MXID and offset numbering increases monotonically
- * across a crash. We do this in the same way as it's done for transaction
+ * across a crash. We do this in the same way as it's done for transaction
* IDs: the WAL record is guaranteed to contain evidence of every MXID we
* could need to worry about, and we just make sure that at the end of
* replay, the next-MXID and next-offset counters are at least as large as
@@ -42,7 +42,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.8 2005/08/20 23:26:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.9 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,13 +59,13 @@
/*
- * Defines for MultiXactOffset page sizes. A page is the same BLCKSZ as is
+ * Defines for MultiXactOffset page sizes. A page is the same BLCKSZ as is
* used everywhere else in Postgres.
*
* Note: because both MultiXactOffsets and TransactionIds are 32 bits and
* wrap around at 0xFFFFFFFF, MultiXact page numbering also wraps around at
* 0xFFFFFFFF/MULTIXACT_*_PER_PAGE, and segment numbering at
- * 0xFFFFFFFF/MULTIXACT_*_PER_PAGE/SLRU_SEGMENTS_PER_PAGE. We need take no
+ * 0xFFFFFFFF/MULTIXACT_*_PER_PAGE/SLRU_SEGMENTS_PER_PAGE. We need take no
* explicit notice of that fact in this module, except when comparing segment
* and page numbers in TruncateMultiXact
* (see MultiXact{Offset,Member}PagePrecedes).
@@ -92,11 +92,11 @@
static SlruCtlData MultiXactOffsetCtlData;
static SlruCtlData MultiXactMemberCtlData;
-#define MultiXactOffsetCtl (&MultiXactOffsetCtlData)
-#define MultiXactMemberCtl (&MultiXactMemberCtlData)
+#define MultiXactOffsetCtl (&MultiXactOffsetCtlData)
+#define MultiXactMemberCtl (&MultiXactMemberCtlData)
/*
- * MultiXact state shared across all backends. All this state is protected
+ * MultiXact state shared across all backends. All this state is protected
* by MultiXactGenLock. (We also use MultiXactOffsetControlLock and
* MultiXactMemberControlLock to guard accesses to the two sets of SLRU
* buffers. For concurrency's sake, we avoid holding more than one of these
@@ -105,50 +105,48 @@ static SlruCtlData MultiXactMemberCtlData;
typedef struct MultiXactStateData
{
/* next-to-be-assigned MultiXactId */
- MultiXactId nextMXact;
+ MultiXactId nextMXact;
/* next-to-be-assigned offset */
- MultiXactOffset nextOffset;
+ MultiXactOffset nextOffset;
/* the Offset SLRU area was last truncated at this MultiXactId */
- MultiXactId lastTruncationPoint;
+ MultiXactId lastTruncationPoint;
/*
- * Per-backend data starts here. We have two arrays stored in
- * the area immediately following the MultiXactStateData struct.
- * Each is indexed by BackendId. (Note: valid BackendIds run from 1 to
- * MaxBackends; element zero of each array is never used.)
+ * Per-backend data starts here. We have two arrays stored in the area
+ * immediately following the MultiXactStateData struct. Each is indexed by
+ * BackendId. (Note: valid BackendIds run from 1 to MaxBackends; element
+ * zero of each array is never used.)
*
- * OldestMemberMXactId[k] is the oldest MultiXactId each backend's
- * current transaction(s) could possibly be a member of, or
- * InvalidMultiXactId when the backend has no live transaction that
- * could possibly be a member of a MultiXact. Each backend sets its
- * entry to the current nextMXact counter just before first acquiring a
- * shared lock in a given transaction, and clears it at transaction end.
- * (This works because only during or after acquiring a shared lock
- * could an XID possibly become a member of a MultiXact, and that
- * MultiXact would have to be created during or after the lock
- * acquisition.)
+ * OldestMemberMXactId[k] is the oldest MultiXactId each backend's current
+ * transaction(s) could possibly be a member of, or InvalidMultiXactId
+ * when the backend has no live transaction that could possibly be a
+ * member of a MultiXact. Each backend sets its entry to the current
+ * nextMXact counter just before first acquiring a shared lock in a given
+ * transaction, and clears it at transaction end. (This works because only
+ * during or after acquiring a shared lock could an XID possibly become a
+ * member of a MultiXact, and that MultiXact would have to be created
+ * during or after the lock acquisition.)
*
- * OldestVisibleMXactId[k] is the oldest MultiXactId each backend's
- * current transaction(s) think is potentially live, or InvalidMultiXactId
- * when not in a transaction or not in a transaction that's paid any
- * attention to MultiXacts yet. This is computed when first needed in
- * a given transaction, and cleared at transaction end. We can compute
- * it as the minimum of the valid OldestMemberMXactId[] entries at the
- * time we compute it (using nextMXact if none are valid). Each backend
- * is required not to attempt to access any SLRU data for MultiXactIds
- * older than its own OldestVisibleMXactId[] setting; this is necessary
- * because the checkpointer could truncate away such data at any instant.
+ * OldestVisibleMXactId[k] is the oldest MultiXactId each backend's current
+ * transaction(s) think is potentially live, or InvalidMultiXactId when
+ * not in a transaction or not in a transaction that's paid any attention
+ * to MultiXacts yet. This is computed when first needed in a given
+ * transaction, and cleared at transaction end. We can compute it as the
+ * minimum of the valid OldestMemberMXactId[] entries at the time we
+ * compute it (using nextMXact if none are valid). Each backend is
+ * required not to attempt to access any SLRU data for MultiXactIds older
+ * than its own OldestVisibleMXactId[] setting; this is necessary because
+ * the checkpointer could truncate away such data at any instant.
*
- * The checkpointer can compute the safe truncation point as the oldest
- * valid value among all the OldestMemberMXactId[] and
- * OldestVisibleMXactId[] entries, or nextMXact if none are valid.
- * Clearly, it is not possible for any later-computed OldestVisibleMXactId
- * value to be older than this, and so there is no risk of truncating
- * data that is still needed.
+ * The checkpointer can compute the safe truncation point as the oldest valid
+ * value among all the OldestMemberMXactId[] and OldestVisibleMXactId[]
+ * entries, or nextMXact if none are valid. Clearly, it is not possible
+ * for any later-computed OldestVisibleMXactId value to be older than
+ * this, and so there is no risk of truncating data that is still needed.
*/
- MultiXactId perBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */
+ MultiXactId perBackendXactIds[1]; /* VARIABLE LENGTH ARRAY */
} MultiXactStateData;
/* Pointers to the state data in shared memory */
@@ -176,13 +174,13 @@ static MultiXactId *OldestVisibleMXactId;
typedef struct mXactCacheEnt
{
struct mXactCacheEnt *next;
- MultiXactId multi;
- int nxids;
- TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */
+ MultiXactId multi;
+ int nxids;
+ TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */
} mXactCacheEnt;
-static mXactCacheEnt *MXactCache = NULL;
-static MemoryContext MXactContext = NULL;
+static mXactCacheEnt *MXactCache = NULL;
+static MemoryContext MXactContext = NULL;
#ifdef MULTIXACT_DEBUG
@@ -201,14 +199,15 @@ static MemoryContext MXactContext = NULL;
static void MultiXactIdSetOldestVisible(void);
static MultiXactId CreateMultiXactId(int nxids, TransactionId *xids);
static void RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
- int nxids, TransactionId *xids);
+ int nxids, TransactionId *xids);
static MultiXactId GetNewMultiXactId(int nxids, MultiXactOffset *offset);
/* MultiXact cache management */
static MultiXactId mXactCacheGetBySet(int nxids, TransactionId *xids);
-static int mXactCacheGetById(MultiXactId multi, TransactionId **xids);
+static int mXactCacheGetById(MultiXactId multi, TransactionId **xids);
static void mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids);
-static int xidComparator(const void *arg1, const void *arg2);
+static int xidComparator(const void *arg1, const void *arg2);
+
#ifdef MULTIXACT_DEBUG
static char *mxid_to_string(MultiXactId multi, int nxids, TransactionId *xids);
#endif
@@ -220,7 +219,7 @@ static bool MultiXactOffsetPagePrecedes(int page1, int page2);
static bool MultiXactMemberPagePrecedes(int page1, int page2);
static bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2);
static bool MultiXactOffsetPrecedes(MultiXactOffset offset1,
- MultiXactOffset offset2);
+ MultiXactOffset offset2);
static void ExtendMultiXactOffset(MultiXactId multi);
static void ExtendMultiXactMember(MultiXactOffset offset, int nmembers);
static void TruncateMultiXact(void);
@@ -239,8 +238,8 @@ static void WriteMZeroPageXlogRec(int pageno, uint8 info);
MultiXactId
MultiXactIdCreate(TransactionId xid1, TransactionId xid2)
{
- MultiXactId newMulti;
- TransactionId xids[2];
+ MultiXactId newMulti;
+ TransactionId xids[2];
AssertArg(TransactionIdIsValid(xid1));
AssertArg(TransactionIdIsValid(xid2));
@@ -248,9 +247,9 @@ MultiXactIdCreate(TransactionId xid1, TransactionId xid2)
Assert(!TransactionIdEquals(xid1, xid2));
/*
- * Note: unlike MultiXactIdExpand, we don't bother to check that both
- * XIDs are still running. In typical usage, xid2 will be our own XID
- * and the caller just did a check on xid1, so it'd be wasted effort.
+ * Note: unlike MultiXactIdExpand, we don't bother to check that both XIDs
+ * are still running. In typical usage, xid2 will be our own XID and the
+ * caller just did a check on xid1, so it'd be wasted effort.
*/
xids[0] = xid1;
@@ -281,12 +280,12 @@ MultiXactIdCreate(TransactionId xid1, TransactionId xid2)
MultiXactId
MultiXactIdExpand(MultiXactId multi, TransactionId xid)
{
- MultiXactId newMulti;
- TransactionId *members;
- TransactionId *newMembers;
- int nmembers;
- int i;
- int j;
+ MultiXactId newMulti;
+ TransactionId *members;
+ TransactionId *newMembers;
+ int nmembers;
+ int i;
+ int j;
AssertArg(MultiXactIdIsValid(multi));
AssertArg(TransactionIdIsValid(xid));
@@ -313,8 +312,8 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid)
}
/*
- * If the TransactionId is already a member of the MultiXactId,
- * just return the existing MultiXactId.
+ * If the TransactionId is already a member of the MultiXactId, just
+ * return the existing MultiXactId.
*/
for (i = 0; i < nmembers; i++)
{
@@ -329,9 +328,9 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid)
/*
* Determine which of the members of the MultiXactId are still running,
- * and use them to create a new one. (Removing dead members is just
- * an optimization, but a useful one. Note we have the same race
- * condition here as above: j could be 0 at the end of the loop.)
+ * and use them to create a new one. (Removing dead members is just an
+ * optimization, but a useful one. Note we have the same race condition
+ * here as above: j could be 0 at the end of the loop.)
*/
newMembers = (TransactionId *)
palloc(sizeof(TransactionId) * (nmembers + 1));
@@ -355,7 +354,7 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid)
/*
* MultiXactIdIsRunning
- * Returns whether a MultiXactId is "running".
+ * Returns whether a MultiXactId is "running".
*
* We return true if at least one member of the given MultiXactId is still
* running. Note that a "false" result is certain not to change,
@@ -365,9 +364,9 @@ bool
MultiXactIdIsRunning(MultiXactId multi)
{
TransactionId *members;
- TransactionId myXid;
- int nmembers;
- int i;
+ TransactionId myXid;
+ int nmembers;
+ int i;
debug_elog3(DEBUG2, "IsRunning %u?", multi);
@@ -394,7 +393,7 @@ MultiXactIdIsRunning(MultiXactId multi)
/*
* This could be made faster by having another entry point in procarray.c,
- * walking the PGPROC array only once for all the members. But in most
+ * walking the PGPROC array only once for all the members. But in most
* cases nmembers should be small enough that it doesn't much matter.
*/
for (i = 0; i < nmembers; i++)
@@ -436,19 +435,19 @@ MultiXactIdSetOldestMember(void)
/*
* You might think we don't need to acquire a lock here, since
- * fetching and storing of TransactionIds is probably atomic,
- * but in fact we do: suppose we pick up nextMXact and then
- * lose the CPU for a long time. Someone else could advance
- * nextMXact, and then another someone else could compute an
- * OldestVisibleMXactId that would be after the value we are
- * going to store when we get control back. Which would be wrong.
+ * fetching and storing of TransactionIds is probably atomic, but in
+ * fact we do: suppose we pick up nextMXact and then lose the CPU for
+ * a long time. Someone else could advance nextMXact, and then
+ * another someone else could compute an OldestVisibleMXactId that
+ * would be after the value we are going to store when we get control
+ * back. Which would be wrong.
*/
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/*
* We have to beware of the possibility that nextMXact is in the
- * wrapped-around state. We don't fix the counter itself here,
- * but we must be sure to store a valid value in our array entry.
+ * wrapped-around state. We don't fix the counter itself here, but we
+ * must be sure to store a valid value in our array entry.
*/
nextMXact = MultiXactState->nextMXact;
if (nextMXact < FirstMultiXactId)
@@ -475,7 +474,7 @@ MultiXactIdSetOldestMember(void)
* The value to set is the oldest of nextMXact and all the valid per-backend
* OldestMemberMXactId[] entries. Because of the locking we do, we can be
* certain that no subsequent call to MultiXactIdSetOldestMember can set
- * an OldestMemberMXactId[] entry older than what we compute here. Therefore
+ * an OldestMemberMXactId[] entry older than what we compute here. Therefore
* there is no live transaction, now or later, that can be a member of any
* MultiXactId older than the OldestVisibleMXactId we compute here.
*/
@@ -485,14 +484,14 @@ MultiXactIdSetOldestVisible(void)
if (!MultiXactIdIsValid(OldestVisibleMXactId[MyBackendId]))
{
MultiXactId oldestMXact;
- int i;
+ int i;
LWLockAcquire(MultiXactGenLock, LW_EXCLUSIVE);
/*
* We have to beware of the possibility that nextMXact is in the
- * wrapped-around state. We don't fix the counter itself here,
- * but we must be sure to store a valid value in our array entry.
+ * wrapped-around state. We don't fix the counter itself here, but we
+ * must be sure to store a valid value in our array entry.
*/
oldestMXact = MultiXactState->nextMXact;
if (oldestMXact < FirstMultiXactId)
@@ -535,17 +534,17 @@ void
MultiXactIdWait(MultiXactId multi)
{
TransactionId *members;
- int nmembers;
+ int nmembers;
nmembers = GetMultiXactIdMembers(multi, &members);
if (nmembers >= 0)
{
- int i;
+ int i;
for (i = 0; i < nmembers; i++)
{
- TransactionId member = members[i];
+ TransactionId member = members[i];
debug_elog4(DEBUG2, "MultiXactIdWait: waiting for %d (%u)",
i, member);
@@ -564,19 +563,19 @@ MultiXactIdWait(MultiXactId multi)
bool
ConditionalMultiXactIdWait(MultiXactId multi)
{
- bool result = true;
+ bool result = true;
TransactionId *members;
- int nmembers;
+ int nmembers;
nmembers = GetMultiXactIdMembers(multi, &members);
if (nmembers >= 0)
{
- int i;
+ int i;
for (i = 0; i < nmembers; i++)
{
- TransactionId member = members[i];
+ TransactionId member = members[i];
debug_elog4(DEBUG2, "ConditionalMultiXactIdWait: trying %d (%u)",
i, member);
@@ -596,7 +595,7 @@ ConditionalMultiXactIdWait(MultiXactId multi)
/*
* CreateMultiXactId
- * Make a new MultiXactId
+ * Make a new MultiXactId
*
* Make XLOG, SLRU and cache entries for a new MultiXactId, recording the
* given TransactionIds as members. Returns the newly created MultiXactId.
@@ -606,7 +605,7 @@ ConditionalMultiXactIdWait(MultiXactId multi)
static MultiXactId
CreateMultiXactId(int nxids, TransactionId *xids)
{
- MultiXactId multi;
+ MultiXactId multi;
MultiXactOffset offset;
XLogRecData rdata[2];
xl_multixact_create xlrec;
@@ -641,15 +640,15 @@ CreateMultiXactId(int nxids, TransactionId *xids)
/*
* Make an XLOG entry describing the new MXID.
*
- * Note: we need not flush this XLOG entry to disk before proceeding.
- * The only way for the MXID to be referenced from any data page is
- * for heap_lock_tuple() to have put it there, and heap_lock_tuple()
- * generates an XLOG record that must follow ours. The normal LSN
- * interlock between the data page and that XLOG record will ensure
- * that our XLOG record reaches disk first. If the SLRU members/offsets
- * data reaches disk sooner than the XLOG record, we do not care because
- * we'll overwrite it with zeroes unless the XLOG record is there too;
- * see notes at top of this file.
+ * Note: we need not flush this XLOG entry to disk before proceeding. The
+ * only way for the MXID to be referenced from any data page is for
+ * heap_lock_tuple() to have put it there, and heap_lock_tuple() generates
+ * an XLOG record that must follow ours. The normal LSN interlock between
+ * the data page and that XLOG record will ensure that our XLOG record
+ * reaches disk first. If the SLRU members/offsets data reaches disk
+ * sooner than the XLOG record, we do not care because we'll overwrite it
+ * with zeroes unless the XLOG record is there too; see notes at top of
+ * this file.
*/
xlrec.mid = multi;
xlrec.moff = offset;
@@ -702,9 +701,9 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
/*
* Note: we pass the MultiXactId to SimpleLruReadPage as the "transaction"
* to complain about if there's any I/O error. This is kinda bogus, but
- * since the errors will always give the full pathname, it should be
- * clear enough that a MultiXactId is really involved. Perhaps someday
- * we'll take the trouble to generalize the slru.c error reporting code.
+ * since the errors will always give the full pathname, it should be clear
+ * enough that a MultiXactId is really involved. Perhaps someday we'll
+ * take the trouble to generalize the slru.c error reporting code.
*/
slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, multi);
offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
@@ -750,7 +749,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
* GetNewMultiXactId
* Get the next MultiXactId.
*
- * Also, reserve the needed amount of space in the "members" area. The
+ * Also, reserve the needed amount of space in the "members" area. The
* starting offset of the reserved space is returned in *offset.
*
* This may generate XLOG records for expansion of the offsets and/or members
@@ -761,7 +760,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
static MultiXactId
GetNewMultiXactId(int nxids, MultiXactOffset *offset)
{
- MultiXactId result;
+ MultiXactId result;
debug_elog3(DEBUG2, "GetNew: for %d xids", nxids);
@@ -785,8 +784,8 @@ GetNewMultiXactId(int nxids, MultiXactOffset *offset)
* Advance counter. As in GetNewTransactionId(), this must not happen
* until after ExtendMultiXactOffset has succeeded!
*
- * We don't care about MultiXactId wraparound here; it will be handled by
- * the next iteration. But note that nextMXact may be InvalidMultiXactId
+ * We don't care about MultiXactId wraparound here; it will be handled by the
+ * next iteration. But note that nextMXact may be InvalidMultiXactId
* after this routine exits, so anyone else looking at the variable must
* be prepared to deal with that.
*/
@@ -809,7 +808,7 @@ GetNewMultiXactId(int nxids, MultiXactOffset *offset)
/*
* GetMultiXactIdMembers
- * Returns the set of TransactionIds that make up a MultiXactId
+ * Returns the set of TransactionIds that make up a MultiXactId
*
* We return -1 if the MultiXactId is too old to possibly have any members
* still running; in that case we have not actually looked them up, and
@@ -822,13 +821,13 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
int prev_pageno;
int entryno;
int slotno;
- MultiXactOffset *offptr;
- MultiXactOffset offset;
+ MultiXactOffset *offptr;
+ MultiXactOffset offset;
int length;
int i;
- MultiXactId nextMXact;
- MultiXactId tmpMXact;
- MultiXactOffset nextOffset;
+ MultiXactId nextMXact;
+ MultiXactId tmpMXact;
+ MultiXactOffset nextOffset;
TransactionId *ptr;
debug_elog3(DEBUG2, "GetMembers: asked for %u", multi);
@@ -850,13 +849,13 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
/*
* We check known limits on MultiXact before resorting to the SLRU area.
*
- * An ID older than our OldestVisibleMXactId[] entry can't possibly still
- * be running, and we'd run the risk of trying to read already-truncated
- * SLRU data if we did try to examine it.
+ * An ID older than our OldestVisibleMXactId[] entry can't possibly still be
+ * running, and we'd run the risk of trying to read already-truncated SLRU
+ * data if we did try to examine it.
*
- * Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is
- * seen, it implies undetected ID wraparound has occurred. We just
- * silently assume that such an ID is no longer running.
+ * Conversely, an ID >= nextMXact shouldn't ever be seen here; if it is seen,
+ * it implies undetected ID wraparound has occurred. We just silently
+ * assume that such an ID is no longer running.
*
* Shared lock is enough here since we aren't modifying any global state.
* Also, we can examine our own OldestVisibleMXactId without the lock,
@@ -880,9 +879,9 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
}
/*
- * Before releasing the lock, save the current counter values, because
- * the target MultiXactId may be just one less than nextMXact. We will
- * need to use nextOffset as the endpoint if so.
+ * Before releasing the lock, save the current counter values, because the
+ * target MultiXactId may be just one less than nextMXact. We will need
+ * to use nextOffset as the endpoint if so.
*/
nextMXact = MultiXactState->nextMXact;
nextOffset = MultiXactState->nextOffset;
@@ -902,11 +901,11 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
/*
* How many members do we need to read? If we are at the end of the
- * assigned MultiXactIds, use the offset just saved above. Else we
- * need to check the MultiXactId following ours.
+ * assigned MultiXactIds, use the offset just saved above. Else we need
+ * to check the MultiXactId following ours.
*
- * Use the same increment rule as GetNewMultiXactId(), that is, don't
- * handle wraparound explicitly until needed.
+ * Use the same increment rule as GetNewMultiXactId(), that is, don't handle
+ * wraparound explicitly until needed.
*/
tmpMXact = multi + 1;
@@ -974,9 +973,9 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
/*
* mXactCacheGetBySet
- * returns a MultiXactId from the cache based on the set of
- * TransactionIds that compose it, or InvalidMultiXactId if
- * none matches.
+ * returns a MultiXactId from the cache based on the set of
+ * TransactionIds that compose it, or InvalidMultiXactId if
+ * none matches.
*
* This is helpful, for example, if two transactions want to lock a huge
* table. By using the cache, the second will use the same MultiXactId
@@ -988,7 +987,7 @@ GetMultiXactIdMembers(MultiXactId multi, TransactionId **xids)
static MultiXactId
mXactCacheGetBySet(int nxids, TransactionId *xids)
{
- mXactCacheEnt *entry;
+ mXactCacheEnt *entry;
debug_elog3(DEBUG2, "CacheGet: looking for %s",
mxid_to_string(InvalidMultiXactId, nxids, xids));
@@ -1015,8 +1014,8 @@ mXactCacheGetBySet(int nxids, TransactionId *xids)
/*
* mXactCacheGetById
- * returns the composing TransactionId set from the cache for a
- * given MultiXactId, if present.
+ * returns the composing TransactionId set from the cache for a
+ * given MultiXactId, if present.
*
* If successful, *xids is set to the address of a palloc'd copy of the
* TransactionId set. Return value is number of members, or -1 on failure.
@@ -1024,7 +1023,7 @@ mXactCacheGetBySet(int nxids, TransactionId *xids)
static int
mXactCacheGetById(MultiXactId multi, TransactionId **xids)
{
- mXactCacheEnt *entry;
+ mXactCacheEnt *entry;
debug_elog3(DEBUG2, "CacheGet: looking for %u", multi);
@@ -1032,7 +1031,7 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids)
{
if (entry->multi == multi)
{
- TransactionId *ptr;
+ TransactionId *ptr;
Size size;
size = sizeof(TransactionId) * entry->nxids;
@@ -1042,7 +1041,7 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids)
memcpy(ptr, entry->xids, size);
debug_elog3(DEBUG2, "CacheGet: found %s",
- mxid_to_string(multi, entry->nxids, entry->xids));
+ mxid_to_string(multi, entry->nxids, entry->xids));
return entry->nxids;
}
}
@@ -1053,12 +1052,12 @@ mXactCacheGetById(MultiXactId multi, TransactionId **xids)
/*
* mXactCachePut
- * Add a new MultiXactId and its composing set into the local cache.
+ * Add a new MultiXactId and its composing set into the local cache.
*/
static void
mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids)
{
- mXactCacheEnt *entry;
+ mXactCacheEnt *entry;
debug_elog3(DEBUG2, "CachePut: storing %s",
mxid_to_string(multi, nxids, xids));
@@ -1092,7 +1091,7 @@ mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids)
/*
* xidComparator
- * qsort comparison function for XIDs
+ * qsort comparison function for XIDs
*
* We don't need to use wraparound comparison for XIDs, and indeed must
* not do so since that does not respect the triangle inequality! Any
@@ -1101,8 +1100,8 @@ mXactCachePut(MultiXactId multi, int nxids, TransactionId *xids)
static int
xidComparator(const void *arg1, const void *arg2)
{
- TransactionId xid1 = * (const TransactionId *) arg1;
- TransactionId xid2 = * (const TransactionId *) arg2;
+ TransactionId xid1 = *(const TransactionId *) arg1;
+ TransactionId xid2 = *(const TransactionId *) arg2;
if (xid1 > xid2)
return 1;
@@ -1115,8 +1114,9 @@ xidComparator(const void *arg1, const void *arg2)
static char *
mxid_to_string(MultiXactId multi, int nxids, TransactionId *xids)
{
- char *str = palloc(15 * (nxids + 1) + 4);
- int i;
+ char *str = palloc(15 * (nxids + 1) + 4);
+ int i;
+
snprintf(str, 47, "%u %d[%u", multi, nxids, xids[0]);
for (i = 1; i < nxids; i++)
@@ -1137,18 +1137,18 @@ void
AtEOXact_MultiXact(void)
{
/*
- * Reset our OldestMemberMXactId and OldestVisibleMXactId values,
- * both of which should only be valid while within a transaction.
+ * Reset our OldestMemberMXactId and OldestVisibleMXactId values, both of
+ * which should only be valid while within a transaction.
*
- * We assume that storing a MultiXactId is atomic and so we need
- * not take MultiXactGenLock to do this.
+ * We assume that storing a MultiXactId is atomic and so we need not take
+ * MultiXactGenLock to do this.
*/
OldestMemberMXactId[MyBackendId] = InvalidMultiXactId;
OldestVisibleMXactId[MyBackendId] = InvalidMultiXactId;
/*
- * Discard the local MultiXactId cache. Since MXactContext was created
- * as a child of TopTransactionContext, we needn't delete it explicitly.
+ * Discard the local MultiXactId cache. Since MXactContext was created as
+ * a child of TopTransactionContext, we needn't delete it explicitly.
*/
MXactContext = NULL;
MXactCache = NULL;
@@ -1156,7 +1156,7 @@ AtEOXact_MultiXact(void)
/*
* Initialization of shared memory for MultiXact. We use two SLRU areas,
- * thus double memory. Also, reserve space for the shared MultiXactState
+ * thus double memory. Also, reserve space for the shared MultiXactState
* struct and the per-backend MultiXactId arrays (two of those, too).
*/
Size
@@ -1178,7 +1178,7 @@ MultiXactShmemSize(void)
void
MultiXactShmemInit(void)
{
- bool found;
+ bool found;
debug_elog2(DEBUG2, "Shared Memory Init for MultiXact");
@@ -1205,8 +1205,8 @@ MultiXactShmemInit(void)
Assert(found);
/*
- * Set up array pointers. Note that perBackendXactIds[0] is wasted
- * space since we only use indexes 1..MaxBackends in each array.
+ * Set up array pointers. Note that perBackendXactIds[0] is wasted space
+ * since we only use indexes 1..MaxBackends in each array.
*/
OldestMemberMXactId = MultiXactState->perBackendXactIds;
OldestVisibleMXactId = OldestMemberMXactId + MaxBackends;
@@ -1214,7 +1214,7 @@ MultiXactShmemInit(void)
/*
* This func must be called ONCE on system install. It creates the initial
- * MultiXact segments. (The MultiXacts directories are assumed to have been
+ * MultiXact segments. (The MultiXacts directories are assumed to have been
* created by initdb, and MultiXactShmemInit must have been called already.)
*/
void
@@ -1287,7 +1287,7 @@ ZeroMultiXactMemberPage(int pageno, bool writeXlog)
* This must be called ONCE during postmaster or standalone-backend startup.
*
* StartupXLOG has already established nextMXact/nextOffset by calling
- * MultiXactSetNextMXact and/or MultiXactAdvanceNextMXact. Note that we
+ * MultiXactSetNextMXact and/or MultiXactAdvanceNextMXact. Note that we
* may already have replayed WAL data into the SLRU files.
*
* We don't need any locks here, really; the SLRU locks are taken
@@ -1311,14 +1311,14 @@ StartupMultiXact(void)
MultiXactOffsetCtl->shared->latest_page_number = pageno;
/*
- * Zero out the remainder of the current offsets page. See notes
- * in StartupCLOG() for motivation.
+ * Zero out the remainder of the current offsets page. See notes in
+ * StartupCLOG() for motivation.
*/
entryno = MultiXactIdToOffsetEntry(multi);
if (entryno != 0)
{
int slotno;
- MultiXactOffset *offptr;
+ MultiXactOffset *offptr;
slotno = SimpleLruReadPage(MultiXactOffsetCtl, pageno, multi);
offptr = (MultiXactOffset *) MultiXactOffsetCtl->shared->page_buffer[slotno];
@@ -1341,14 +1341,14 @@ StartupMultiXact(void)
MultiXactMemberCtl->shared->latest_page_number = pageno;
/*
- * Zero out the remainder of the current members page. See notes
- * in StartupCLOG() for motivation.
+ * Zero out the remainder of the current members page. See notes in
+ * StartupCLOG() for motivation.
*/
entryno = MXOffsetToMemberEntry(offset);
if (entryno != 0)
{
int slotno;
- TransactionId *xidptr;
+ TransactionId *xidptr;
slotno = SimpleLruReadPage(MultiXactMemberCtl, pageno, offset);
xidptr = (TransactionId *) MultiXactMemberCtl->shared->page_buffer[slotno];
@@ -1499,14 +1499,14 @@ static void
ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
{
/*
- * It's possible that the members span more than one page of the
- * members file, so we loop to ensure we consider each page. The
- * coding is not optimal if the members span several pages, but
- * that seems unusual enough to not worry much about.
+ * It's possible that the members span more than one page of the members
+ * file, so we loop to ensure we consider each page. The coding is not
+ * optimal if the members span several pages, but that seems unusual
+ * enough to not worry much about.
*/
while (nmembers > 0)
{
- int entryno;
+ int entryno;
/*
* Only zero when at first entry of a page.
@@ -1514,7 +1514,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
entryno = MXOffsetToMemberEntry(offset);
if (entryno == 0)
{
- int pageno;
+ int pageno;
pageno = MXOffsetToMemberPage(offset);
@@ -1536,7 +1536,7 @@ ExtendMultiXactMember(MultiXactOffset offset, int nmembers)
* Remove all MultiXactOffset and MultiXactMember segments before the oldest
* ones still of interest.
*
- * This is called only during checkpoints. We assume no more than one
+ * This is called only during checkpoints. We assume no more than one
* backend does this at a time.
*
* XXX do we have any issues with needing to checkpoint here?
@@ -1545,23 +1545,23 @@ static void
TruncateMultiXact(void)
{
MultiXactId nextMXact;
- MultiXactOffset nextOffset;
+ MultiXactOffset nextOffset;
MultiXactId oldestMXact;
- MultiXactOffset oldestOffset;
+ MultiXactOffset oldestOffset;
int cutoffPage;
int i;
/*
- * First, compute where we can safely truncate. Per notes above,
- * this is the oldest valid value among all the OldestMemberMXactId[] and
+ * First, compute where we can safely truncate. Per notes above, this is
+ * the oldest valid value among all the OldestMemberMXactId[] and
* OldestVisibleMXactId[] entries, or nextMXact if none are valid.
*/
LWLockAcquire(MultiXactGenLock, LW_SHARED);
/*
* We have to beware of the possibility that nextMXact is in the
- * wrapped-around state. We don't fix the counter itself here,
- * but we must be sure to use a valid value in our calculation.
+ * wrapped-around state. We don't fix the counter itself here, but we
+ * must be sure to use a valid value in our calculation.
*/
nextMXact = MultiXactState->nextMXact;
if (nextMXact < FirstMultiXactId)
@@ -1597,9 +1597,9 @@ TruncateMultiXact(void)
return;
/*
- * We need to determine where to truncate MultiXactMember. If we
- * found a valid oldest MultiXactId, read its starting offset;
- * otherwise we use the nextOffset value we saved above.
+ * We need to determine where to truncate MultiXactMember. If we found a
+ * valid oldest MultiXactId, read its starting offset; otherwise we use
+ * the nextOffset value we saved above.
*/
if (oldestMXact == nextMXact)
oldestOffset = nextOffset;
@@ -1608,7 +1608,7 @@ TruncateMultiXact(void)
int pageno;
int slotno;
int entryno;
- MultiXactOffset *offptr;
+ MultiXactOffset *offptr;
LWLockAcquire(MultiXactOffsetControlLock, LW_EXCLUSIVE);
@@ -1624,8 +1624,8 @@ TruncateMultiXact(void)
}
/*
- * The cutoff point is the start of the segment containing oldestMXact.
- * We pass the *page* containing oldestMXact to SimpleLruTruncate.
+ * The cutoff point is the start of the segment containing oldestMXact. We
+ * pass the *page* containing oldestMXact to SimpleLruTruncate.
*/
cutoffPage = MultiXactIdToOffsetPage(oldestMXact);
@@ -1677,8 +1677,8 @@ MultiXactOffsetPagePrecedes(int page1, int page2)
static bool
MultiXactMemberPagePrecedes(int page1, int page2)
{
- MultiXactOffset offset1;
- MultiXactOffset offset2;
+ MultiXactOffset offset1;
+ MultiXactOffset offset2;
offset1 = ((MultiXactOffset) page1) * MULTIXACT_MEMBERS_PER_PAGE;
offset2 = ((MultiXactOffset) page2) * MULTIXACT_MEMBERS_PER_PAGE;
@@ -1695,7 +1695,7 @@ MultiXactMemberPagePrecedes(int page1, int page2)
static bool
MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
{
- int32 diff = (int32) (multi1 - multi2);
+ int32 diff = (int32) (multi1 - multi2);
return (diff < 0);
}
@@ -1706,7 +1706,7 @@ MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
static bool
MultiXactOffsetPrecedes(MultiXactOffset offset1, MultiXactOffset offset2)
{
- int32 diff = (int32) (offset1 - offset2);
+ int32 diff = (int32) (offset1 - offset2);
return (diff < 0);
}
@@ -1783,9 +1783,9 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
MultiXactAdvanceNextMXact(xlrec->mid + 1, xlrec->moff + xlrec->nxids);
/*
- * Make sure nextXid is beyond any XID mentioned in the record.
- * This should be unnecessary, since any XID found here ought to
- * have other evidence in the XLOG, but let's be safe.
+ * Make sure nextXid is beyond any XID mentioned in the record. This
+ * should be unnecessary, since any XID found here ought to have other
+ * evidence in the XLOG, but let's be safe.
*/
max_xid = record->xl_xid;
for (i = 0; i < xlrec->nxids; i++)
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index 67d9d3f54f..5891890b76 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -48,7 +48,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.27 2005/08/20 23:26:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.28 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -186,8 +186,8 @@ SimpleLruInit(SlruCtl ctl, const char *name,
Assert(found);
/*
- * Initialize the unshared control struct, including directory path.
- * We assume caller set PagePrecedes.
+ * Initialize the unshared control struct, including directory path. We
+ * assume caller set PagePrecedes.
*/
ctl->shared = shared;
ctl->do_fsync = true; /* default behavior */
@@ -351,11 +351,11 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
LWLockAcquire(shared->buffer_locks[slotno], LW_EXCLUSIVE);
/*
- * Check to see if someone else already did the write, or took the
- * buffer away from us. If so, do nothing. NOTE: we really should
- * never see WRITE_IN_PROGRESS here, since that state should only
- * occur while the writer is holding the buffer lock. But accept it
- * so that we have a recovery path if a writer aborts.
+ * Check to see if someone else already did the write, or took the buffer
+ * away from us. If so, do nothing. NOTE: we really should never see
+ * WRITE_IN_PROGRESS here, since that state should only occur while the
+ * writer is holding the buffer lock. But accept it so that we have a
+ * recovery path if a writer aborts.
*/
if (shared->page_number[slotno] != pageno ||
(shared->page_status[slotno] != SLRU_PAGE_DIRTY &&
@@ -368,15 +368,14 @@ SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata)
/*
* Mark the slot write-busy. After this point, a transaction status
- * update on this page will mark it dirty again. NB: we are assuming
- * that read/write of the page status field is atomic, since we change
- * the state while not holding control lock. However, we cannot set
- * this state any sooner, or we'd possibly fool a previous writer into
- * thinking he's successfully dumped the page when he hasn't.
- * (Scenario: other writer starts, page is redirtied, we come along
- * and set WRITE_IN_PROGRESS again, other writer completes and sets
- * CLEAN because redirty info has been lost, then we think it's clean
- * too.)
+ * update on this page will mark it dirty again. NB: we are assuming that
+ * read/write of the page status field is atomic, since we change the
+ * state while not holding control lock. However, we cannot set this
+ * state any sooner, or we'd possibly fool a previous writer into thinking
+ * he's successfully dumped the page when he hasn't. (Scenario: other
+ * writer starts, page is redirtied, we come along and set
+ * WRITE_IN_PROGRESS again, other writer completes and sets CLEAN because
+ * redirty info has been lost, then we think it's clean too.)
*/
shared->page_status[slotno] = SLRU_PAGE_WRITE_IN_PROGRESS;
@@ -436,8 +435,8 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
* In a crash-and-restart situation, it's possible for us to receive
* commands to set the commit status of transactions whose bits are in
* already-truncated segments of the commit log (see notes in
- * SlruPhysicalWritePage). Hence, if we are InRecovery, allow the
- * case where the file doesn't exist, and return zeroes instead.
+ * SlruPhysicalWritePage). Hence, if we are InRecovery, allow the case
+ * where the file doesn't exist, and return zeroes instead.
*/
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0)
@@ -528,17 +527,16 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
{
/*
* If the file doesn't already exist, we should create it. It is
- * possible for this to need to happen when writing a page that's
- * not first in its segment; we assume the OS can cope with that.
- * (Note: it might seem that it'd be okay to create files only
- * when SimpleLruZeroPage is called for the first page of a
- * segment. However, if after a crash and restart the REDO logic
- * elects to replay the log from a checkpoint before the latest
- * one, then it's possible that we will get commands to set
- * transaction status of transactions that have already been
- * truncated from the commit log. Easiest way to deal with that is
- * to accept references to nonexistent files here and in
- * SlruPhysicalReadPage.)
+ * possible for this to need to happen when writing a page that's not
+ * first in its segment; we assume the OS can cope with that. (Note:
+ * it might seem that it'd be okay to create files only when
+ * SimpleLruZeroPage is called for the first page of a segment.
+ * However, if after a crash and restart the REDO logic elects to
+ * replay the log from a checkpoint before the latest one, then it's
+ * possible that we will get commands to set transaction status of
+ * transactions that have already been truncated from the commit log.
+ * Easiest way to deal with that is to accept references to
+ * nonexistent files here and in SlruPhysicalReadPage.)
*/
SlruFileName(ctl, path, segno);
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
@@ -635,49 +633,49 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
case SLRU_OPEN_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
+ errmsg("could not access status of transaction %u", xid),
errdetail("could not open file \"%s\": %m",
path)));
break;
case SLRU_CREATE_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
+ errmsg("could not access status of transaction %u", xid),
errdetail("could not create file \"%s\": %m",
path)));
break;
case SLRU_SEEK_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
- errdetail("could not seek in file \"%s\" to offset %u: %m",
- path, offset)));
+ errmsg("could not access status of transaction %u", xid),
+ errdetail("could not seek in file \"%s\" to offset %u: %m",
+ path, offset)));
break;
case SLRU_READ_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
- errdetail("could not read from file \"%s\" at offset %u: %m",
- path, offset)));
+ errmsg("could not access status of transaction %u", xid),
+ errdetail("could not read from file \"%s\" at offset %u: %m",
+ path, offset)));
break;
case SLRU_WRITE_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
- errdetail("could not write to file \"%s\" at offset %u: %m",
- path, offset)));
+ errmsg("could not access status of transaction %u", xid),
+ errdetail("could not write to file \"%s\" at offset %u: %m",
+ path, offset)));
break;
case SLRU_FSYNC_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
+ errmsg("could not access status of transaction %u", xid),
errdetail("could not fsync file \"%s\": %m",
path)));
break;
case SLRU_CLOSE_FAILED:
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not access status of transaction %u", xid),
+ errmsg("could not access status of transaction %u", xid),
errdetail("could not close file \"%s\": %m",
path)));
break;
@@ -723,8 +721,8 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
}
/*
- * If we find any EMPTY slot, just select that one. Else locate
- * the least-recently-used slot that isn't the latest page.
+ * If we find any EMPTY slot, just select that one. Else locate the
+ * least-recently-used slot that isn't the latest page.
*/
for (slotno = 0; slotno < NUM_SLRU_BUFFERS; slotno++)
{
@@ -745,10 +743,10 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
return bestslot;
/*
- * We need to do I/O. Normal case is that we have to write it
- * out, but it's possible in the worst case to have selected a
- * read-busy page. In that case we use SimpleLruReadPage to wait
- * for the read to complete.
+ * We need to do I/O. Normal case is that we have to write it out,
+ * but it's possible in the worst case to have selected a read-busy
+ * page. In that case we use SimpleLruReadPage to wait for the read
+ * to complete.
*/
if (shared->page_status[bestslot] == SLRU_PAGE_READ_IN_PROGRESS)
(void) SimpleLruReadPage(ctl, shared->page_number[bestslot],
@@ -757,9 +755,9 @@ SlruSelectLRUPage(SlruCtl ctl, int pageno)
SimpleLruWritePage(ctl, bestslot, NULL);
/*
- * Now loop back and try again. This is the easiest way of
- * dealing with corner cases such as the victim page being
- * re-dirtied while we wrote it.
+ * Now loop back and try again. This is the easiest way of dealing
+ * with corner cases such as the victim page being re-dirtied while we
+ * wrote it.
*/
}
}
@@ -789,9 +787,9 @@ SimpleLruFlush(SlruCtl ctl, bool checkpoint)
SimpleLruWritePage(ctl, slotno, &fdata);
/*
- * When called during a checkpoint, we cannot assert that the slot
- * is clean now, since another process might have re-dirtied it
- * already. That's okay.
+ * When called during a checkpoint, we cannot assert that the slot is
+ * clean now, since another process might have re-dirtied it already.
+ * That's okay.
*/
Assert(checkpoint ||
shared->page_status[slotno] == SLRU_PAGE_EMPTY ||
@@ -841,10 +839,10 @@ SimpleLruTruncate(SlruCtl ctl, int cutoffPage)
cutoffPage -= cutoffPage % SLRU_PAGES_PER_SEGMENT;
/*
- * Scan shared memory and remove any pages preceding the cutoff page,
- * to ensure we won't rewrite them later. (Since this is normally
- * called in or just after a checkpoint, any dirty pages should have
- * been flushed already ... we're just being extra careful here.)
+ * Scan shared memory and remove any pages preceding the cutoff page, to
+ * ensure we won't rewrite them later. (Since this is normally called in
+ * or just after a checkpoint, any dirty pages should have been flushed
+ * already ... we're just being extra careful here.)
*/
LWLockAcquire(shared->ControlLock, LW_EXCLUSIVE);
@@ -852,16 +850,16 @@ restart:;
/*
* While we are holding the lock, make an important safety check: the
- * planned cutoff point must be <= the current endpoint page.
- * Otherwise we have already wrapped around, and proceeding with the
- * truncation would risk removing the current segment.
+ * planned cutoff point must be <= the current endpoint page. Otherwise we
+ * have already wrapped around, and proceeding with the truncation would
+ * risk removing the current segment.
*/
if (ctl->PagePrecedes(shared->latest_page_number, cutoffPage))
{
LWLockRelease(shared->ControlLock);
ereport(LOG,
- (errmsg("could not truncate directory \"%s\": apparent wraparound",
- ctl->Dir)));
+ (errmsg("could not truncate directory \"%s\": apparent wraparound",
+ ctl->Dir)));
return;
}
@@ -882,9 +880,9 @@ restart:;
}
/*
- * Hmm, we have (or may have) I/O operations acting on the page,
- * so we've got to wait for them to finish and then start again.
- * This is the same logic as in SlruSelectLRUPage.
+ * Hmm, we have (or may have) I/O operations acting on the page, so
+ * we've got to wait for them to finish and then start again. This is
+ * the same logic as in SlruSelectLRUPage.
*/
if (shared->page_status[slotno] == SLRU_PAGE_READ_IN_PROGRESS)
(void) SimpleLruReadPage(ctl, shared->page_number[slotno],
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 9b45035036..7671eb6a45 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -22,7 +22,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.10 2005/08/20 23:26:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.11 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -234,9 +234,8 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
* initialize the currently-active page(s) to zeroes during startup.
- * Whenever we advance into a new page, ExtendSUBTRANS will likewise
- * zero the new page without regard to whatever was previously on
- * disk.
+ * Whenever we advance into a new page, ExtendSUBTRANS will likewise zero
+ * the new page without regard to whatever was previously on disk.
*/
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE);
@@ -262,8 +261,8 @@ ShutdownSUBTRANS(void)
/*
* Flush dirty SUBTRANS pages to disk
*
- * This is not actually necessary from a correctness point of view. We do
- * it merely as a debugging aid.
+ * This is not actually necessary from a correctness point of view. We do it
+ * merely as a debugging aid.
*/
SimpleLruFlush(SubTransCtl, false);
}
@@ -277,9 +276,9 @@ CheckPointSUBTRANS(void)
/*
* Flush dirty SUBTRANS pages to disk
*
- * This is not actually necessary from a correctness point of view. We do
- * it merely to improve the odds that writing of dirty pages is done
- * by the checkpoint process and not by backends.
+ * This is not actually necessary from a correctness point of view. We do it
+ * merely to improve the odds that writing of dirty pages is done by the
+ * checkpoint process and not by backends.
*/
SimpleLruFlush(SubTransCtl, true);
}
@@ -329,8 +328,8 @@ TruncateSUBTRANS(TransactionId oldestXact)
int cutoffPage;
/*
- * The cutoff point is the start of the segment containing oldestXact.
- * We pass the *page* containing oldestXact to SimpleLruTruncate.
+ * The cutoff point is the start of the segment containing oldestXact. We
+ * pass the *page* containing oldestXact to SimpleLruTruncate.
*/
cutoffPage = TransactionIdToPage(oldestXact);
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 5fa6f82daf..5985252052 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.65 2005/06/17 22:32:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.66 2005/10/15 02:49:09 momjian Exp $
*
* NOTES
* This file contains the high level access-method interface to the
@@ -54,8 +54,8 @@ TransactionLogFetch(TransactionId transactionId)
XidStatus xidstatus;
/*
- * Before going to the commit log manager, check our single item cache
- * to see if we didn't just check the transaction status a moment ago.
+ * Before going to the commit log manager, check our single item cache to
+ * see if we didn't just check the transaction status a moment ago.
*/
if (TransactionIdEquals(transactionId, cachedFetchXid))
return cachedFetchXidStatus;
@@ -78,8 +78,8 @@ TransactionLogFetch(TransactionId transactionId)
xidstatus = TransactionIdGetStatus(transactionId);
/*
- * DO NOT cache status for unfinished or sub-committed transactions!
- * We only cache status that is guaranteed not to change.
+ * DO NOT cache status for unfinished or sub-committed transactions! We
+ * only cache status that is guaranteed not to change.
*/
if (xidstatus != TRANSACTION_STATUS_IN_PROGRESS &&
xidstatus != TRANSACTION_STATUS_SUB_COMMITTED)
@@ -169,18 +169,18 @@ TransactionIdDidCommit(TransactionId transactionId)
return true;
/*
- * If it's marked subcommitted, we have to check the parent
- * recursively. However, if it's older than TransactionXmin, we can't
- * look at pg_subtrans; instead assume that the parent crashed without
- * cleaning up its children.
+ * If it's marked subcommitted, we have to check the parent recursively.
+ * However, if it's older than TransactionXmin, we can't look at
+ * pg_subtrans; instead assume that the parent crashed without cleaning up
+ * its children.
*
- * Originally we Assert'ed that the result of SubTransGetParent was
- * not zero. However with the introduction of prepared transactions,
- * there can be a window just after database startup where we do not
- * have complete knowledge in pg_subtrans of the transactions after
- * TransactionXmin. StartupSUBTRANS() has ensured that any missing
- * information will be zeroed. Since this case should not happen under
- * normal conditions, it seems reasonable to emit a WARNING for it.
+ * Originally we Assert'ed that the result of SubTransGetParent was not zero.
+ * However with the introduction of prepared transactions, there can be a
+ * window just after database startup where we do not have complete
+ * knowledge in pg_subtrans of the transactions after TransactionXmin.
+ * StartupSUBTRANS() has ensured that any missing information will be
+ * zeroed. Since this case should not happen under normal conditions, it
+ * seems reasonable to emit a WARNING for it.
*/
if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED)
{
@@ -225,10 +225,10 @@ TransactionIdDidAbort(TransactionId transactionId)
return true;
/*
- * If it's marked subcommitted, we have to check the parent
- * recursively. However, if it's older than TransactionXmin, we can't
- * look at pg_subtrans; instead assume that the parent crashed without
- * cleaning up its children.
+ * If it's marked subcommitted, we have to check the parent recursively.
+ * However, if it's older than TransactionXmin, we can't look at
+ * pg_subtrans; instead assume that the parent crashed without cleaning up
+ * its children.
*/
if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED)
{
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 05590da14e..0ece348e18 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.14 2005/10/13 22:55:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.15 2005/10/15 02:49:09 momjian Exp $
*
* NOTES
* Each global transaction is associated with a global transaction
@@ -64,7 +64,7 @@
#define TWOPHASE_DIR "pg_twophase"
/* GUC variable, can't be changed after startup */
-int max_prepared_xacts = 5;
+int max_prepared_xacts = 5;
/*
* This struct describes one global transaction that is in prepared state
@@ -97,7 +97,7 @@ int max_prepared_xacts = 5;
* entry will remain in prepXacts until recycled. We can detect recyclable
* entries by checking for valid = false and locking_xid no longer active.
*
- * typedef struct GlobalTransactionData *GlobalTransaction appears in
+ * typedef struct GlobalTransactionData *GlobalTransaction appears in
* twophase.h
*/
#define GIDSIZE 200
@@ -105,12 +105,12 @@ int max_prepared_xacts = 5;
typedef struct GlobalTransactionData
{
PGPROC proc; /* dummy proc */
- TimestampTz prepared_at; /* time of preparation */
+ TimestampTz prepared_at; /* time of preparation */
XLogRecPtr prepare_lsn; /* XLOG offset of prepare record */
Oid owner; /* ID of user that executed the xact */
TransactionId locking_xid; /* top-level XID of backend working on xact */
bool valid; /* TRUE if fully prepared */
- char gid[GIDSIZE]; /* The GID assigned to the prepared xact */
+ char gid[GIDSIZE]; /* The GID assigned to the prepared xact */
} GlobalTransactionData;
/*
@@ -123,30 +123,30 @@ typedef struct TwoPhaseStateData
SHMEM_OFFSET freeGXacts;
/* Number of valid prepXacts entries. */
- int numPrepXacts;
+ int numPrepXacts;
/*
* There are max_prepared_xacts items in this array, but C wants a
* fixed-size array.
*/
- GlobalTransaction prepXacts[1]; /* VARIABLE LENGTH ARRAY */
+ GlobalTransaction prepXacts[1]; /* VARIABLE LENGTH ARRAY */
} TwoPhaseStateData; /* VARIABLE LENGTH STRUCT */
static TwoPhaseStateData *TwoPhaseState;
static void RecordTransactionCommitPrepared(TransactionId xid,
- int nchildren,
- TransactionId *children,
- int nrels,
- RelFileNode *rels);
+ int nchildren,
+ TransactionId *children,
+ int nrels,
+ RelFileNode *rels);
static void RecordTransactionAbortPrepared(TransactionId xid,
- int nchildren,
- TransactionId *children,
- int nrels,
- RelFileNode *rels);
+ int nchildren,
+ TransactionId *children,
+ int nrels,
+ RelFileNode *rels);
static void ProcessRecords(char *bufptr, TransactionId xid,
- const TwoPhaseCallback callbacks[]);
+ const TwoPhaseCallback callbacks[]);
/*
@@ -171,7 +171,7 @@ TwoPhaseShmemSize(void)
void
TwoPhaseShmemInit(void)
{
- bool found;
+ bool found;
TwoPhaseState = ShmemInitStruct("Prepared Transaction Table",
TwoPhaseShmemSize(),
@@ -190,7 +190,7 @@ TwoPhaseShmemInit(void)
*/
gxacts = (GlobalTransaction)
((char *) TwoPhaseState +
- MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) +
+ MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) +
sizeof(GlobalTransaction) * max_prepared_xacts));
for (i = 0; i < max_prepared_xacts; i++)
{
@@ -205,7 +205,7 @@ TwoPhaseShmemInit(void)
/*
* MarkAsPreparing
- * Reserve the GID for the given transaction.
+ * Reserve the GID for the given transaction.
*
* Internally, this creates a gxact struct and puts it into the active array.
* NOTE: this is also used when reloading a gxact after a crash; so avoid
@@ -215,8 +215,8 @@ GlobalTransaction
MarkAsPreparing(TransactionId xid, const char *gid,
TimestampTz prepared_at, Oid owner, Oid databaseid)
{
- GlobalTransaction gxact;
- int i;
+ GlobalTransaction gxact;
+ int i;
if (strlen(gid) >= GIDSIZE)
ereport(ERROR,
@@ -227,10 +227,9 @@ MarkAsPreparing(TransactionId xid, const char *gid,
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
/*
- * First, find and recycle any gxacts that failed during prepare.
- * We do this partly to ensure we don't mistakenly say their GIDs
- * are still reserved, and partly so we don't fail on out-of-slots
- * unnecessarily.
+ * First, find and recycle any gxacts that failed during prepare. We do
+ * this partly to ensure we don't mistakenly say their GIDs are still
+ * reserved, and partly so we don't fail on out-of-slots unnecessarily.
*/
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
@@ -360,13 +359,13 @@ MarkAsPrepared(GlobalTransaction gxact)
static GlobalTransaction
LockGXact(const char *gid, Oid user)
{
- int i;
+ int i;
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
- GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
+ GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
/* Ignore not-yet-valid GIDs */
if (!gxact->valid)
@@ -380,15 +379,15 @@ LockGXact(const char *gid, Oid user)
if (TransactionIdIsActive(gxact->locking_xid))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("prepared transaction with identifier \"%s\" is busy",
- gid)));
+ errmsg("prepared transaction with identifier \"%s\" is busy",
+ gid)));
gxact->locking_xid = InvalidTransactionId;
}
if (user != gxact->owner && !superuser_arg(user))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("permission denied to finish prepared transaction"),
+ errmsg("permission denied to finish prepared transaction"),
errhint("Must be superuser or the user that prepared the transaction.")));
/* OK for me to lock it */
@@ -403,8 +402,8 @@ LockGXact(const char *gid, Oid user)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("prepared transaction with identifier \"%s\" does not exist",
- gid)));
+ errmsg("prepared transaction with identifier \"%s\" does not exist",
+ gid)));
/* NOTREACHED */
return NULL;
@@ -419,7 +418,7 @@ LockGXact(const char *gid, Oid user)
static void
RemoveGXact(GlobalTransaction gxact)
{
- int i;
+ int i;
LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
@@ -449,7 +448,7 @@ RemoveGXact(GlobalTransaction gxact)
/*
* TransactionIdIsPrepared
* True iff transaction associated with the identifier is prepared
- * for two-phase commit
+ * for two-phase commit
*
* Note: only gxacts marked "valid" are considered; but notice we do not
* check the locking status.
@@ -459,14 +458,14 @@ RemoveGXact(GlobalTransaction gxact)
static bool
TransactionIdIsPrepared(TransactionId xid)
{
- bool result = false;
- int i;
+ bool result = false;
+ int i;
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
- GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
+ GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
if (gxact->valid && gxact->proc.xid == xid)
{
@@ -496,8 +495,8 @@ static int
GetPreparedTransactionList(GlobalTransaction *gxacts)
{
GlobalTransaction array;
- int num;
- int i;
+ int num;
+ int i;
LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
@@ -526,13 +525,13 @@ GetPreparedTransactionList(GlobalTransaction *gxacts)
typedef struct
{
GlobalTransaction array;
- int ngxacts;
- int currIdx;
+ int ngxacts;
+ int currIdx;
} Working_State;
/*
* pg_prepared_xact
- * Produce a view with one row per prepared transaction.
+ * Produce a view with one row per prepared transaction.
*
* This function is here so we don't have to export the
* GlobalTransactionData struct definition.
@@ -552,8 +551,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
funcctx = SRF_FIRSTCALL_INIT();
/*
- * Switch to memory context appropriate for multiple function
- * calls
+ * Switch to memory context appropriate for multiple function calls
*/
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
@@ -574,8 +572,8 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
funcctx->tuple_desc = BlessTupleDesc(tupdesc);
/*
- * Collect all the 2PC status information that we will format and
- * send out as a result set.
+ * Collect all the 2PC status information that we will format and send
+ * out as a result set.
*/
status = (Working_State *) palloc(sizeof(Working_State));
funcctx->user_fctx = (void *) status;
@@ -644,7 +642,7 @@ TwoPhaseGetDummyProc(TransactionId xid)
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
- GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
+ GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
if (gxact->proc.xid == xid)
{
@@ -665,7 +663,7 @@ TwoPhaseGetDummyProc(TransactionId xid)
}
/************************************************************************/
-/* State file support */
+/* State file support */
/************************************************************************/
#define TwoPhaseFilePath(path, xid) \
@@ -674,14 +672,14 @@ TwoPhaseGetDummyProc(TransactionId xid)
/*
* 2PC state file format:
*
- * 1. TwoPhaseFileHeader
- * 2. TransactionId[] (subtransactions)
+ * 1. TwoPhaseFileHeader
+ * 2. TransactionId[] (subtransactions)
* 3. RelFileNode[] (files to be deleted at commit)
* 4. RelFileNode[] (files to be deleted at abort)
- * 5. TwoPhaseRecordOnDisk
- * 6. ...
- * 7. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID)
- * 8. CRC32
+ * 5. TwoPhaseRecordOnDisk
+ * 6. ...
+ * 7. TwoPhaseRecordOnDisk (end sentinel, rmid == TWOPHASE_RM_END_ID)
+ * 8. CRC32
*
* Each segment except the final CRC32 is MAXALIGN'd.
*/
@@ -693,16 +691,16 @@ TwoPhaseGetDummyProc(TransactionId xid)
typedef struct TwoPhaseFileHeader
{
- uint32 magic; /* format identifier */
- uint32 total_len; /* actual file length */
- TransactionId xid; /* original transaction XID */
- Oid database; /* OID of database it was in */
- TimestampTz prepared_at; /* time of preparation */
- Oid owner; /* user running the transaction */
- int32 nsubxacts; /* number of following subxact XIDs */
- int32 ncommitrels; /* number of delete-on-commit rels */
- int32 nabortrels; /* number of delete-on-abort rels */
- char gid[GIDSIZE]; /* GID for transaction */
+ uint32 magic; /* format identifier */
+ uint32 total_len; /* actual file length */
+ TransactionId xid; /* original transaction XID */
+ Oid database; /* OID of database it was in */
+ TimestampTz prepared_at; /* time of preparation */
+ Oid owner; /* user running the transaction */
+ int32 nsubxacts; /* number of following subxact XIDs */
+ int32 ncommitrels; /* number of delete-on-commit rels */
+ int32 nabortrels; /* number of delete-on-abort rels */
+ char gid[GIDSIZE]; /* GID for transaction */
} TwoPhaseFileHeader;
/*
@@ -713,9 +711,9 @@ typedef struct TwoPhaseFileHeader
*/
typedef struct TwoPhaseRecordOnDisk
{
- uint32 len; /* length of rmgr data */
- TwoPhaseRmgrId rmid; /* resource manager for this record */
- uint16 info; /* flag bits for use by rmgr */
+ uint32 len; /* length of rmgr data */
+ TwoPhaseRmgrId rmid; /* resource manager for this record */
+ uint16 info; /* flag bits for use by rmgr */
} TwoPhaseRecordOnDisk;
/*
@@ -728,9 +726,9 @@ static struct xllist
{
XLogRecData *head; /* first data block in the chain */
XLogRecData *tail; /* last block in chain */
- uint32 bytes_free; /* free bytes left in tail block */
- uint32 total_len; /* total data bytes in chain */
-} records;
+ uint32 bytes_free; /* free bytes left in tail block */
+ uint32 total_len; /* total data bytes in chain */
+} records;
/*
@@ -744,7 +742,7 @@ static struct xllist
static void
save_state_data(const void *data, uint32 len)
{
- uint32 padlen = MAXALIGN(len);
+ uint32 padlen = MAXALIGN(len);
if (padlen > records.bytes_free)
{
@@ -772,7 +770,7 @@ save_state_data(const void *data, uint32 len)
void
StartPrepare(GlobalTransaction gxact)
{
- TransactionId xid = gxact->proc.xid;
+ TransactionId xid = gxact->proc.xid;
TwoPhaseFileHeader hdr;
TransactionId *children;
RelFileNode *commitrels;
@@ -833,13 +831,13 @@ StartPrepare(GlobalTransaction gxact)
void
EndPrepare(GlobalTransaction gxact)
{
- TransactionId xid = gxact->proc.xid;
+ TransactionId xid = gxact->proc.xid;
TwoPhaseFileHeader *hdr;
- char path[MAXPGPATH];
- XLogRecData *record;
- pg_crc32 statefile_crc;
- pg_crc32 bogus_crc;
- int fd;
+ char path[MAXPGPATH];
+ XLogRecData *record;
+ pg_crc32 statefile_crc;
+ pg_crc32 bogus_crc;
+ int fd;
/* Add the end sentinel to the list of 2PC records */
RegisterTwoPhaseRecord(TWOPHASE_RM_END_ID, 0,
@@ -853,10 +851,10 @@ EndPrepare(GlobalTransaction gxact)
/*
* Create the 2PC state file.
*
- * Note: because we use BasicOpenFile(), we are responsible for ensuring
- * the FD gets closed in any error exit path. Once we get into the
- * critical section, though, it doesn't matter since any failure causes
- * PANIC anyway.
+ * Note: because we use BasicOpenFile(), we are responsible for ensuring the
+ * FD gets closed in any error exit path. Once we get into the critical
+ * section, though, it doesn't matter since any failure causes PANIC
+ * anyway.
*/
TwoPhaseFilePath(path, xid);
@@ -887,11 +885,10 @@ EndPrepare(GlobalTransaction gxact)
FIN_CRC32(statefile_crc);
/*
- * Write a deliberately bogus CRC to the state file; this is just
- * paranoia to catch the case where four more bytes will run us out of
- * disk space.
+ * Write a deliberately bogus CRC to the state file; this is just paranoia
+ * to catch the case where four more bytes will run us out of disk space.
*/
- bogus_crc = ~ statefile_crc;
+ bogus_crc = ~statefile_crc;
if ((write(fd, &bogus_crc, sizeof(pg_crc32))) != sizeof(pg_crc32))
{
@@ -914,11 +911,11 @@ EndPrepare(GlobalTransaction gxact)
* The state file isn't valid yet, because we haven't written the correct
* CRC yet. Before we do that, insert entry in WAL and flush it to disk.
*
- * Between the time we have written the WAL entry and the time we write
- * out the correct state file CRC, we have an inconsistency: the xact is
- * prepared according to WAL but not according to our on-disk state.
- * We use a critical section to force a PANIC if we are unable to complete
- * the write --- then, WAL replay should repair the inconsistency. The
+ * Between the time we have written the WAL entry and the time we write out
+ * the correct state file CRC, we have an inconsistency: the xact is
+ * prepared according to WAL but not according to our on-disk state. We
+ * use a critical section to force a PANIC if we are unable to complete
+ * the write --- then, WAL replay should repair the inconsistency. The
* odds of a PANIC actually occurring should be very tiny given that we
* were able to write the bogus CRC above.
*
@@ -956,16 +953,16 @@ EndPrepare(GlobalTransaction gxact)
errmsg("could not close twophase state file: %m")));
/*
- * Mark the prepared transaction as valid. As soon as xact.c marks
- * MyProc as not running our XID (which it will do immediately after
- * this function returns), others can commit/rollback the xact.
+ * Mark the prepared transaction as valid. As soon as xact.c marks MyProc
+ * as not running our XID (which it will do immediately after this
+ * function returns), others can commit/rollback the xact.
*
* NB: a side effect of this is to make a dummy ProcArray entry for the
* prepared XID. This must happen before we clear the XID from MyProc,
* else there is a window where the XID is not running according to
- * TransactionIdInProgress, and onlookers would be entitled to assume
- * the xact crashed. Instead we have a window where the same XID
- * appears twice in ProcArray, which is OK.
+ * TransactionIdInProgress, and onlookers would be entitled to assume the
+ * xact crashed. Instead we have a window where the same XID appears
+ * twice in ProcArray, which is OK.
*/
MarkAsPrepared(gxact);
@@ -1011,9 +1008,10 @@ ReadTwoPhaseFile(TransactionId xid)
char *buf;
TwoPhaseFileHeader *hdr;
int fd;
- struct stat stat;
+ struct stat stat;
uint32 crc_offset;
- pg_crc32 calc_crc, file_crc;
+ pg_crc32 calc_crc,
+ file_crc;
TwoPhaseFilePath(path, xid);
@@ -1028,9 +1026,8 @@ ReadTwoPhaseFile(TransactionId xid)
}
/*
- * Check file length. We can determine a lower bound pretty easily.
- * We set an upper bound mainly to avoid palloc() failure on a corrupt
- * file.
+ * Check file length. We can determine a lower bound pretty easily. We
+ * set an upper bound mainly to avoid palloc() failure on a corrupt file.
*/
if (fstat(fd, &stat))
{
@@ -1107,17 +1104,17 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
{
GlobalTransaction gxact;
TransactionId xid;
- char *buf;
- char *bufptr;
+ char *buf;
+ char *bufptr;
TwoPhaseFileHeader *hdr;
TransactionId *children;
RelFileNode *commitrels;
RelFileNode *abortrels;
- int i;
+ int i;
/*
- * Validate the GID, and lock the GXACT to ensure that two backends
- * do not try to commit the same GID at once.
+ * Validate the GID, and lock the GXACT to ensure that two backends do not
+ * try to commit the same GID at once.
*/
gxact = LockGXact(gid, GetUserId());
xid = gxact->proc.xid;
@@ -1148,10 +1145,10 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
/*
* The order of operations here is critical: make the XLOG entry for
* commit or abort, then mark the transaction committed or aborted in
- * pg_clog, then remove its PGPROC from the global ProcArray (which
- * means TransactionIdIsInProgress will stop saying the prepared xact
- * is in progress), then run the post-commit or post-abort callbacks.
- * The callbacks will release the locks the transaction held.
+ * pg_clog, then remove its PGPROC from the global ProcArray (which means
+ * TransactionIdIsInProgress will stop saying the prepared xact is in
+ * progress), then run the post-commit or post-abort callbacks. The
+ * callbacks will release the locks the transaction held.
*/
if (isCommit)
RecordTransactionCommitPrepared(xid,
@@ -1165,18 +1162,18 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
ProcArrayRemove(&gxact->proc);
/*
- * In case we fail while running the callbacks, mark the gxact invalid
- * so no one else will try to commit/rollback, and so it can be recycled
- * properly later. It is still locked by our XID so it won't go away yet.
+ * In case we fail while running the callbacks, mark the gxact invalid so
+ * no one else will try to commit/rollback, and so it can be recycled
+ * properly later. It is still locked by our XID so it won't go away yet.
*
* (We assume it's safe to do this without taking TwoPhaseStateLock.)
*/
gxact->valid = false;
/*
- * We have to remove any files that were supposed to be dropped.
- * For consistency with the regular xact.c code paths, must do this
- * before releasing locks, so do it before running the callbacks.
+ * We have to remove any files that were supposed to be dropped. For
+ * consistency with the regular xact.c code paths, must do this before
+ * releasing locks, so do it before running the callbacks.
*
* NB: this code knows that we couldn't be dropping any temp rels ...
*/
@@ -1228,8 +1225,8 @@ ProcessRecords(char *bufptr, TransactionId xid,
bufptr += MAXALIGN(sizeof(TwoPhaseRecordOnDisk));
if (callbacks[record->rmid] != NULL)
- callbacks[record->rmid](xid, record->info,
- (void *) bufptr, record->len);
+ callbacks[record->rmid] (xid, record->info,
+ (void *) bufptr, record->len);
bufptr += MAXALIGN(record->len);
}
@@ -1244,15 +1241,15 @@ ProcessRecords(char *bufptr, TransactionId xid,
void
RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
{
- char path[MAXPGPATH];
+ char path[MAXPGPATH];
TwoPhaseFilePath(path, xid);
if (unlink(path))
if (errno != ENOENT || giveWarning)
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove two-phase state file \"%s\": %m",
- path)));
+ errmsg("could not remove two-phase state file \"%s\": %m",
+ path)));
}
/*
@@ -1300,8 +1297,8 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
}
/*
- * We must fsync the file because the end-of-replay checkpoint will
- * not do so, there being no GXACT in shared memory yet to tell it to.
+ * We must fsync the file because the end-of-replay checkpoint will not do
+ * so, there being no GXACT in shared memory yet to tell it to.
*/
if (pg_fsync(fd) != 0)
{
@@ -1343,15 +1340,15 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
int i;
/*
- * We don't want to hold the TwoPhaseStateLock while doing I/O,
- * so we grab it just long enough to make a list of the XIDs that
- * require fsyncing, and then do the I/O afterwards.
+ * We don't want to hold the TwoPhaseStateLock while doing I/O, so we grab
+ * it just long enough to make a list of the XIDs that require fsyncing,
+ * and then do the I/O afterwards.
*
- * This approach creates a race condition: someone else could delete
- * a GXACT between the time we release TwoPhaseStateLock and the time
- * we try to open its state file. We handle this by special-casing
- * ENOENT failures: if we see that, we verify that the GXACT is no
- * longer valid, and if so ignore the failure.
+ * This approach creates a race condition: someone else could delete a GXACT
+ * between the time we release TwoPhaseStateLock and the time we try to
+ * open its state file. We handle this by special-casing ENOENT failures:
+ * if we see that, we verify that the GXACT is no longer valid, and if so
+ * ignore the failure.
*/
if (max_prepared_xacts <= 0)
return; /* nothing to do */
@@ -1362,9 +1359,9 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
{
- GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
+ GlobalTransaction gxact = TwoPhaseState->prepXacts[i];
- if (gxact->valid &&
+ if (gxact->valid &&
XLByteLE(gxact->prepare_lsn, redo_horizon))
xids[nxids++] = gxact->proc.xid;
}
@@ -1374,7 +1371,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
for (i = 0; i < nxids; i++)
{
TransactionId xid = xids[i];
- int fd;
+ int fd;
TwoPhaseFilePath(path, xid);
@@ -1424,7 +1421,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
*
* We throw away any prepared xacts with main XID beyond nextXid --- if any
* are present, it suggests that the DBA has done a PITR recovery to an
- * earlier point in time without cleaning out pg_twophase. We dare not
+ * earlier point in time without cleaning out pg_twophase. We dare not
* try to recover such prepared xacts since they likely depend on database
* state that doesn't exist now.
*
@@ -1442,7 +1439,7 @@ PrescanPreparedTransactions(void)
{
TransactionId origNextXid = ShmemVariableCache->nextXid;
TransactionId result = origNextXid;
- DIR *cldir;
+ DIR *cldir;
struct dirent *clde;
cldir = AllocateDir(TWOPHASE_DIR);
@@ -1452,10 +1449,10 @@ PrescanPreparedTransactions(void)
strspn(clde->d_name, "0123456789ABCDEF") == 8)
{
TransactionId xid;
- char *buf;
- TwoPhaseFileHeader *hdr;
+ char *buf;
+ TwoPhaseFileHeader *hdr;
TransactionId *subxids;
- int i;
+ int i;
xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
@@ -1541,8 +1538,8 @@ PrescanPreparedTransactions(void)
void
RecoverPreparedTransactions(void)
{
- char dir[MAXPGPATH];
- DIR *cldir;
+ char dir[MAXPGPATH];
+ DIR *cldir;
struct dirent *clde;
snprintf(dir, MAXPGPATH, "%s", TWOPHASE_DIR);
@@ -1554,12 +1551,12 @@ RecoverPreparedTransactions(void)
strspn(clde->d_name, "0123456789ABCDEF") == 8)
{
TransactionId xid;
- char *buf;
- char *bufptr;
- TwoPhaseFileHeader *hdr;
+ char *buf;
+ char *bufptr;
+ TwoPhaseFileHeader *hdr;
TransactionId *subxids;
- GlobalTransaction gxact;
- int i;
+ GlobalTransaction gxact;
+ int i;
xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
@@ -1598,8 +1595,8 @@ RecoverPreparedTransactions(void)
/*
* Reconstruct subtrans state for the transaction --- needed
- * because pg_subtrans is not preserved over a restart. Note
- * that we are linking all the subtransactions directly to the
+ * because pg_subtrans is not preserved over a restart. Note that
+ * we are linking all the subtransactions directly to the
* top-level XID; there may originally have been a more complex
* hierarchy, but there's no need to restore that exactly.
*/
@@ -1609,12 +1606,12 @@ RecoverPreparedTransactions(void)
/*
* Recreate its GXACT and dummy PGPROC
*
- * Note: since we don't have the PREPARE record's WAL location
- * at hand, we leave prepare_lsn zeroes. This means the GXACT
- * will be fsync'd on every future checkpoint. We assume this
+ * Note: since we don't have the PREPARE record's WAL location at
+ * hand, we leave prepare_lsn zeroes. This means the GXACT will
+ * be fsync'd on every future checkpoint. We assume this
* situation is infrequent enough that the performance cost is
- * negligible (especially since we know the state file has
- * already been fsynced).
+ * negligible (especially since we know the state file has already
+ * been fsynced).
*/
gxact = MarkAsPreparing(xid, hdr->gid,
hdr->prepared_at,
@@ -1773,12 +1770,11 @@ RecordTransactionAbortPrepared(TransactionId xid,
XLogFlush(recptr);
/*
- * Mark the transaction aborted in clog. This is not absolutely
- * necessary but we may as well do it while we are here.
+ * Mark the transaction aborted in clog. This is not absolutely necessary
+ * but we may as well do it while we are here.
*/
TransactionIdAbort(xid);
TransactionIdAbortTree(nchildren, children);
END_CRIT_SECTION();
}
-
diff --git a/src/backend/access/transam/twophase_rmgr.c b/src/backend/access/transam/twophase_rmgr.c
index e78f8b2fbb..eab442404f 100644
--- a/src/backend/access/transam/twophase_rmgr.c
+++ b/src/backend/access/transam/twophase_rmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.1 2005/06/17 22:32:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.2 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,29 +21,29 @@
#include "utils/inval.h"
-const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] =
+const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] =
{
- NULL, /* END ID */
- lock_twophase_recover, /* Lock */
- NULL, /* Inval */
- NULL, /* flat file update */
- NULL /* notify/listen */
+ NULL, /* END ID */
+ lock_twophase_recover, /* Lock */
+ NULL, /* Inval */
+ NULL, /* flat file update */
+ NULL /* notify/listen */
};
-const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] =
+const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] =
{
- NULL, /* END ID */
- lock_twophase_postcommit, /* Lock */
- inval_twophase_postcommit, /* Inval */
- flatfile_twophase_postcommit, /* flat file update */
- notify_twophase_postcommit /* notify/listen */
+ NULL, /* END ID */
+ lock_twophase_postcommit, /* Lock */
+ inval_twophase_postcommit, /* Inval */
+ flatfile_twophase_postcommit, /* flat file update */
+ notify_twophase_postcommit /* notify/listen */
};
-const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] =
+const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] =
{
- NULL, /* END ID */
- lock_twophase_postabort, /* Lock */
- NULL, /* Inval */
- NULL, /* flat file update */
- NULL /* notify/listen */
+ NULL, /* END ID */
+ lock_twophase_postabort, /* Lock */
+ NULL, /* Inval */
+ NULL, /* flat file update */
+ NULL /* notify/listen */
};
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index 99d9213af0..bff646afb6 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -6,7 +6,7 @@
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.66 2005/08/22 16:59:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.67 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,21 +49,21 @@ GetNewTransactionId(bool isSubXact)
xid = ShmemVariableCache->nextXid;
/*
- * Check to see if it's safe to assign another XID. This protects
- * against catastrophic data loss due to XID wraparound. The basic
- * rules are: warn if we're past xidWarnLimit, and refuse to execute
- * transactions if we're past xidStopLimit, unless we are running in
- * a standalone backend (which gives an escape hatch to the DBA who
- * ignored all those warnings).
+ * Check to see if it's safe to assign another XID. This protects against
+ * catastrophic data loss due to XID wraparound. The basic rules are:
+ * warn if we're past xidWarnLimit, and refuse to execute transactions if
+ * we're past xidStopLimit, unless we are running in a standalone backend
+ * (which gives an escape hatch to the DBA who ignored all those
+ * warnings).
*
- * Test is coded to fall out as fast as possible during normal operation,
- * ie, when the warn limit is set and we haven't violated it.
+ * Test is coded to fall out as fast as possible during normal operation, ie,
+ * when the warn limit is set and we haven't violated it.
*/
if (TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidWarnLimit) &&
TransactionIdIsValid(ShmemVariableCache->xidWarnLimit))
{
if (IsUnderPostmaster &&
- TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidStopLimit))
+ TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidStopLimit))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("database is not accepting queries to avoid wraparound data loss in database \"%s\"",
@@ -72,20 +72,19 @@ GetNewTransactionId(bool isSubXact)
NameStr(ShmemVariableCache->limit_datname))));
else
ereport(WARNING,
- (errmsg("database \"%s\" must be vacuumed within %u transactions",
- NameStr(ShmemVariableCache->limit_datname),
- ShmemVariableCache->xidWrapLimit - xid),
- errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".",
- NameStr(ShmemVariableCache->limit_datname))));
+ (errmsg("database \"%s\" must be vacuumed within %u transactions",
+ NameStr(ShmemVariableCache->limit_datname),
+ ShmemVariableCache->xidWrapLimit - xid),
+ errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".",
+ NameStr(ShmemVariableCache->limit_datname))));
}
/*
* If we are allocating the first XID of a new page of the commit log,
- * zero out that commit-log page before returning. We must do this
- * while holding XidGenLock, else another xact could acquire and
- * commit a later XID before we zero the page. Fortunately, a page of
- * the commit log holds 32K or more transactions, so we don't have to
- * do this very often.
+ * zero out that commit-log page before returning. We must do this while
+ * holding XidGenLock, else another xact could acquire and commit a later
+ * XID before we zero the page. Fortunately, a page of the commit log
+ * holds 32K or more transactions, so we don't have to do this very often.
*
* Extend pg_subtrans too.
*/
@@ -93,45 +92,43 @@ GetNewTransactionId(bool isSubXact)
ExtendSUBTRANS(xid);
/*
- * Now advance the nextXid counter. This must not happen until after
- * we have successfully completed ExtendCLOG() --- if that routine
- * fails, we want the next incoming transaction to try it again. We
- * cannot assign more XIDs until there is CLOG space for them.
+ * Now advance the nextXid counter. This must not happen until after we
+ * have successfully completed ExtendCLOG() --- if that routine fails, we
+ * want the next incoming transaction to try it again. We cannot assign
+ * more XIDs until there is CLOG space for them.
*/
TransactionIdAdvance(ShmemVariableCache->nextXid);
/*
- * We must store the new XID into the shared PGPROC array before
- * releasing XidGenLock. This ensures that when GetSnapshotData calls
+ * We must store the new XID into the shared PGPROC array before releasing
+ * XidGenLock. This ensures that when GetSnapshotData calls
* ReadNewTransactionId, all active XIDs before the returned value of
- * nextXid are already present in PGPROC. Else we have a race
- * condition.
+ * nextXid are already present in PGPROC. Else we have a race condition.
*
* XXX by storing xid into MyProc without acquiring ProcArrayLock, we are
* relying on fetch/store of an xid to be atomic, else other backends
* might see a partially-set xid here. But holding both locks at once
- * would be a nasty concurrency hit (and in fact could cause a
- * deadlock against GetSnapshotData). So for now, assume atomicity.
- * Note that readers of PGPROC xid field should be careful to fetch
- * the value only once, rather than assume they can read it multiple
- * times and get the same answer each time.
+ * would be a nasty concurrency hit (and in fact could cause a deadlock
+ * against GetSnapshotData). So for now, assume atomicity. Note that
+ * readers of PGPROC xid field should be careful to fetch the value only
+ * once, rather than assume they can read it multiple times and get the
+ * same answer each time.
*
* The same comments apply to the subxact xid count and overflow fields.
*
- * A solution to the atomic-store problem would be to give each PGPROC
- * its own spinlock used only for fetching/storing that PGPROC's xid
- * and related fields.
+ * A solution to the atomic-store problem would be to give each PGPROC its
+ * own spinlock used only for fetching/storing that PGPROC's xid and
+ * related fields.
*
* If there's no room to fit a subtransaction XID into PGPROC, set the
* cache-overflowed flag instead. This forces readers to look in
- * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There
- * is a race-condition window, in that the new XID will not appear as
- * running until its parent link has been placed into pg_subtrans.
- * However, that will happen before anyone could possibly have a
- * reason to inquire about the status of the XID, so it seems OK.
- * (Snapshots taken during this window *will* include the parent XID,
- * so they will deliver the correct answer later on when someone does
- * have a reason to inquire.)
+ * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There is a
+ * race-condition window, in that the new XID will not appear as running
+ * until its parent link has been placed into pg_subtrans. However, that
+ * will happen before anyone could possibly have a reason to inquire about
+ * the status of the XID, so it seems OK. (Snapshots taken during this
+ * window *will* include the parent XID, so they will deliver the correct
+ * answer later on when someone does have a reason to inquire.)
*/
if (MyProc != NULL)
{
@@ -197,27 +194,26 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid,
xidWrapLimit += FirstNormalTransactionId;
/*
- * We'll refuse to continue assigning XIDs in interactive mode once
- * we get within 1M transactions of data loss. This leaves lots
- * of room for the DBA to fool around fixing things in a standalone
- * backend, while not being significant compared to total XID space.
- * (Note that since vacuuming requires one transaction per table
- * cleaned, we had better be sure there's lots of XIDs left...)
+ * We'll refuse to continue assigning XIDs in interactive mode once we get
+ * within 1M transactions of data loss. This leaves lots of room for the
+ * DBA to fool around fixing things in a standalone backend, while not
+ * being significant compared to total XID space. (Note that since
+ * vacuuming requires one transaction per table cleaned, we had better be
+ * sure there's lots of XIDs left...)
*/
xidStopLimit = xidWrapLimit - 1000000;
if (xidStopLimit < FirstNormalTransactionId)
xidStopLimit -= FirstNormalTransactionId;
/*
- * We'll start complaining loudly when we get within 10M transactions
- * of the stop point. This is kind of arbitrary, but if you let your
- * gas gauge get down to 1% of full, would you be looking for the
- * next gas station? We need to be fairly liberal about this number
- * because there are lots of scenarios where most transactions are
- * done by automatic clients that won't pay attention to warnings.
- * (No, we're not gonna make this configurable. If you know enough to
- * configure it, you know enough to not get in this kind of trouble in
- * the first place.)
+ * We'll start complaining loudly when we get within 10M transactions of
+ * the stop point. This is kind of arbitrary, but if you let your gas
+ * gauge get down to 1% of full, would you be looking for the next gas
+ * station? We need to be fairly liberal about this number because there
+ * are lots of scenarios where most transactions are done by automatic
+ * clients that won't pay attention to warnings. (No, we're not gonna make
+ * this configurable. If you know enough to configure it, you know enough
+ * to not get in this kind of trouble in the first place.)
*/
xidWarnLimit = xidStopLimit - 10000000;
if (xidWarnLimit < FirstNormalTransactionId)
@@ -234,16 +230,16 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid,
/* Log the info */
ereport(LOG,
- (errmsg("transaction ID wrap limit is %u, limited by database \"%s\"",
- xidWrapLimit, NameStr(*oldest_datname))));
+ (errmsg("transaction ID wrap limit is %u, limited by database \"%s\"",
+ xidWrapLimit, NameStr(*oldest_datname))));
/* Give an immediate warning if past the wrap warn point */
if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit))
ereport(WARNING,
- (errmsg("database \"%s\" must be vacuumed within %u transactions",
- NameStr(*oldest_datname),
- xidWrapLimit - curXid),
- errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".",
- NameStr(*oldest_datname))));
+ (errmsg("database \"%s\" must be vacuumed within %u transactions",
+ NameStr(*oldest_datname),
+ xidWrapLimit - curXid),
+ errhint("To avoid a database shutdown, execute a full-database VACUUM in \"%s\".",
+ NameStr(*oldest_datname))));
}
@@ -272,11 +268,11 @@ GetNewObjectId(void)
* right after a wrap occurs, so as to avoid a possibly large number of
* iterations in GetNewOid.) Note we are relying on unsigned comparison.
*
- * During initdb, we start the OID generator at FirstBootstrapObjectId,
- * so we only enforce wrapping to that point when in bootstrap or
- * standalone mode. The first time through this routine after normal
- * postmaster start, the counter will be forced up to FirstNormalObjectId.
- * This mechanism leaves the OIDs between FirstBootstrapObjectId and
+ * During initdb, we start the OID generator at FirstBootstrapObjectId, so we
+ * only enforce wrapping to that point when in bootstrap or standalone
+ * mode. The first time through this routine after normal postmaster
+ * start, the counter will be forced up to FirstNormalObjectId. This
+ * mechanism leaves the OIDs between FirstBootstrapObjectId and
* FirstNormalObjectId available for automatic assignment during initdb,
* while ensuring they will never conflict with user-assigned OIDs.
*/
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index eabcb117cc..ea19e07564 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.214 2005/08/20 23:45:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.215 2005/10/15 02:49:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -110,15 +110,14 @@ typedef enum TBlockState
*/
typedef struct TransactionStateData
{
- TransactionId transactionId; /* my XID, or Invalid if none */
+ TransactionId transactionId; /* my XID, or Invalid if none */
SubTransactionId subTransactionId; /* my subxact ID */
char *name; /* savepoint name, if any */
int savepointLevel; /* savepoint level */
TransState state; /* low-level state */
TBlockState blockState; /* high-level state */
int nestingLevel; /* nest depth */
- MemoryContext curTransactionContext; /* my xact-lifetime
- * context */
+ MemoryContext curTransactionContext; /* my xact-lifetime context */
ResourceOwner curTransactionOwner; /* my query resources */
List *childXids; /* subcommitted child XIDs */
Oid currentUser; /* subxact start current_user */
@@ -219,8 +218,8 @@ static void AtStart_Memory(void);
static void AtStart_ResourceOwner(void);
static void CallXactCallbacks(XactEvent event);
static void CallSubXactCallbacks(SubXactEvent event,
- SubTransactionId mySubid,
- SubTransactionId parentSubid);
+ SubTransactionId mySubid,
+ SubTransactionId parentSubid);
static void CleanupTransaction(void);
static void CommitTransaction(void);
static void RecordTransactionAbort(void);
@@ -349,18 +348,18 @@ AssignSubTransactionId(TransactionState s)
/*
* Generate a new Xid and record it in PG_PROC and pg_subtrans.
*
- * NB: we must make the subtrans entry BEFORE the Xid appears anywhere
- * in shared storage other than PG_PROC; because if there's no room for
- * it in PG_PROC, the subtrans entry is needed to ensure that other
- * backends see the Xid as "running". See GetNewTransactionId.
+ * NB: we must make the subtrans entry BEFORE the Xid appears anywhere in
+ * shared storage other than PG_PROC; because if there's no room for it in
+ * PG_PROC, the subtrans entry is needed to ensure that other backends see
+ * the Xid as "running". See GetNewTransactionId.
*/
s->transactionId = GetNewTransactionId(true);
SubTransSetParent(s->transactionId, s->parent->transactionId);
/*
- * Acquire lock on the transaction XID. (We assume this cannot block.)
- * We have to be sure that the lock is assigned to the transaction's
+ * Acquire lock on the transaction XID. (We assume this cannot block.) We
+ * have to be sure that the lock is assigned to the transaction's
* ResourceOwner.
*/
currentOwner = CurrentResourceOwner;
@@ -453,22 +452,22 @@ TransactionIdIsCurrentTransactionId(TransactionId xid)
/*
* We always say that BootstrapTransactionId is "not my transaction ID"
- * even when it is (ie, during bootstrap). Along with the fact that
+ * even when it is (ie, during bootstrap). Along with the fact that
* transam.c always treats BootstrapTransactionId as already committed,
- * this causes the tqual.c routines to see all tuples as committed,
- * which is what we need during bootstrap. (Bootstrap mode only inserts
- * tuples, it never updates or deletes them, so all tuples can be presumed
- * good immediately.)
+ * this causes the tqual.c routines to see all tuples as committed, which
+ * is what we need during bootstrap. (Bootstrap mode only inserts tuples,
+ * it never updates or deletes them, so all tuples can be presumed good
+ * immediately.)
*/
if (xid == BootstrapTransactionId)
return false;
/*
- * We will return true for the Xid of the current subtransaction, any
- * of its subcommitted children, any of its parents, or any of their
- * previously subcommitted children. However, a transaction being
- * aborted is no longer "current", even though it may still have an
- * entry on the state stack.
+ * We will return true for the Xid of the current subtransaction, any of
+ * its subcommitted children, any of its parents, or any of their
+ * previously subcommitted children. However, a transaction being aborted
+ * is no longer "current", even though it may still have an entry on the
+ * state stack.
*/
for (s = CurrentTransactionState; s != NULL; s = s->parent)
{
@@ -498,12 +497,12 @@ void
CommandCounterIncrement(void)
{
currentCommandId += 1;
- if (currentCommandId == FirstCommandId) /* check for overflow */
+ if (currentCommandId == FirstCommandId) /* check for overflow */
{
currentCommandId -= 1;
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("cannot have more than 2^32-1 commands in a transaction")));
+ errmsg("cannot have more than 2^32-1 commands in a transaction")));
}
/* Propagate new command ID into static snapshots, if set */
@@ -607,16 +606,15 @@ AtSubStart_Memory(void)
Assert(CurTransactionContext != NULL);
/*
- * Create a CurTransactionContext, which will be used to hold data
- * that survives subtransaction commit but disappears on
- * subtransaction abort. We make it a child of the immediate parent's
- * CurTransactionContext.
+ * Create a CurTransactionContext, which will be used to hold data that
+ * survives subtransaction commit but disappears on subtransaction abort.
+ * We make it a child of the immediate parent's CurTransactionContext.
*/
CurTransactionContext = AllocSetContextCreate(CurTransactionContext,
"CurTransactionContext",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
s->curTransactionContext = CurTransactionContext;
/* Make the CurTransactionContext active. */
@@ -634,8 +632,8 @@ AtSubStart_ResourceOwner(void)
Assert(s->parent != NULL);
/*
- * Create a resource owner for the subtransaction. We make it a child
- * of the immediate parent's resource owner.
+ * Create a resource owner for the subtransaction. We make it a child of
+ * the immediate parent's resource owner.
*/
s->curTransactionOwner =
ResourceOwnerCreate(s->parent->curTransactionOwner,
@@ -666,11 +664,10 @@ RecordTransactionCommit(void)
nchildren = xactGetCommittedChildren(&children);
/*
- * If we made neither any XLOG entries nor any temp-rel updates, and
- * have no files to be deleted, we can omit recording the transaction
- * commit at all. (This test includes the effects of subtransactions,
- * so the presence of committed subxacts need not alone force a
- * write.)
+ * If we made neither any XLOG entries nor any temp-rel updates, and have
+ * no files to be deleted, we can omit recording the transaction commit at
+ * all. (This test includes the effects of subtransactions, so the
+ * presence of committed subxacts need not alone force a write.)
*/
if (MyXactMadeXLogEntry || MyXactMadeTempRelUpdate || nrels > 0)
{
@@ -684,18 +681,17 @@ RecordTransactionCommit(void)
START_CRIT_SECTION();
/*
- * If our transaction made any transaction-controlled XLOG
- * entries, we need to lock out checkpoint start between writing
- * our XLOG record and updating pg_clog. Otherwise it is possible
- * for the checkpoint to set REDO after the XLOG record but fail
- * to flush the pg_clog update to disk, leading to loss of the
- * transaction commit if we crash a little later. Slightly klugy
- * fix for problem discovered 2004-08-10.
+ * If our transaction made any transaction-controlled XLOG entries, we
+ * need to lock out checkpoint start between writing our XLOG record
+ * and updating pg_clog. Otherwise it is possible for the checkpoint
+ * to set REDO after the XLOG record but fail to flush the pg_clog
+ * update to disk, leading to loss of the transaction commit if we
+ * crash a little later. Slightly klugy fix for problem discovered
+ * 2004-08-10.
*
- * (If it made no transaction-controlled XLOG entries, its XID
- * appears nowhere in permanent storage, so no one else will ever
- * care if it committed; so it doesn't matter if we lose the
- * commit flag.)
+ * (If it made no transaction-controlled XLOG entries, its XID appears
+ * nowhere in permanent storage, so no one else will ever care if it
+ * committed; so it doesn't matter if we lose the commit flag.)
*
* Note we only need a shared lock.
*/
@@ -704,8 +700,8 @@ RecordTransactionCommit(void)
LWLockAcquire(CheckpointStartLock, LW_SHARED);
/*
- * We only need to log the commit in XLOG if the transaction made
- * any transaction-controlled XLOG entries or will delete files.
+ * We only need to log the commit in XLOG if the transaction made any
+ * transaction-controlled XLOG entries or will delete files.
*/
if (madeTCentries || nrels > 0)
{
@@ -748,26 +744,26 @@ RecordTransactionCommit(void)
}
/*
- * We must flush our XLOG entries to disk if we made any XLOG
- * entries, whether in or out of transaction control. For
- * example, if we reported a nextval() result to the client, this
- * ensures that any XLOG record generated by nextval will hit the
- * disk before we report the transaction committed.
+ * We must flush our XLOG entries to disk if we made any XLOG entries,
+ * whether in or out of transaction control. For example, if we
+ * reported a nextval() result to the client, this ensures that any
+ * XLOG record generated by nextval will hit the disk before we report
+ * the transaction committed.
*
- * Note: if we generated a commit record above, MyXactMadeXLogEntry
- * will certainly be set now.
+ * Note: if we generated a commit record above, MyXactMadeXLogEntry will
+ * certainly be set now.
*/
if (MyXactMadeXLogEntry)
{
/*
* Sleep before flush! So we can flush more than one commit
- * records per single fsync. (The idea is some other backend
- * may do the XLogFlush while we're sleeping. This needs work
- * still, because on most Unixen, the minimum select() delay
- * is 10msec or more, which is way too long.)
+ * records per single fsync. (The idea is some other backend may
+ * do the XLogFlush while we're sleeping. This needs work still,
+ * because on most Unixen, the minimum select() delay is 10msec or
+ * more, which is way too long.)
*
- * We do not sleep if enableFsync is not turned on, nor if there
- * are fewer than CommitSiblings other backends with active
+ * We do not sleep if enableFsync is not turned on, nor if there are
+ * fewer than CommitSiblings other backends with active
* transactions.
*/
if (CommitDelay > 0 && enableFsync &&
@@ -778,14 +774,13 @@ RecordTransactionCommit(void)
}
/*
- * We must mark the transaction committed in clog if its XID
- * appears either in permanent rels or in local temporary rels. We
- * test this by seeing if we made transaction-controlled entries
- * *OR* local-rel tuple updates. Note that if we made only the
- * latter, we have not emitted an XLOG record for our commit, and
- * so in the event of a crash the clog update might be lost. This
- * is okay because no one else will ever care whether we
- * committed.
+ * We must mark the transaction committed in clog if its XID appears
+ * either in permanent rels or in local temporary rels. We test this
+ * by seeing if we made transaction-controlled entries *OR* local-rel
+ * tuple updates. Note that if we made only the latter, we have not
+ * emitted an XLOG record for our commit, and so in the event of a
+ * crash the clog update might be lost. This is okay because no one
+ * else will ever care whether we committed.
*/
if (madeTCentries || MyXactMadeTempRelUpdate)
{
@@ -833,9 +828,8 @@ static void
AtCommit_Memory(void)
{
/*
- * Now that we're "out" of a transaction, have the system allocate
- * things in the top memory context instead of per-transaction
- * contexts.
+ * Now that we're "out" of a transaction, have the system allocate things
+ * in the top memory context instead of per-transaction contexts.
*/
MemoryContextSwitchTo(TopMemoryContext);
@@ -870,9 +864,9 @@ AtSubCommit_Memory(void)
/*
* Ordinarily we cannot throw away the child's CurTransactionContext,
- * since the data it contains will be needed at upper commit. However,
- * if there isn't actually anything in it, we can throw it away. This
- * avoids a small memory leak in the common case of "trivial" subxacts.
+ * since the data it contains will be needed at upper commit. However, if
+ * there isn't actually anything in it, we can throw it away. This avoids
+ * a small memory leak in the common case of "trivial" subxacts.
*/
if (MemoryContextIsEmpty(s->curTransactionContext))
{
@@ -908,9 +902,10 @@ AtSubCommit_childXids(void)
{
s->parent->childXids = list_concat(s->parent->childXids,
s->childXids);
+
/*
- * list_concat doesn't free the list header for the second list;
- * do so here to avoid memory leakage (kluge)
+ * list_concat doesn't free the list header for the second list; do so
+ * here to avoid memory leakage (kluge)
*/
pfree(s->childXids);
s->childXids = NIL;
@@ -929,14 +924,14 @@ RecordSubTransactionCommit(void)
* We do not log the subcommit in XLOG; it doesn't matter until the
* top-level transaction commits.
*
- * We must mark the subtransaction subcommitted in clog if its XID
- * appears either in permanent rels or in local temporary rels. We
- * test this by seeing if we made transaction-controlled entries *OR*
- * local-rel tuple updates. (The test here actually covers the entire
- * transaction tree so far, so it may mark subtransactions that don't
- * really need it, but it's probably not worth being tenser. Note that
- * if a prior subtransaction dirtied these variables, then
- * RecordTransactionCommit will have to do the full pushup anyway...)
+ * We must mark the subtransaction subcommitted in clog if its XID appears
+ * either in permanent rels or in local temporary rels. We test this by
+ * seeing if we made transaction-controlled entries *OR* local-rel tuple
+ * updates. (The test here actually covers the entire transaction tree so
+ * far, so it may mark subtransactions that don't really need it, but it's
+ * probably not worth being tenser. Note that if a prior subtransaction
+ * dirtied these variables, then RecordTransactionCommit will have to do
+ * the full pushup anyway...)
*/
if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate)
{
@@ -974,9 +969,9 @@ RecordTransactionAbort(void)
/*
* If we made neither any transaction-controlled XLOG entries nor any
- * temp-rel updates, and are not going to delete any files, we can
- * omit recording the transaction abort at all. No one will ever care
- * that it aborted. (These tests cover our whole transaction tree.)
+ * temp-rel updates, and are not going to delete any files, we can omit
+ * recording the transaction abort at all. No one will ever care that it
+ * aborted. (These tests cover our whole transaction tree.)
*/
if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate || nrels > 0)
{
@@ -992,16 +987,16 @@ RecordTransactionAbort(void)
START_CRIT_SECTION();
/*
- * We only need to log the abort in XLOG if the transaction made
- * any transaction-controlled XLOG entries or will delete files.
- * (If it made no transaction-controlled XLOG entries, its XID
- * appears nowhere in permanent storage, so no one else will ever
- * care if it committed.)
+ * We only need to log the abort in XLOG if the transaction made any
+ * transaction-controlled XLOG entries or will delete files. (If it
+ * made no transaction-controlled XLOG entries, its XID appears
+ * nowhere in permanent storage, so no one else will ever care if it
+ * committed.)
*
- * We do not flush XLOG to disk unless deleting files, since the
- * default assumption after a crash would be that we aborted,
- * anyway. For the same reason, we don't need to worry about
- * interlocking against checkpoint start.
+ * We do not flush XLOG to disk unless deleting files, since the default
+ * assumption after a crash would be that we aborted, anyway. For the
+ * same reason, we don't need to worry about interlocking against
+ * checkpoint start.
*/
if (MyLastRecPtr.xrecoff != 0 || nrels > 0)
{
@@ -1047,8 +1042,8 @@ RecordTransactionAbort(void)
* Mark the transaction aborted in clog. This is not absolutely
* necessary but we may as well do it while we are here.
*
- * The ordering here isn't critical but it seems best to mark the
- * parent first. This assures an atomic transition of all the
+ * The ordering here isn't critical but it seems best to mark the parent
+ * first. This assures an atomic transition of all the
* subtransactions to aborted state from the point of view of
* concurrent TransactionIdDidAbort calls.
*/
@@ -1078,8 +1073,8 @@ AtAbort_Memory(void)
{
/*
* Make sure we are in a valid context (not a child of
- * TopTransactionContext...). Note that it is possible for this code
- * to be called when we aren't in a transaction at all; go directly to
+ * TopTransactionContext...). Note that it is possible for this code to
+ * be called when we aren't in a transaction at all; go directly to
* TopMemoryContext in that case.
*/
if (TopTransactionContext != NULL)
@@ -1087,8 +1082,8 @@ AtAbort_Memory(void)
MemoryContextSwitchTo(TopTransactionContext);
/*
- * We do not want to destroy the transaction's global state yet,
- * so we can't free any memory here.
+ * We do not want to destroy the transaction's global state yet, so we
+ * can't free any memory here.
*/
}
else
@@ -1114,8 +1109,8 @@ static void
AtAbort_ResourceOwner(void)
{
/*
- * Make sure we have a valid ResourceOwner, if possible (else it
- * will be NULL, which is OK)
+ * Make sure we have a valid ResourceOwner, if possible (else it will be
+ * NULL, which is OK)
*/
CurrentResourceOwner = TopTransactionResourceOwner;
}
@@ -1143,7 +1138,7 @@ AtSubAbort_childXids(void)
/*
* We keep the child-XID lists in TopTransactionContext (see
- * AtSubCommit_childXids). This means we'd better free the list
+ * AtSubCommit_childXids). This means we'd better free the list
* explicitly at abort to avoid leakage.
*/
list_free(s->childXids);
@@ -1168,11 +1163,11 @@ RecordSubTransactionAbort(void)
/*
* If we made neither any transaction-controlled XLOG entries nor any
- * temp-rel updates, and are not going to delete any files, we can
- * omit recording the transaction abort at all. No one will ever care
- * that it aborted. (These tests cover our whole transaction tree,
- * and therefore may mark subxacts that don't really need it, but it's
- * probably not worth being tenser.)
+ * temp-rel updates, and are not going to delete any files, we can omit
+ * recording the transaction abort at all. No one will ever care that it
+ * aborted. (These tests cover our whole transaction tree, and therefore
+ * may mark subxacts that don't really need it, but it's probably not
+ * worth being tenser.)
*
* In this case we needn't worry about marking subcommitted children as
* aborted, because they didn't mark themselves as subcommitted in the
@@ -1183,8 +1178,8 @@ RecordSubTransactionAbort(void)
START_CRIT_SECTION();
/*
- * We only need to log the abort in XLOG if the transaction made
- * any transaction-controlled XLOG entries or will delete files.
+ * We only need to log the abort in XLOG if the transaction made any
+ * transaction-controlled XLOG entries or will delete files.
*/
if (MyLastRecPtr.xrecoff != 0 || nrels > 0)
{
@@ -1238,11 +1233,10 @@ RecordSubTransactionAbort(void)
}
/*
- * We can immediately remove failed XIDs from PGPROC's cache of
- * running child XIDs. It's easiest to do it here while we have the
- * child XID array at hand, even though in the main-transaction case
- * the equivalent work happens just after return from
- * RecordTransactionAbort.
+ * We can immediately remove failed XIDs from PGPROC's cache of running
+ * child XIDs. It's easiest to do it here while we have the child XID
+ * array at hand, even though in the main-transaction case the equivalent
+ * work happens just after return from RecordTransactionAbort.
*/
XidCacheRemoveRunningXids(xid, nchildren, children);
@@ -1265,9 +1259,8 @@ static void
AtCleanup_Memory(void)
{
/*
- * Now that we're "out" of a transaction, have the system allocate
- * things in the top memory context instead of per-transaction
- * contexts.
+ * Now that we're "out" of a transaction, have the system allocate things
+ * in the top memory context instead of per-transaction contexts.
*/
MemoryContextSwitchTo(TopMemoryContext);
@@ -1304,9 +1297,9 @@ AtSubCleanup_Memory(void)
CurTransactionContext = s->parent->curTransactionContext;
/*
- * Delete the subxact local memory contexts. Its CurTransactionContext
- * can go too (note this also kills CurTransactionContexts from any
- * children of the subxact).
+ * Delete the subxact local memory contexts. Its CurTransactionContext can
+ * go too (note this also kills CurTransactionContexts from any children
+ * of the subxact).
*/
if (s->curTransactionContext)
MemoryContextDelete(s->curTransactionContext);
@@ -1344,11 +1337,10 @@ StartTransaction(void)
* start processing
*/
s->state = TRANS_START;
- s->transactionId = InvalidTransactionId; /* until assigned */
+ s->transactionId = InvalidTransactionId; /* until assigned */
/*
- * Make sure we've freed any old snapshot, and reset xact state
- * variables
+ * Make sure we've freed any old snapshot, and reset xact state variables
*/
FreeXactSnapshot();
XactIsoLevel = DefaultXactIsoLevel;
@@ -1386,10 +1378,10 @@ StartTransaction(void)
s->childXids = NIL;
/*
- * You might expect to see "s->currentUser = GetUserId();" here, but
- * you won't because it doesn't work during startup; the userid isn't
- * set yet during a backend's first transaction start. We only use
- * the currentUser field in sub-transaction state structs.
+ * You might expect to see "s->currentUser = GetUserId();" here, but you
+ * won't because it doesn't work during startup; the userid isn't set yet
+ * during a backend's first transaction start. We only use the
+ * currentUser field in sub-transaction state structs.
*
* prevXactReadOnly is also valid only in sub-transactions.
*/
@@ -1432,13 +1424,12 @@ CommitTransaction(void)
Assert(s->parent == NULL);
/*
- * Do pre-commit processing (most of this stuff requires database
- * access, and in fact could still cause an error...)
+ * Do pre-commit processing (most of this stuff requires database access,
+ * and in fact could still cause an error...)
*
- * It is possible for CommitHoldablePortals to invoke functions that
- * queue deferred triggers, and it's also possible that triggers create
- * holdable cursors. So we have to loop until there's nothing left to
- * do.
+ * It is possible for CommitHoldablePortals to invoke functions that queue
+ * deferred triggers, and it's also possible that triggers create holdable
+ * cursors. So we have to loop until there's nothing left to do.
*/
for (;;)
{
@@ -1525,19 +1516,19 @@ CommitTransaction(void)
}
/*
- * This is all post-commit cleanup. Note that if an error is raised
- * here, it's too late to abort the transaction. This should be just
+ * This is all post-commit cleanup. Note that if an error is raised here,
+ * it's too late to abort the transaction. This should be just
* noncritical resource releasing.
*
- * The ordering of operations is not entirely random. The idea is:
- * release resources visible to other backends (eg, files, buffer
- * pins); then release locks; then release backend-local resources. We
- * want to release locks at the point where any backend waiting for us
- * will see our transaction as being fully cleaned up.
+ * The ordering of operations is not entirely random. The idea is: release
+ * resources visible to other backends (eg, files, buffer pins); then
+ * release locks; then release backend-local resources. We want to release
+ * locks at the point where any backend waiting for us will see our
+ * transaction as being fully cleaned up.
*
- * Resources that can be associated with individual queries are handled
- * by the ResourceOwner mechanism. The other calls here are for
- * backend-wide state.
+ * Resources that can be associated with individual queries are handled by
+ * the ResourceOwner mechanism. The other calls here are for backend-wide
+ * state.
*/
CallXactCallbacks(XACT_EVENT_COMMIT);
@@ -1553,12 +1544,11 @@ CommitTransaction(void)
AtEOXact_RelationCache(true);
/*
- * Make catalog changes visible to all backends. This has to happen
- * after relcache references are dropped (see comments for
- * AtEOXact_RelationCache), but before locks are released (if anyone
- * is waiting for lock on a relation we've modified, we want them to
- * know about the catalog change before they start using the
- * relation).
+ * Make catalog changes visible to all backends. This has to happen after
+ * relcache references are dropped (see comments for
+ * AtEOXact_RelationCache), but before locks are released (if anyone is
+ * waiting for lock on a relation we've modified, we want them to know
+ * about the catalog change before they start using the relation).
*/
AtEOXact_Inval(true);
@@ -1621,10 +1611,10 @@ CommitTransaction(void)
static void
PrepareTransaction(void)
{
- TransactionState s = CurrentTransactionState;
- TransactionId xid = GetCurrentTransactionId();
- GlobalTransaction gxact;
- TimestampTz prepared_at;
+ TransactionState s = CurrentTransactionState;
+ TransactionId xid = GetCurrentTransactionId();
+ GlobalTransaction gxact;
+ TimestampTz prepared_at;
ShowTransactionState("PrepareTransaction");
@@ -1637,13 +1627,12 @@ PrepareTransaction(void)
Assert(s->parent == NULL);
/*
- * Do pre-commit processing (most of this stuff requires database
- * access, and in fact could still cause an error...)
+ * Do pre-commit processing (most of this stuff requires database access,
+ * and in fact could still cause an error...)
*
- * It is possible for PrepareHoldablePortals to invoke functions that
- * queue deferred triggers, and it's also possible that triggers create
- * holdable cursors. So we have to loop until there's nothing left to
- * do.
+ * It is possible for PrepareHoldablePortals to invoke functions that queue
+ * deferred triggers, and it's also possible that triggers create holdable
+ * cursors. So we have to loop until there's nothing left to do.
*/
for (;;)
{
@@ -1693,8 +1682,8 @@ PrepareTransaction(void)
BufmgrCommit();
/*
- * Reserve the GID for this transaction. This could fail if the
- * requested GID is invalid or already in use.
+ * Reserve the GID for this transaction. This could fail if the requested
+ * GID is invalid or already in use.
*/
gxact = MarkAsPreparing(xid, prepareGID, prepared_at,
GetUserId(), MyDatabaseId);
@@ -1707,14 +1696,14 @@ PrepareTransaction(void)
* want transaction abort to be able to clean up. (In particular, the
* AtPrepare routines may error out if they find cases they cannot
* handle.) State cleanup should happen in the PostPrepare routines
- * below. However, some modules can go ahead and clear state here
- * because they wouldn't do anything with it during abort anyway.
+ * below. However, some modules can go ahead and clear state here because
+ * they wouldn't do anything with it during abort anyway.
*
* Note: because the 2PC state file records will be replayed in the same
- * order they are made, the order of these calls has to match the order
- * in which we want things to happen during COMMIT PREPARED or
- * ROLLBACK PREPARED; in particular, pay attention to whether things
- * should happen before or after releasing the transaction's locks.
+ * order they are made, the order of these calls has to match the order in
+ * which we want things to happen during COMMIT PREPARED or ROLLBACK
+ * PREPARED; in particular, pay attention to whether things should happen
+ * before or after releasing the transaction's locks.
*/
StartPrepare(gxact);
@@ -1726,15 +1715,14 @@ PrepareTransaction(void)
/*
* Here is where we really truly prepare.
*
- * We have to record transaction prepares even if we didn't
- * make any updates, because the transaction manager might
- * get confused if we lose a global transaction.
+ * We have to record transaction prepares even if we didn't make any updates,
+ * because the transaction manager might get confused if we lose a global
+ * transaction.
*/
EndPrepare(gxact);
/*
- * Now we clean up backend-internal state and release internal
- * resources.
+ * Now we clean up backend-internal state and release internal resources.
*/
/* Break the chain of back-links in the XLOG records I output */
@@ -1743,9 +1731,9 @@ PrepareTransaction(void)
MyXactMadeTempRelUpdate = false;
/*
- * Let others know about no transaction in progress by me. This has
- * to be done *after* the prepared transaction has been marked valid,
- * else someone may think it is unlocked and recyclable.
+ * Let others know about no transaction in progress by me. This has to be
+ * done *after* the prepared transaction has been marked valid, else
+ * someone may think it is unlocked and recyclable.
*/
/* Lock ProcArrayLock because that's what GetSnapshotData uses. */
@@ -1762,7 +1750,7 @@ PrepareTransaction(void)
/*
* This is all post-transaction cleanup. Note that if an error is raised
* here, it's too late to abort the transaction. This should be just
- * noncritical resource releasing. See notes in CommitTransaction.
+ * noncritical resource releasing. See notes in CommitTransaction.
*/
CallXactCallbacks(XACT_EVENT_PREPARE);
@@ -1819,8 +1807,8 @@ PrepareTransaction(void)
s->childXids = NIL;
/*
- * done with 1st phase commit processing, set current transaction
- * state back to default
+ * done with 1st phase commit processing, set current transaction state
+ * back to default
*/
s->state = TRANS_DEFAULT;
@@ -1842,8 +1830,8 @@ AbortTransaction(void)
/*
* Release any LW locks we might be holding as quickly as possible.
* (Regular locks, however, must be held till we finish aborting.)
- * Releasing LW locks is critical since we might try to grab them
- * again while cleaning up!
+ * Releasing LW locks is critical since we might try to grab them again
+ * while cleaning up!
*/
LWLockReleaseAll();
@@ -1852,8 +1840,8 @@ AbortTransaction(void)
UnlockBuffers();
/*
- * Also clean up any open wait for lock, since the lock manager will
- * choke if we try to wait for another lock before doing this.
+ * Also clean up any open wait for lock, since the lock manager will choke
+ * if we try to wait for another lock before doing this.
*/
LockWaitCancel();
@@ -1866,8 +1854,8 @@ AbortTransaction(void)
Assert(s->parent == NULL);
/*
- * set the current transaction state information appropriately during
- * the abort processing
+ * set the current transaction state information appropriately during the
+ * abort processing
*/
s->state = TRANS_ABORT;
@@ -1876,15 +1864,14 @@ AbortTransaction(void)
AtAbort_ResourceOwner();
/*
- * Reset user id which might have been changed transiently. We cannot
- * use s->currentUser, since it may not be set yet; instead rely on
- * internal state of miscinit.c.
+ * Reset user id which might have been changed transiently. We cannot use
+ * s->currentUser, since it may not be set yet; instead rely on internal
+ * state of miscinit.c.
*
- * (Note: it is not necessary to restore session authorization here
- * because that can only be changed via GUC, and GUC will take care of
- * rolling it back if need be. However, an error within a SECURITY
- * DEFINER function could send control here with the wrong current
- * userid.)
+ * (Note: it is not necessary to restore session authorization here because
+ * that can only be changed via GUC, and GUC will take care of rolling it
+ * back if need be. However, an error within a SECURITY DEFINER function
+ * could send control here with the wrong current userid.)
*/
AtAbort_UserId();
@@ -1898,15 +1885,15 @@ AbortTransaction(void)
AtEOXact_UpdateFlatFiles(false);
/*
- * Advertise the fact that we aborted in pg_clog (assuming that we
- * got as far as assigning an XID to advertise).
+ * Advertise the fact that we aborted in pg_clog (assuming that we got as
+ * far as assigning an XID to advertise).
*/
if (TransactionIdIsValid(s->transactionId))
RecordTransactionAbort();
/*
- * Let others know about no transaction in progress by me. Note that
- * this must be done _before_ releasing locks we hold and _after_
+ * Let others know about no transaction in progress by me. Note that this
+ * must be done _before_ releasing locks we hold and _after_
* RecordTransactionAbort.
*/
if (MyProc != NULL)
@@ -2012,8 +1999,8 @@ StartTransactionCommand(void)
switch (s->blockState)
{
/*
- * if we aren't in a transaction block, we just do our usual
- * start transaction.
+ * if we aren't in a transaction block, we just do our usual start
+ * transaction.
*/
case TBLOCK_DEFAULT:
StartTransaction();
@@ -2021,23 +2008,23 @@ StartTransactionCommand(void)
break;
/*
- * We are somewhere in a transaction block or subtransaction
- * and about to start a new command. For now we do nothing,
- * but someday we may do command-local resource initialization.
- * (Note that any needed CommandCounterIncrement was done by
- * the previous CommitTransactionCommand.)
+ * We are somewhere in a transaction block or subtransaction and
+ * about to start a new command. For now we do nothing, but
+ * someday we may do command-local resource initialization. (Note
+ * that any needed CommandCounterIncrement was done by the
+ * previous CommitTransactionCommand.)
*/
case TBLOCK_INPROGRESS:
case TBLOCK_SUBINPROGRESS:
break;
/*
- * Here we are in a failed transaction block (one of
- * the commands caused an abort) so we do nothing but remain in
- * the abort state. Eventually we will get a ROLLBACK command
- * which will get us out of this state. (It is up to other
- * code to ensure that no commands other than ROLLBACK will be
- * processed in these states.)
+ * Here we are in a failed transaction block (one of the commands
+ * caused an abort) so we do nothing but remain in the abort
+ * state. Eventually we will get a ROLLBACK command which will
+ * get us out of this state. (It is up to other code to ensure
+ * that no commands other than ROLLBACK will be processed in these
+ * states.)
*/
case TBLOCK_ABORT:
case TBLOCK_SUBABORT:
@@ -2099,10 +2086,10 @@ CommitTransactionCommand(void)
break;
/*
- * We are completing a "BEGIN TRANSACTION" command, so we
- * change to the "transaction block in progress" state and
- * return. (We assume the BEGIN did nothing to the database,
- * so we need no CommandCounterIncrement.)
+ * We are completing a "BEGIN TRANSACTION" command, so we change
+ * to the "transaction block in progress" state and return. (We
+ * assume the BEGIN did nothing to the database, so we need no
+ * CommandCounterIncrement.)
*/
case TBLOCK_BEGIN:
s->blockState = TBLOCK_INPROGRESS;
@@ -2110,8 +2097,8 @@ CommitTransactionCommand(void)
/*
* This is the case when we have finished executing a command
- * someplace within a transaction block. We increment the
- * command counter and return.
+ * someplace within a transaction block. We increment the command
+ * counter and return.
*/
case TBLOCK_INPROGRESS:
case TBLOCK_SUBINPROGRESS:
@@ -2119,8 +2106,8 @@ CommitTransactionCommand(void)
break;
/*
- * We are completing a "COMMIT" command. Do it and return to
- * the idle state.
+ * We are completing a "COMMIT" command. Do it and return to the
+ * idle state.
*/
case TBLOCK_END:
CommitTransaction();
@@ -2128,17 +2115,17 @@ CommitTransactionCommand(void)
break;
/*
- * Here we are in the middle of a transaction block but one of
- * the commands caused an abort so we do nothing but remain in
- * the abort state. Eventually we will get a ROLLBACK comand.
+ * Here we are in the middle of a transaction block but one of the
+ * commands caused an abort so we do nothing but remain in the
+ * abort state. Eventually we will get a ROLLBACK comand.
*/
case TBLOCK_ABORT:
case TBLOCK_SUBABORT:
break;
/*
- * Here we were in an aborted transaction block and we just
- * got the ROLLBACK command from the user, so clean up the
+ * Here we were in an aborted transaction block and we just got
+ * the ROLLBACK command from the user, so clean up the
* already-aborted transaction and return to the idle state.
*/
case TBLOCK_ABORT_END:
@@ -2147,9 +2134,9 @@ CommitTransactionCommand(void)
break;
/*
- * Here we were in a perfectly good transaction block but the
- * user told us to ROLLBACK anyway. We have to abort the
- * transaction and then clean up.
+ * Here we were in a perfectly good transaction block but the user
+ * told us to ROLLBACK anyway. We have to abort the transaction
+ * and then clean up.
*/
case TBLOCK_ABORT_PENDING:
AbortTransaction();
@@ -2169,8 +2156,8 @@ CommitTransactionCommand(void)
/*
* We were just issued a SAVEPOINT inside a transaction block.
* Start a subtransaction. (DefineSavepoint already did
- * PushTransaction, so as to have someplace to put the
- * SUBBEGIN state.)
+ * PushTransaction, so as to have someplace to put the SUBBEGIN
+ * state.)
*/
case TBLOCK_SUBBEGIN:
StartSubTransaction();
@@ -2259,8 +2246,8 @@ CommitTransactionCommand(void)
break;
/*
- * Same as above, but the subtransaction had already failed,
- * so we don't need AbortSubTransaction.
+ * Same as above, but the subtransaction had already failed, so we
+ * don't need AbortSubTransaction.
*/
case TBLOCK_SUBABORT_RESTART:
{
@@ -2320,8 +2307,8 @@ AbortCurrentTransaction(void)
break;
/*
- * if we aren't in a transaction block, we just do the basic
- * abort & cleanup transaction.
+ * if we aren't in a transaction block, we just do the basic abort
+ * & cleanup transaction.
*/
case TBLOCK_STARTED:
AbortTransaction();
@@ -2330,11 +2317,11 @@ AbortCurrentTransaction(void)
break;
/*
- * If we are in TBLOCK_BEGIN it means something screwed up
- * right after reading "BEGIN TRANSACTION". We assume that
- * the user will interpret the error as meaning the BEGIN
- * failed to get him into a transaction block, so we should
- * abort and return to idle state.
+ * If we are in TBLOCK_BEGIN it means something screwed up right
+ * after reading "BEGIN TRANSACTION". We assume that the user
+ * will interpret the error as meaning the BEGIN failed to get him
+ * into a transaction block, so we should abort and return to idle
+ * state.
*/
case TBLOCK_BEGIN:
AbortTransaction();
@@ -2354,9 +2341,9 @@ AbortCurrentTransaction(void)
break;
/*
- * Here, we failed while trying to COMMIT. Clean up the
- * transaction and return to idle state (we do not want to
- * stay in the transaction).
+ * Here, we failed while trying to COMMIT. Clean up the
+ * transaction and return to idle state (we do not want to stay in
+ * the transaction).
*/
case TBLOCK_END:
AbortTransaction();
@@ -2365,9 +2352,9 @@ AbortCurrentTransaction(void)
break;
/*
- * Here, we are already in an aborted transaction state and
- * are waiting for a ROLLBACK, but for some reason we failed
- * again! So we just remain in the abort state.
+ * Here, we are already in an aborted transaction state and are
+ * waiting for a ROLLBACK, but for some reason we failed again!
+ * So we just remain in the abort state.
*/
case TBLOCK_ABORT:
case TBLOCK_SUBABORT:
@@ -2375,8 +2362,8 @@ AbortCurrentTransaction(void)
/*
* We are in a failed transaction and we got the ROLLBACK command.
- * We have already aborted, we just need to cleanup and go to
- * idle state.
+ * We have already aborted, we just need to cleanup and go to idle
+ * state.
*/
case TBLOCK_ABORT_END:
CleanupTransaction();
@@ -2395,8 +2382,8 @@ AbortCurrentTransaction(void)
/*
* Here, we failed while trying to PREPARE. Clean up the
- * transaction and return to idle state (we do not want to
- * stay in the transaction).
+ * transaction and return to idle state (we do not want to stay in
+ * the transaction).
*/
case TBLOCK_PREPARE:
AbortTransaction();
@@ -2406,8 +2393,8 @@ AbortCurrentTransaction(void)
/*
* We got an error inside a subtransaction. Abort just the
- * subtransaction, and go to the persistent SUBABORT state
- * until we get ROLLBACK.
+ * subtransaction, and go to the persistent SUBABORT state until
+ * we get ROLLBACK.
*/
case TBLOCK_SUBINPROGRESS:
AbortSubTransaction();
@@ -2416,7 +2403,7 @@ AbortCurrentTransaction(void)
/*
* If we failed while trying to create a subtransaction, clean up
- * the broken subtransaction and abort the parent. The same
+ * the broken subtransaction and abort the parent. The same
* applies if we get a failure while ending a subtransaction.
*/
case TBLOCK_SUBBEGIN:
@@ -2479,15 +2466,15 @@ PreventTransactionChain(void *stmtNode, const char *stmtType)
stmtType)));
/*
- * Are we inside a function call? If the statement's parameter block
- * was allocated in QueryContext, assume it is an interactive command.
+ * Are we inside a function call? If the statement's parameter block was
+ * allocated in QueryContext, assume it is an interactive command.
* Otherwise assume it is coming from a function.
*/
if (!MemoryContextContains(QueryContext, stmtNode))
ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
/* translator: %s represents an SQL statement name */
- errmsg("%s cannot be executed from a function", stmtType)));
+ errmsg("%s cannot be executed from a function", stmtType)));
/* If we got past IsTransactionBlock test, should be in default state */
if (CurrentTransactionState->blockState != TBLOCK_DEFAULT &&
@@ -2529,8 +2516,8 @@ RequireTransactionChain(void *stmtNode, const char *stmtType)
return;
/*
- * Are we inside a function call? If the statement's parameter block
- * was allocated in QueryContext, assume it is an interactive command.
+ * Are we inside a function call? If the statement's parameter block was
+ * allocated in QueryContext, assume it is an interactive command.
* Otherwise assume it is coming from a function.
*/
if (!MemoryContextContains(QueryContext, stmtNode))
@@ -2556,8 +2543,8 @@ bool
IsInTransactionChain(void *stmtNode)
{
/*
- * Return true on same conditions that would make
- * PreventTransactionChain error out
+ * Return true on same conditions that would make PreventTransactionChain
+ * error out
*/
if (IsTransactionBlock())
return true;
@@ -2705,8 +2692,7 @@ BeginTransactionBlock(void)
switch (s->blockState)
{
/*
- * We are not inside a transaction block, so allow one to
- * begin.
+ * We are not inside a transaction block, so allow one to begin.
*/
case TBLOCK_STARTED:
s->blockState = TBLOCK_BEGIN;
@@ -2721,7 +2707,7 @@ BeginTransactionBlock(void)
case TBLOCK_SUBABORT:
ereport(WARNING,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
- errmsg("there is already a transaction in progress")));
+ errmsg("there is already a transaction in progress")));
break;
/* These cases are invalid. */
@@ -2759,7 +2745,7 @@ bool
PrepareTransactionBlock(char *gid)
{
TransactionState s;
- bool result;
+ bool result;
/* Set up to commit the current transaction */
result = EndTransactionBlock();
@@ -2832,8 +2818,8 @@ EndTransactionBlock(void)
break;
/*
- * We are in a live subtransaction block. Set up to subcommit
- * all open subtransactions and then commit the main transaction.
+ * We are in a live subtransaction block. Set up to subcommit all
+ * open subtransactions and then commit the main transaction.
*/
case TBLOCK_SUBINPROGRESS:
while (s->parent != NULL)
@@ -2854,9 +2840,9 @@ EndTransactionBlock(void)
break;
/*
- * Here we are inside an aborted subtransaction. Treat the
- * COMMIT as ROLLBACK: set up to abort everything and exit
- * the main transaction.
+ * Here we are inside an aborted subtransaction. Treat the COMMIT
+ * as ROLLBACK: set up to abort everything and exit the main
+ * transaction.
*/
case TBLOCK_SUBABORT:
while (s->parent != NULL)
@@ -2927,9 +2913,9 @@ UserAbortTransactionBlock(void)
switch (s->blockState)
{
/*
- * We are inside a transaction block and we got a ROLLBACK
- * command from the user, so tell CommitTransactionCommand
- * to abort and exit the transaction block.
+ * We are inside a transaction block and we got a ROLLBACK command
+ * from the user, so tell CommitTransactionCommand to abort and
+ * exit the transaction block.
*/
case TBLOCK_INPROGRESS:
s->blockState = TBLOCK_ABORT_PENDING;
@@ -2937,17 +2923,17 @@ UserAbortTransactionBlock(void)
/*
* We are inside a failed transaction block and we got a ROLLBACK
- * command from the user. Abort processing is already done,
- * so CommitTransactionCommand just has to cleanup and go back
- * to idle state.
+ * command from the user. Abort processing is already done, so
+ * CommitTransactionCommand just has to cleanup and go back to
+ * idle state.
*/
case TBLOCK_ABORT:
s->blockState = TBLOCK_ABORT_END;
break;
/*
- * We are inside a subtransaction. Mark everything
- * up to top level as exitable.
+ * We are inside a subtransaction. Mark everything up to top
+ * level as exitable.
*/
case TBLOCK_SUBINPROGRESS:
case TBLOCK_SUBABORT:
@@ -2972,8 +2958,8 @@ UserAbortTransactionBlock(void)
break;
/*
- * The user issued ABORT when not inside a transaction. Issue
- * a WARNING and go to abort state. The upcoming call to
+ * The user issued ABORT when not inside a transaction. Issue a
+ * WARNING and go to abort state. The upcoming call to
* CommitTransactionCommand() will then put us back into the
* default state.
*/
@@ -3021,8 +3007,8 @@ DefineSavepoint(char *name)
s = CurrentTransactionState; /* changed by push */
/*
- * Savepoint names, like the TransactionState block itself,
- * live in TopTransactionContext.
+ * Savepoint names, like the TransactionState block itself, live
+ * in TopTransactionContext.
*/
if (name)
s->name = MemoryContextStrdup(TopTransactionContext, name);
@@ -3078,8 +3064,8 @@ ReleaseSavepoint(List *options)
break;
/*
- * We are in a non-aborted subtransaction. This is the only
- * valid case.
+ * We are in a non-aborted subtransaction. This is the only valid
+ * case.
*/
case TBLOCK_SUBINPROGRESS:
break;
@@ -3134,8 +3120,8 @@ ReleaseSavepoint(List *options)
/*
* Mark "commit pending" all subtransactions up to the target
- * subtransaction. The actual commits will happen when control gets
- * to CommitTransactionCommand.
+ * subtransaction. The actual commits will happen when control gets to
+ * CommitTransactionCommand.
*/
xact = CurrentTransactionState;
for (;;)
@@ -3232,8 +3218,8 @@ RollbackToSavepoint(List *options)
/*
* Mark "abort pending" all subtransactions up to the target
- * subtransaction. The actual aborts will happen when control gets
- * to CommitTransactionCommand.
+ * subtransaction. The actual aborts will happen when control gets to
+ * CommitTransactionCommand.
*/
xact = CurrentTransactionState;
for (;;)
@@ -3284,8 +3270,8 @@ BeginInternalSubTransaction(char *name)
s = CurrentTransactionState; /* changed by push */
/*
- * Savepoint names, like the TransactionState block itself,
- * live in TopTransactionContext.
+ * Savepoint names, like the TransactionState block itself, live
+ * in TopTransactionContext.
*/
if (name)
s->name = MemoryContextStrdup(TopTransactionContext, name);
@@ -3333,7 +3319,7 @@ ReleaseCurrentSubTransaction(void)
Assert(s->state == TRANS_INPROGRESS);
MemoryContextSwitchTo(CurTransactionContext);
CommitSubTransaction();
- s = CurrentTransactionState; /* changed by pop */
+ s = CurrentTransactionState; /* changed by pop */
Assert(s->state == TRANS_INPROGRESS);
}
@@ -3433,8 +3419,7 @@ AbortOutOfAnyTransaction(void)
break;
/*
- * In a subtransaction, so clean it up and abort parent
- * too
+ * In a subtransaction, so clean it up and abort parent too
*/
case TBLOCK_SUBBEGIN:
case TBLOCK_SUBINPROGRESS:
@@ -3667,9 +3652,9 @@ CommitSubTransaction(void)
s->parent->subTransactionId);
/*
- * We need to restore the upper transaction's read-only state, in case
- * the upper is read-write while the child is read-only; GUC will
- * incorrectly think it should leave the child state in place.
+ * We need to restore the upper transaction's read-only state, in case the
+ * upper is read-write while the child is read-only; GUC will incorrectly
+ * think it should leave the child state in place.
*/
XactReadOnly = s->prevXactReadOnly;
@@ -3706,8 +3691,8 @@ AbortSubTransaction(void)
/*
* Release any LW locks we might be holding as quickly as possible.
* (Regular locks, however, must be held till we finish aborting.)
- * Releasing LW locks is critical since we might try to grab them
- * again while cleaning up!
+ * Releasing LW locks is critical since we might try to grab them again
+ * while cleaning up!
*
* FIXME This may be incorrect --- Are there some locks we should keep?
* Buffer locks, for example? I don't think so but I'm not sure.
@@ -3726,8 +3711,8 @@ AbortSubTransaction(void)
AtSubAbort_ResourceOwner();
/*
- * We can skip all this stuff if the subxact failed before creating
- * a ResourceOwner...
+ * We can skip all this stuff if the subxact failed before creating a
+ * ResourceOwner...
*/
if (s->curTransactionOwner)
{
@@ -3777,25 +3762,23 @@ AbortSubTransaction(void)
}
/*
- * Reset user id which might have been changed transiently. Here we
- * want to restore to the userid that was current at subxact entry.
- * (As in AbortTransaction, we need not worry about the session
- * userid.)
+ * Reset user id which might have been changed transiently. Here we want
+ * to restore to the userid that was current at subxact entry. (As in
+ * AbortTransaction, we need not worry about the session userid.)
*
- * Must do this after AtEOXact_GUC to handle the case where we entered
- * the subxact inside a SECURITY DEFINER function (hence current and
- * session userids were different) and then session auth was changed
- * inside the subxact. GUC will reset both current and session
- * userids to the entry-time session userid. This is right in every
- * other scenario so it seems simplest to let GUC do that and fix it
- * here.
+ * Must do this after AtEOXact_GUC to handle the case where we entered the
+ * subxact inside a SECURITY DEFINER function (hence current and session
+ * userids were different) and then session auth was changed inside the
+ * subxact. GUC will reset both current and session userids to the
+ * entry-time session userid. This is right in every other scenario so it
+ * seems simplest to let GUC do that and fix it here.
*/
SetUserId(s->currentUser);
/*
- * Restore the upper transaction's read-only state, too. This should
- * be redundant with GUC's cleanup but we may as well do it for
- * consistency with the commit case.
+ * Restore the upper transaction's read-only state, too. This should be
+ * redundant with GUC's cleanup but we may as well do it for consistency
+ * with the commit case.
*/
XactReadOnly = s->prevXactReadOnly;
@@ -3846,11 +3829,11 @@ PushTransaction(void)
{
TransactionState p = CurrentTransactionState;
TransactionState s;
- Oid currentUser;
+ Oid currentUser;
/*
- * At present, GetUserId cannot fail, but let's not assume that. Get
- * the ID before entering the critical code sequence.
+ * At present, GetUserId cannot fail, but let's not assume that. Get the
+ * ID before entering the critical code sequence.
*/
currentUser = GetUserId();
@@ -3860,6 +3843,7 @@ PushTransaction(void)
s = (TransactionState)
MemoryContextAllocZero(TopTransactionContext,
sizeof(TransactionStateData));
+
/*
* Assign a subtransaction ID, watching out for counter wraparound.
*/
@@ -3872,11 +3856,12 @@ PushTransaction(void)
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("cannot have more than 2^32-1 subtransactions in a transaction")));
}
+
/*
* We can now stack a minimally valid subtransaction without fear of
* failure.
*/
- s->transactionId = InvalidTransactionId; /* until assigned */
+ s->transactionId = InvalidTransactionId; /* until assigned */
s->subTransactionId = currentSubTransactionId;
s->parent = p;
s->nestingLevel = p->nestingLevel + 1;
@@ -3889,10 +3874,10 @@ PushTransaction(void)
CurrentTransactionState = s;
/*
- * AbortSubTransaction and CleanupSubTransaction have to be able to
- * cope with the subtransaction from here on out; in particular they
- * should not assume that it necessarily has a transaction context,
- * resource owner, or XID.
+ * AbortSubTransaction and CleanupSubTransaction have to be able to cope
+ * with the subtransaction from here on out; in particular they should not
+ * assume that it necessarily has a transaction context, resource owner,
+ * or XID.
*/
}
@@ -3959,7 +3944,7 @@ ShowTransactionStateRec(TransactionState s)
/* use ereport to suppress computation if msg will not be printed */
ereport(DEBUG3,
(errmsg_internal("name: %s; blockState: %13s; state: %7s, xid/subid/cid: %u/%u/%u, nestlvl: %d, children: %s",
- PointerIsValid(s->name) ? s->name : "unnamed",
+ PointerIsValid(s->name) ? s->name : "unnamed",
BlockStateAsString(s->blockState),
TransStateAsString(s->state),
(unsigned int) s->transactionId,
@@ -4215,7 +4200,7 @@ xact_desc_commit(char *buf, xl_xact_commit *xlrec)
if (xlrec->nsubxacts > 0)
{
TransactionId *xacts = (TransactionId *)
- &xlrec->xnodes[xlrec->nrels];
+ &xlrec->xnodes[xlrec->nrels];
sprintf(buf + strlen(buf), "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
@@ -4246,7 +4231,7 @@ xact_desc_abort(char *buf, xl_xact_abort *xlrec)
if (xlrec->nsubxacts > 0)
{
TransactionId *xacts = (TransactionId *)
- &xlrec->xnodes[xlrec->nrels];
+ &xlrec->xnodes[xlrec->nrels];
sprintf(buf + strlen(buf), "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 878d7e21ef..7a37c656dc 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.219 2005/10/03 00:28:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.220 2005/10/15 02:49:10 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,7 +51,7 @@
/*
* Because O_DIRECT bypasses the kernel buffers, and because we never
* read those buffers except during crash recovery, it is a win to use
- * it in all cases where we sync on each write(). We could allow O_DIRECT
+ * it in all cases where we sync on each write(). We could allow O_DIRECT
* with fsync(), but because skipping the kernel buffer forces writes out
* quickly, it seems best just to use it for O_SYNC. It is hard to imagine
* how fsync() could be a win for O_DIRECT compared to O_SYNC and O_DIRECT.
@@ -85,14 +85,14 @@
#if O_DSYNC != BARE_OPEN_SYNC_FLAG
#define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
#endif
-#else /* !defined(OPEN_SYNC_FLAG) */
+#else /* !defined(OPEN_SYNC_FLAG) */
/* Win32 only has O_DSYNC */
#define OPEN_DATASYNC_FLAG (O_DSYNC | PG_O_DIRECT)
#endif
#endif
#if defined(OPEN_DATASYNC_FLAG)
-#define DEFAULT_SYNC_METHOD_STR "open_datasync"
+#define DEFAULT_SYNC_METHOD_STR "open_datasync"
#define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN
#define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG
#elif defined(HAVE_FDATASYNC)
@@ -154,7 +154,7 @@ bool XLOG_DEBUG = false;
/* these are derived from XLOG_sync_method by assign_xlog_sync_method */
-int sync_method = DEFAULT_SYNC_METHOD;
+int sync_method = DEFAULT_SYNC_METHOD;
static int open_sync_bit = DEFAULT_SYNC_FLAGBIT;
#define XLOG_SYNC_BIT (enableFsync ? open_sync_bit : 0)
@@ -368,10 +368,9 @@ typedef struct XLogCtlData
XLogCtlWrite Write;
/*
- * These values do not change after startup, although the pointed-to
- * pages and xlblocks values certainly do. Permission to read/write
- * the pages and xlblocks values depends on WALInsertLock and
- * WALWriteLock.
+ * These values do not change after startup, although the pointed-to pages
+ * and xlblocks values certainly do. Permission to read/write the pages
+ * and xlblocks values depends on WALInsertLock and WALWriteLock.
*/
char *pages; /* buffers for unwritten XLOG pages */
XLogRecPtr *xlblocks; /* 1st byte ptr-s + BLCKSZ */
@@ -449,8 +448,8 @@ static char *readRecordBuf = NULL;
static uint32 readRecordBufSize = 0;
/* State information for XLOG reading */
-static XLogRecPtr ReadRecPtr; /* start of last record read */
-static XLogRecPtr EndRecPtr; /* end+1 of last record read */
+static XLogRecPtr ReadRecPtr; /* start of last record read */
+static XLogRecPtr EndRecPtr; /* end+1 of last record read */
static XLogRecord *nextRecord = NULL;
static TimeLineID lastPageTLI = 0;
@@ -467,7 +466,7 @@ static void exitArchiveRecovery(TimeLineID endTLI,
static bool recoveryStopsHere(XLogRecord *record, bool *includeThis);
static bool XLogCheckBuffer(XLogRecData *rdata,
- XLogRecPtr *lsn, BkpBlock *bkpb);
+ XLogRecPtr *lsn, BkpBlock *bkpb);
static bool AdvanceXLInsertBuffer(void);
static void XLogWrite(XLogwrtRqst WriteRqst, bool flexible);
static int XLogFileInit(uint32 log, uint32 seg,
@@ -481,7 +480,7 @@ static bool RestoreArchivedFile(char *path, const char *xlogfname,
const char *recovername, off_t expectedSize);
static int PreallocXlogFiles(XLogRecPtr endptr);
static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
- int *nsegsremoved, int *nsegsrecycled);
+ int *nsegsremoved, int *nsegsrecycled);
static void RemoveOldBackupHistory(void);
static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode);
static bool ValidXLOGHeader(XLogPageHeader hdr, int emode);
@@ -554,36 +553,34 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
}
/*
- * In bootstrap mode, we don't actually log anything but XLOG
- * resources; return a phony record pointer.
+ * In bootstrap mode, we don't actually log anything but XLOG resources;
+ * return a phony record pointer.
*/
if (IsBootstrapProcessingMode() && rmid != RM_XLOG_ID)
{
RecPtr.xlogid = 0;
- RecPtr.xrecoff = SizeOfXLogLongPHD; /* start of 1st chkpt
- * record */
+ RecPtr.xrecoff = SizeOfXLogLongPHD; /* start of 1st chkpt record */
return (RecPtr);
}
/*
* Here we scan the rdata chain, determine which buffers must be backed
* up, and compute the CRC values for the data. Note that the record
- * header isn't added into the CRC initially since we don't know the
- * final length or info bits quite yet. Thus, the CRC will represent
- * the CRC of the whole record in the order "rdata, then backup blocks,
- * then record header".
+ * header isn't added into the CRC initially since we don't know the final
+ * length or info bits quite yet. Thus, the CRC will represent the CRC of
+ * the whole record in the order "rdata, then backup blocks, then record
+ * header".
*
- * We may have to loop back to here if a race condition is detected
- * below. We could prevent the race by doing all this work while
- * holding the insert lock, but it seems better to avoid doing CRC
- * calculations while holding the lock. This means we have to be
- * careful about modifying the rdata chain until we know we aren't
- * going to loop back again. The only change we allow ourselves to
- * make earlier is to set rdt->data = NULL in chain items we have
- * decided we will have to back up the whole buffer for. This is OK
- * because we will certainly decide the same thing again for those
- * items if we do it over; doing it here saves an extra pass over the
- * chain later.
+ * We may have to loop back to here if a race condition is detected below. We
+ * could prevent the race by doing all this work while holding the insert
+ * lock, but it seems better to avoid doing CRC calculations while holding
+ * the lock. This means we have to be careful about modifying the rdata
+ * chain until we know we aren't going to loop back again. The only
+ * change we allow ourselves to make earlier is to set rdt->data = NULL in
+ * chain items we have decided we will have to back up the whole buffer
+ * for. This is OK because we will certainly decide the same thing again
+ * for those items if we do it over; doing it here saves an extra pass
+ * over the chain later.
*/
begin:;
for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++)
@@ -680,12 +677,12 @@ begin:;
}
/*
- * NOTE: the test for len == 0 here is somewhat fishy, since in theory
- * all of the rmgr data might have been suppressed in favor of backup
- * blocks. Currently, all callers of XLogInsert provide at least some
- * not-in-a-buffer data and so len == 0 should never happen, but that
- * may not be true forever. If you need to remove the len == 0 check,
- * also remove the check for xl_len == 0 in ReadRecord, below.
+ * NOTE: the test for len == 0 here is somewhat fishy, since in theory all
+ * of the rmgr data might have been suppressed in favor of backup blocks.
+ * Currently, all callers of XLogInsert provide at least some
+ * not-in-a-buffer data and so len == 0 should never happen, but that may
+ * not be true forever. If you need to remove the len == 0 check, also
+ * remove the check for xl_len == 0 in ReadRecord, below.
*/
if (len == 0)
elog(PANIC, "invalid xlog record length %u", len);
@@ -718,9 +715,9 @@ begin:;
* Since the amount of data we write here is completely optional
* anyway, tell XLogWrite it can be "flexible" and stop at a
* convenient boundary. This allows writes triggered by this
- * mechanism to synchronize with the cache boundaries, so that
- * in a long transaction we'll basically dump alternating halves
- * of the buffer array.
+ * mechanism to synchronize with the cache boundaries, so that in
+ * a long transaction we'll basically dump alternating halves of
+ * the buffer array.
*/
LogwrtResult = XLogCtl->Write.LogwrtResult;
if (XLByteLT(LogwrtResult.Write, LogwrtRqst.Write))
@@ -733,10 +730,9 @@ begin:;
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
/*
- * Check to see if my RedoRecPtr is out of date. If so, may have to
- * go back and recompute everything. This can only happen just after
- * a checkpoint, so it's better to be slow in this case and fast
- * otherwise.
+ * Check to see if my RedoRecPtr is out of date. If so, may have to go
+ * back and recompute everything. This can only happen just after a
+ * checkpoint, so it's better to be slow in this case and fast otherwise.
*/
if (!XLByteEQ(RedoRecPtr, Insert->RedoRecPtr))
{
@@ -751,8 +747,8 @@ begin:;
XLByteLE(dtbuf_lsn[i], RedoRecPtr))
{
/*
- * Oops, this buffer now needs to be backed up, but we
- * didn't think so above. Start over.
+ * Oops, this buffer now needs to be backed up, but we didn't
+ * think so above. Start over.
*/
LWLockRelease(WALInsertLock);
END_CRIT_SECTION();
@@ -762,15 +758,14 @@ begin:;
}
/*
- * Make additional rdata chain entries for the backup blocks, so that
- * we don't need to special-case them in the write loop. Note that we
- * have now irrevocably changed the input rdata chain. At the exit of
- * this loop, write_len includes the backup block data.
+ * Make additional rdata chain entries for the backup blocks, so that we
+ * don't need to special-case them in the write loop. Note that we have
+ * now irrevocably changed the input rdata chain. At the exit of this
+ * loop, write_len includes the backup block data.
*
- * Also set the appropriate info bits to show which buffers were backed
- * up. The i'th XLR_SET_BKP_BLOCK bit corresponds to the i'th
- * distinct buffer value (ignoring InvalidBuffer) appearing in the
- * rdata chain.
+ * Also set the appropriate info bits to show which buffers were backed up.
+ * The i'th XLR_SET_BKP_BLOCK bit corresponds to the i'th distinct buffer
+ * value (ignoring InvalidBuffer) appearing in the rdata chain.
*/
write_len = len;
for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++)
@@ -822,8 +817,7 @@ begin:;
/*
* If there isn't enough space on the current XLOG page for a record
- * header, advance to the next page (leaving the unused space as
- * zeroes).
+ * header, advance to the next page (leaving the unused space as zeroes).
*/
updrqst = false;
freespace = INSERT_FREESPACE(Insert);
@@ -925,15 +919,15 @@ begin:;
freespace = INSERT_FREESPACE(Insert);
/*
- * The recptr I return is the beginning of the *next* record. This
- * will be stored as LSN for changed data pages...
+ * The recptr I return is the beginning of the *next* record. This will be
+ * stored as LSN for changed data pages...
*/
INSERT_RECPTR(RecPtr, Insert, curridx);
/* Need to update shared LogwrtRqst if some block was filled up */
if (freespace < SizeOfXLogRecord)
- updrqst = true; /* curridx is filled and available for
- * writing out */
+ updrqst = true; /* curridx is filled and available for writing
+ * out */
else
curridx = PrevBufIdx(curridx);
WriteRqst = XLogCtl->xlblocks[curridx];
@@ -975,9 +969,9 @@ XLogCheckBuffer(XLogRecData *rdata,
page = (PageHeader) BufferGetBlock(rdata->buffer);
/*
- * XXX We assume page LSN is first data on *every* page that can be
- * passed to XLogInsert, whether it otherwise has the standard page
- * layout or not.
+ * XXX We assume page LSN is first data on *every* page that can be passed
+ * to XLogInsert, whether it otherwise has the standard page layout or
+ * not.
*/
*lsn = page->pd_lsn;
@@ -1163,9 +1157,9 @@ AdvanceXLInsertBuffer(void)
LogwrtResult = Insert->LogwrtResult;
/*
- * Get ending-offset of the buffer page we need to replace (this may
- * be zero if the buffer hasn't been used yet). Fall through if it's
- * already written out.
+ * Get ending-offset of the buffer page we need to replace (this may be
+ * zero if the buffer hasn't been used yet). Fall through if it's already
+ * written out.
*/
OldPageRqstPtr = XLogCtl->xlblocks[nextidx];
if (!XLByteLE(OldPageRqstPtr, LogwrtResult.Write))
@@ -1208,9 +1202,8 @@ AdvanceXLInsertBuffer(void)
else
{
/*
- * Have to write buffers while holding insert lock. This
- * is not good, so only write as much as we absolutely
- * must.
+ * Have to write buffers while holding insert lock. This is
+ * not good, so only write as much as we absolutely must.
*/
WriteRqst.Write = OldPageRqstPtr;
WriteRqst.Flush.xlogid = 0;
@@ -1223,8 +1216,8 @@ AdvanceXLInsertBuffer(void)
}
/*
- * Now the next buffer slot is free and we can set it up to be the
- * next output page.
+ * Now the next buffer slot is free and we can set it up to be the next
+ * output page.
*/
NewPageEndPtr = XLogCtl->xlblocks[Insert->curridx];
if (NewPageEndPtr.xrecoff >= XLogFileSize)
@@ -1237,24 +1230,27 @@ AdvanceXLInsertBuffer(void)
NewPageEndPtr.xrecoff += BLCKSZ;
XLogCtl->xlblocks[nextidx] = NewPageEndPtr;
NewPage = (XLogPageHeader) (XLogCtl->pages + nextidx * (Size) BLCKSZ);
+
Insert->curridx = nextidx;
Insert->currpage = NewPage;
- Insert->currpos = ((char *) NewPage) + SizeOfXLogShortPHD;
+
+ Insert->currpos = ((char *) NewPage) +SizeOfXLogShortPHD;
/*
- * Be sure to re-zero the buffer so that bytes beyond what we've
- * written will look like zeroes and not valid XLOG records...
+ * Be sure to re-zero the buffer so that bytes beyond what we've written
+ * will look like zeroes and not valid XLOG records...
*/
MemSet((char *) NewPage, 0, BLCKSZ);
/*
* Fill the new page's header
*/
- NewPage->xlp_magic = XLOG_PAGE_MAGIC;
+ NewPage ->xlp_magic = XLOG_PAGE_MAGIC;
+
/* NewPage->xlp_info = 0; */ /* done by memset */
- NewPage->xlp_tli = ThisTimeLineID;
- NewPage->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid;
- NewPage->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ;
+ NewPage ->xlp_tli = ThisTimeLineID;
+ NewPage ->xlp_pageaddr.xlogid = NewPageEndPtr.xlogid;
+ NewPage ->xlp_pageaddr.xrecoff = NewPageEndPtr.xrecoff - BLCKSZ;
/*
* If first page of an XLOG segment file, make it a long header.
@@ -1265,8 +1261,9 @@ AdvanceXLInsertBuffer(void)
NewLongPage->xlp_sysid = ControlFile->system_identifier;
NewLongPage->xlp_seg_size = XLogSegSize;
- NewPage->xlp_info |= XLP_LONG_HEADER;
- Insert->currpos = ((char *) NewPage) + SizeOfXLogLongPHD;
+ NewPage ->xlp_info |= XLP_LONG_HEADER;
+
+ Insert->currpos = ((char *) NewPage) +SizeOfXLogLongPHD;
}
return update_needed;
@@ -1298,19 +1295,18 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
Assert(CritSectionCount > 0);
/*
- * Update local LogwrtResult (caller probably did this already,
- * but...)
+ * Update local LogwrtResult (caller probably did this already, but...)
*/
LogwrtResult = Write->LogwrtResult;
/*
* Since successive pages in the xlog cache are consecutively allocated,
* we can usually gather multiple pages together and issue just one
- * write() call. npages is the number of pages we have determined can
- * be written together; startidx is the cache block index of the first
- * one, and startoffset is the file offset at which it should go.
- * The latter two variables are only valid when npages > 0, but we must
- * initialize all of them to keep the compiler quiet.
+ * write() call. npages is the number of pages we have determined can be
+ * written together; startidx is the cache block index of the first one,
+ * and startoffset is the file offset at which it should go. The latter
+ * two variables are only valid when npages > 0, but we must initialize
+ * all of them to keep the compiler quiet.
*/
npages = 0;
startidx = 0;
@@ -1320,18 +1316,17 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
* Within the loop, curridx is the cache block index of the page to
* consider writing. We advance Write->curridx only after successfully
* writing pages. (Right now, this refinement is useless since we are
- * going to PANIC if any error occurs anyway; but someday it may come
- * in useful.)
+ * going to PANIC if any error occurs anyway; but someday it may come in
+ * useful.)
*/
curridx = Write->curridx;
while (XLByteLT(LogwrtResult.Write, WriteRqst.Write))
{
/*
- * Make sure we're not ahead of the insert process. This could
- * happen if we're passed a bogus WriteRqst.Write that is past the
- * end of the last page that's been initialized by
- * AdvanceXLInsertBuffer.
+ * Make sure we're not ahead of the insert process. This could happen
+ * if we're passed a bogus WriteRqst.Write that is past the end of the
+ * last page that's been initialized by AdvanceXLInsertBuffer.
*/
if (!XLByteLT(LogwrtResult.Write, XLogCtl->xlblocks[curridx]))
elog(PANIC, "xlog write request %X/%X is past end of log %X/%X",
@@ -1355,8 +1350,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
if (close(openLogFile))
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not close log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not close log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
openLogFile = -1;
}
XLByteToPrevSeg(LogwrtResult.Write, openLogId, openLogSeg);
@@ -1379,13 +1374,13 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
UpdateControlFile();
/*
- * Signal bgwriter to start a checkpoint if it's been
- * too long since the last one. (We look at local copy of
- * RedoRecPtr which might be a little out of date, but
- * should be close enough for this purpose.)
+ * Signal bgwriter to start a checkpoint if it's been too long
+ * since the last one. (We look at local copy of RedoRecPtr
+ * which might be a little out of date, but should be close
+ * enough for this purpose.)
*
- * A straight computation of segment number could overflow
- * 32 bits. Rather than assuming we have working 64-bit
+ * A straight computation of segment number could overflow 32
+ * bits. Rather than assuming we have working 64-bit
* arithmetic, we compare the highest-order bits separately,
* and force a checkpoint immediately when they change.
*/
@@ -1434,10 +1429,10 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
npages++;
/*
- * Dump the set if this will be the last loop iteration, or if
- * we are at the last page of the cache area (since the next page
- * won't be contiguous in memory), or if we are at the end of the
- * logfile segment.
+ * Dump the set if this will be the last loop iteration, or if we are
+ * at the last page of the cache area (since the next page won't be
+ * contiguous in memory), or if we are at the end of the logfile
+ * segment.
*/
finishing_seg = !ispartialpage &&
(startoffset + npages * BLCKSZ) >= XLogSegSize;
@@ -1496,7 +1491,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
if (finishing_seg)
{
issue_xlog_fsync();
- LogwrtResult.Flush = LogwrtResult.Write; /* end of page */
+ LogwrtResult.Flush = LogwrtResult.Write; /* end of page */
if (XLogArchivingActive())
XLogArchiveNotifySeg(openLogId, openLogSeg);
@@ -1526,20 +1521,20 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
XLByteLT(LogwrtResult.Flush, LogwrtResult.Write))
{
/*
- * Could get here without iterating above loop, in which case we
- * might have no open file or the wrong one. However, we do not
- * need to fsync more than one file.
+ * Could get here without iterating above loop, in which case we might
+ * have no open file or the wrong one. However, we do not need to
+ * fsync more than one file.
*/
if (sync_method != SYNC_METHOD_OPEN)
{
if (openLogFile >= 0 &&
- !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
+ !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
{
if (close(openLogFile))
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not close log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not close log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
openLogFile = -1;
}
if (openLogFile < 0)
@@ -1557,8 +1552,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
* Update shared-memory status
*
* We make sure that the shared 'request' values do not fall behind the
- * 'result' values. This is not absolutely essential, but it saves
- * some code in a couple of places.
+ * 'result' values. This is not absolutely essential, but it saves some
+ * code in a couple of places.
*/
{
/* use volatile pointer to prevent code rearrangement */
@@ -1608,11 +1603,10 @@ XLogFlush(XLogRecPtr record)
/*
* Since fsync is usually a horribly expensive operation, we try to
- * piggyback as much data as we can on each fsync: if we see any more
- * data entered into the xlog buffer, we'll write and fsync that too,
- * so that the final value of LogwrtResult.Flush is as large as
- * possible. This gives us some chance of avoiding another fsync
- * immediately after.
+ * piggyback as much data as we can on each fsync: if we see any more data
+ * entered into the xlog buffer, we'll write and fsync that too, so that
+ * the final value of LogwrtResult.Flush is as large as possible. This
+ * gives us some chance of avoiding another fsync immediately after.
*/
/* initialize to given target; may increase below */
@@ -1669,31 +1663,29 @@ XLogFlush(XLogRecPtr record)
/*
* If we still haven't flushed to the request point then we have a
- * problem; most likely, the requested flush point is past end of
- * XLOG. This has been seen to occur when a disk page has a corrupted
- * LSN.
+ * problem; most likely, the requested flush point is past end of XLOG.
+ * This has been seen to occur when a disk page has a corrupted LSN.
*
- * Formerly we treated this as a PANIC condition, but that hurts the
- * system's robustness rather than helping it: we do not want to take
- * down the whole system due to corruption on one data page. In
- * particular, if the bad page is encountered again during recovery
- * then we would be unable to restart the database at all! (This
- * scenario has actually happened in the field several times with 7.1
- * releases. Note that we cannot get here while InRedo is true, but if
- * the bad page is brought in and marked dirty during recovery then
- * CreateCheckPoint will try to flush it at the end of recovery.)
+ * Formerly we treated this as a PANIC condition, but that hurts the system's
+ * robustness rather than helping it: we do not want to take down the
+ * whole system due to corruption on one data page. In particular, if the
+ * bad page is encountered again during recovery then we would be unable
+ * to restart the database at all! (This scenario has actually happened
+ * in the field several times with 7.1 releases. Note that we cannot get
+ * here while InRedo is true, but if the bad page is brought in and marked
+ * dirty during recovery then CreateCheckPoint will try to flush it at the
+ * end of recovery.)
*
- * The current approach is to ERROR under normal conditions, but only
- * WARNING during recovery, so that the system can be brought up even
- * if there's a corrupt LSN. Note that for calls from xact.c, the
- * ERROR will be promoted to PANIC since xact.c calls this routine
- * inside a critical section. However, calls from bufmgr.c are not
- * within critical sections and so we will not force a restart for a
- * bad LSN on a data page.
+ * The current approach is to ERROR under normal conditions, but only WARNING
+ * during recovery, so that the system can be brought up even if there's a
+ * corrupt LSN. Note that for calls from xact.c, the ERROR will be
+ * promoted to PANIC since xact.c calls this routine inside a critical
+ * section. However, calls from bufmgr.c are not within critical sections
+ * and so we will not force a restart for a bad LSN on a data page.
*/
if (XLByteLT(LogwrtResult.Flush, record))
elog(InRecovery ? WARNING : ERROR,
- "xlog flush request %X/%X is not satisfied --- flushed only to %X/%X",
+ "xlog flush request %X/%X is not satisfied --- flushed only to %X/%X",
record.xlogid, record.xrecoff,
LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
}
@@ -1734,8 +1726,7 @@ XLogFileInit(uint32 log, uint32 seg,
XLogFilePath(path, ThisTimeLineID, log, seg);
/*
- * Try to use existent file (checkpoint maker may have created it
- * already)
+ * Try to use existent file (checkpoint maker may have created it already)
*/
if (*use_existent)
{
@@ -1754,10 +1745,10 @@ XLogFileInit(uint32 log, uint32 seg,
}
/*
- * Initialize an empty (all zeroes) segment. NOTE: it is possible
- * that another process is doing the same thing. If so, we will end
- * up pre-creating an extra log segment. That seems OK, and better
- * than holding the lock throughout this lengthy process.
+ * Initialize an empty (all zeroes) segment. NOTE: it is possible that
+ * another process is doing the same thing. If so, we will end up
+ * pre-creating an extra log segment. That seems OK, and better than
+ * holding the lock throughout this lengthy process.
*/
snprintf(tmppath, MAXPGPATH, XLOGDIR "/xlogtemp.%d", (int) getpid());
@@ -1772,13 +1763,13 @@ XLogFileInit(uint32 log, uint32 seg,
errmsg("could not create file \"%s\": %m", tmppath)));
/*
- * Zero-fill the file. We have to do this the hard way to ensure that
- * all the file space has really been allocated --- on platforms that
- * allow "holes" in files, just seeking to the end doesn't allocate
- * intermediate space. This way, we know that we have all the space
- * and (after the fsync below) that all the indirect blocks are down
- * on disk. Therefore, fdatasync(2) or O_DSYNC will be sufficient to
- * sync future writes to the log file.
+ * Zero-fill the file. We have to do this the hard way to ensure that all
+ * the file space has really been allocated --- on platforms that allow
+ * "holes" in files, just seeking to the end doesn't allocate intermediate
+ * space. This way, we know that we have all the space and (after the
+ * fsync below) that all the indirect blocks are down on disk. Therefore,
+ * fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the
+ * log file.
*/
MemSet(zbuffer, 0, sizeof(zbuffer));
for (nbytes = 0; nbytes < XLogSegSize; nbytes += sizeof(zbuffer))
@@ -1789,8 +1780,7 @@ XLogFileInit(uint32 log, uint32 seg,
int save_errno = errno;
/*
- * If we fail to make the file, delete it to release disk
- * space
+ * If we fail to make the file, delete it to release disk space
*/
unlink(tmppath);
/* if write didn't set errno, assume problem is no disk space */
@@ -1798,7 +1788,7 @@ XLogFileInit(uint32 log, uint32 seg,
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write to file \"%s\": %m", tmppath)));
+ errmsg("could not write to file \"%s\": %m", tmppath)));
}
}
@@ -1816,9 +1806,9 @@ XLogFileInit(uint32 log, uint32 seg,
* Now move the segment into place with its final name.
*
* If caller didn't want to use a pre-existing file, get rid of any
- * pre-existing file. Otherwise, cope with possibility that someone
- * else has created the file while we were filling ours: if so, use
- * ours to pre-create a future log segment.
+ * pre-existing file. Otherwise, cope with possibility that someone else
+ * has created the file while we were filling ours: if so, use ours to
+ * pre-create a future log segment.
*/
installed_log = log;
installed_seg = seg;
@@ -1840,8 +1830,8 @@ XLogFileInit(uint32 log, uint32 seg,
if (fd < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
- path, log, seg)));
+ errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
+ path, log, seg)));
return (fd);
}
@@ -1908,7 +1898,7 @@ XLogFileCopy(uint32 log, uint32 seg,
errmsg("could not read file \"%s\": %m", path)));
else
ereport(ERROR,
- (errmsg("not enough data in file \"%s\"", path)));
+ (errmsg("not enough data in file \"%s\"", path)));
}
errno = 0;
if ((int) write(fd, buffer, sizeof(buffer)) != (int) sizeof(buffer))
@@ -1916,8 +1906,7 @@ XLogFileCopy(uint32 log, uint32 seg,
int save_errno = errno;
/*
- * If we fail to make the file, delete it to release disk
- * space
+ * If we fail to make the file, delete it to release disk space
*/
unlink(tmppath);
/* if write didn't set errno, assume problem is no disk space */
@@ -1925,7 +1914,7 @@ XLogFileCopy(uint32 log, uint32 seg,
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write to file \"%s\": %m", tmppath)));
+ errmsg("could not write to file \"%s\": %m", tmppath)));
}
}
@@ -2057,8 +2046,8 @@ XLogFileOpen(uint32 log, uint32 seg)
if (fd < 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
- path, log, seg)));
+ errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
+ path, log, seg)));
return fd;
}
@@ -2075,14 +2064,14 @@ XLogFileRead(uint32 log, uint32 seg, int emode)
int fd;
/*
- * Loop looking for a suitable timeline ID: we might need to read any
- * of the timelines listed in expectedTLIs.
+ * Loop looking for a suitable timeline ID: we might need to read any of
+ * the timelines listed in expectedTLIs.
*
* We expect curFileTLI on entry to be the TLI of the preceding file in
- * sequence, or 0 if there was no predecessor. We do not allow
- * curFileTLI to go backwards; this prevents us from picking up the
- * wrong file when a parent timeline extends to higher segment numbers
- * than the child we want to read.
+ * sequence, or 0 if there was no predecessor. We do not allow curFileTLI
+ * to go backwards; this prevents us from picking up the wrong file when a
+ * parent timeline extends to higher segment numbers than the child we
+ * want to read.
*/
foreach(cell, expectedTLIs)
{
@@ -2111,8 +2100,8 @@ XLogFileRead(uint32 log, uint32 seg, int emode)
if (errno != ENOENT) /* unexpected failure? */
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
- path, log, seg)));
+ errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
+ path, log, seg)));
}
/* Couldn't find it. For simplicity, complain about front timeline */
@@ -2120,8 +2109,8 @@ XLogFileRead(uint32 log, uint32 seg, int emode)
errno = ENOENT;
ereport(emode,
(errcode_for_file_access(),
- errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
- path, log, seg)));
+ errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
+ path, log, seg)));
return -1;
}
@@ -2152,29 +2141,27 @@ RestoreArchivedFile(char *path, const char *xlogfname,
struct stat stat_buf;
/*
- * When doing archive recovery, we always prefer an archived log file
- * even if a file of the same name exists in XLOGDIR. The reason is
- * that the file in XLOGDIR could be an old, un-filled or
- * partly-filled version that was copied and restored as part of
- * backing up $PGDATA.
+ * When doing archive recovery, we always prefer an archived log file even
+ * if a file of the same name exists in XLOGDIR. The reason is that the
+ * file in XLOGDIR could be an old, un-filled or partly-filled version
+ * that was copied and restored as part of backing up $PGDATA.
*
* We could try to optimize this slightly by checking the local copy
- * lastchange timestamp against the archived copy, but we have no API
- * to do this, nor can we guarantee that the lastchange timestamp was
- * preserved correctly when we copied to archive. Our aim is
- * robustness, so we elect not to do this.
+ * lastchange timestamp against the archived copy, but we have no API to
+ * do this, nor can we guarantee that the lastchange timestamp was
+ * preserved correctly when we copied to archive. Our aim is robustness,
+ * so we elect not to do this.
*
- * If we cannot obtain the log file from the archive, however, we will
- * try to use the XLOGDIR file if it exists. This is so that we can
- * make use of log segments that weren't yet transferred to the
- * archive.
+ * If we cannot obtain the log file from the archive, however, we will try to
+ * use the XLOGDIR file if it exists. This is so that we can make use of
+ * log segments that weren't yet transferred to the archive.
*
- * Notice that we don't actually overwrite any files when we copy back
- * from archive because the recoveryRestoreCommand may inadvertently
- * restore inappropriate xlogs, or they may be corrupt, so we may wish
- * to fallback to the segments remaining in current XLOGDIR later. The
- * copy-from-archive filename is always the same, ensuring that we
- * don't run out of disk space on long recoveries.
+ * Notice that we don't actually overwrite any files when we copy back from
+ * archive because the recoveryRestoreCommand may inadvertently restore
+ * inappropriate xlogs, or they may be corrupt, so we may wish to fallback
+ * to the segments remaining in current XLOGDIR later. The
+ * copy-from-archive filename is always the same, ensuring that we don't
+ * run out of disk space on long recoveries.
*/
snprintf(xlogpath, MAXPGPATH, XLOGDIR "/%s", recovername);
@@ -2259,11 +2246,11 @@ RestoreArchivedFile(char *path, const char *xlogfname,
* command apparently succeeded, but let's make sure the file is
* really there now and has the correct size.
*
- * XXX I made wrong-size a fatal error to ensure the DBA would notice
- * it, but is that too strong? We could try to plow ahead with a
- * local copy of the file ... but the problem is that there
- * probably isn't one, and we'd incorrectly conclude we've reached
- * the end of WAL and we're done recovering ...
+ * XXX I made wrong-size a fatal error to ensure the DBA would notice it,
+ * but is that too strong? We could try to plow ahead with a local
+ * copy of the file ... but the problem is that there probably isn't
+ * one, and we'd incorrectly conclude we've reached the end of WAL and
+ * we're done recovering ...
*/
if (stat(xlogpath, &stat_buf) == 0)
{
@@ -2296,18 +2283,17 @@ RestoreArchivedFile(char *path, const char *xlogfname,
/*
* remember, we rollforward UNTIL the restore fails so failure here is
* just part of the process... that makes it difficult to determine
- * whether the restore failed because there isn't an archive to
- * restore, or because the administrator has specified the restore
- * program incorrectly. We have to assume the former.
+ * whether the restore failed because there isn't an archive to restore,
+ * or because the administrator has specified the restore program
+ * incorrectly. We have to assume the former.
*/
ereport(DEBUG2,
- (errmsg("could not restore file \"%s\" from archive: return code %d",
- xlogfname, rc)));
+ (errmsg("could not restore file \"%s\" from archive: return code %d",
+ xlogfname, rc)));
/*
- * if an archived file is not available, there might still be a
- * version of this file in XLOGDIR, so return that as the filename to
- * open.
+ * if an archived file is not available, there might still be a version of
+ * this file in XLOGDIR, so return that as the filename to open.
*
* In many recovery scenarios we expect this to fail also, but if so that
* just means we've reached the end of WAL.
@@ -2375,8 +2361,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
if (xldir == NULL)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open transaction log directory \"%s\": %m",
- XLOGDIR)));
+ errmsg("could not open transaction log directory \"%s\": %m",
+ XLOGDIR)));
XLogFileName(lastoff, ThisTimeLineID, log, seg);
@@ -2384,14 +2370,14 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
{
/*
* We ignore the timeline part of the XLOG segment identifiers in
- * deciding whether a segment is still needed. This ensures that
- * we won't prematurely remove a segment from a parent timeline.
- * We could probably be a little more proactive about removing
- * segments of non-parent timelines, but that would be a whole lot
- * more complicated.
+ * deciding whether a segment is still needed. This ensures that we
+ * won't prematurely remove a segment from a parent timeline. We could
+ * probably be a little more proactive about removing segments of
+ * non-parent timelines, but that would be a whole lot more
+ * complicated.
*
- * We use the alphanumeric sorting property of the filenames to
- * decide which ones are earlier than the lastoff segment.
+ * We use the alphanumeric sorting property of the filenames to decide
+ * which ones are earlier than the lastoff segment.
*/
if (strlen(xlde->d_name) == 24 &&
strspn(xlde->d_name, "0123456789ABCDEF") == 24 &&
@@ -2409,16 +2395,16 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
/*
- * Before deleting the file, see if it can be recycled as
- * a future log segment.
+ * Before deleting the file, see if it can be recycled as a
+ * future log segment.
*/
if (InstallXLogFileSegment(&endlogId, &endlogSeg, path,
true, &max_advance,
true))
{
ereport(DEBUG2,
- (errmsg("recycled transaction log file \"%s\"",
- xlde->d_name)));
+ (errmsg("recycled transaction log file \"%s\"",
+ xlde->d_name)));
(*nsegsrecycled)++;
/* Needn't recheck that slot on future iterations */
if (max_advance > 0)
@@ -2431,8 +2417,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
{
/* No need for any more future segments... */
ereport(DEBUG2,
- (errmsg("removing transaction log file \"%s\"",
- xlde->d_name)));
+ (errmsg("removing transaction log file \"%s\"",
+ xlde->d_name)));
unlink(path);
(*nsegsremoved)++;
}
@@ -2459,8 +2445,8 @@ RemoveOldBackupHistory(void)
if (xldir == NULL)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open transaction log directory \"%s\": %m",
- XLOGDIR)));
+ errmsg("could not open transaction log directory \"%s\": %m",
+ XLOGDIR)));
while ((xlde = ReadDir(xldir, XLOGDIR)) != NULL)
{
@@ -2473,8 +2459,8 @@ RemoveOldBackupHistory(void)
if (!XLogArchivingActive() || XLogArchiveIsDone(xlde->d_name))
{
ereport(DEBUG2,
- (errmsg("removing transaction log backup history file \"%s\"",
- xlde->d_name)));
+ (errmsg("removing transaction log backup history file \"%s\"",
+ xlde->d_name)));
snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
unlink(path);
XLogArchiveCleanup(xlde->d_name);
@@ -2576,7 +2562,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
blk = (char *) XLogRecGetData(record) + len;
for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++)
{
- uint32 blen;
+ uint32 blen;
if (!(record->xl_info & XLR_SET_BKP_BLOCK(i)))
continue;
@@ -2611,8 +2597,8 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
if (!EQ_CRC32(record->xl_crc, crc))
{
ereport(emode,
- (errmsg("incorrect resource manager data checksum in record at %X/%X",
- recptr.xlogid, recptr.xrecoff)));
+ (errmsg("incorrect resource manager data checksum in record at %X/%X",
+ recptr.xlogid, recptr.xrecoff)));
return false;
}
@@ -2647,12 +2633,11 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
if (readBuf == NULL)
{
/*
- * First time through, permanently allocate readBuf. We do it
- * this way, rather than just making a static array, for two
- * reasons: (1) no need to waste the storage in most
- * instantiations of the backend; (2) a static char array isn't
- * guaranteed to have any particular alignment, whereas malloc()
- * will provide MAXALIGN'd storage.
+ * First time through, permanently allocate readBuf. We do it this
+ * way, rather than just making a static array, for two reasons: (1)
+ * no need to waste the storage in most instantiations of the backend;
+ * (2) a static char array isn't guaranteed to have any particular
+ * alignment, whereas malloc() will provide MAXALIGN'd storage.
*/
readBuf = (char *) malloc(BLCKSZ);
Assert(readBuf != NULL);
@@ -2685,11 +2670,11 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
RecPtr->xlogid, RecPtr->xrecoff)));
/*
- * Since we are going to a random position in WAL, forget any
- * prior state about what timeline we were in, and allow it to be
- * any timeline in expectedTLIs. We also set a flag to allow
- * curFileTLI to go backwards (but we can't reset that variable
- * right here, since we might not change files at all).
+ * Since we are going to a random position in WAL, forget any prior
+ * state about what timeline we were in, and allow it to be any
+ * timeline in expectedTLIs. We also set a flag to allow curFileTLI
+ * to go backwards (but we can't reset that variable right here, since
+ * we might not change files at all).
*/
lastPageTLI = 0; /* see comment in ValidXLOGHeader */
randAccess = true; /* allow curFileTLI to go backwards too */
@@ -2741,9 +2726,9 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
if (targetRecOff == 0)
{
/*
- * Can only get here in the continuing-from-prev-page case,
- * because XRecOffIsValid eliminated the zero-page-offset case
- * otherwise. Need to skip over the new page's header.
+ * Can only get here in the continuing-from-prev-page case, because
+ * XRecOffIsValid eliminated the zero-page-offset case otherwise. Need
+ * to skip over the new page's header.
*/
tmpRecPtr.xrecoff += pageHeaderSize;
targetRecOff = pageHeaderSize;
@@ -2791,14 +2776,14 @@ got_record:;
{
ereport(emode,
(errmsg("invalid resource manager ID %u at %X/%X",
- record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff)));
+ record->xl_rmid, RecPtr->xlogid, RecPtr->xrecoff)));
goto next_record_is_invalid;
}
if (randAccess)
{
/*
- * We can't exactly verify the prev-link, but surely it should be
- * less than the record's own address.
+ * We can't exactly verify the prev-link, but surely it should be less
+ * than the record's own address.
*/
if (!XLByteLT(record->xl_prev, *RecPtr))
{
@@ -2812,9 +2797,9 @@ got_record:;
else
{
/*
- * Record's prev-link should exactly match our previous location.
- * This check guards against torn WAL pages where a stale but
- * valid-looking WAL record starts on a sector boundary.
+ * Record's prev-link should exactly match our previous location. This
+ * check guards against torn WAL pages where a stale but valid-looking
+ * WAL record starts on a sector boundary.
*/
if (!XLByteEQ(record->xl_prev, ReadRecPtr))
{
@@ -2827,11 +2812,10 @@ got_record:;
}
/*
- * Allocate or enlarge readRecordBuf as needed. To avoid useless
- * small increases, round its size to a multiple of BLCKSZ, and make
- * sure it's at least 4*BLCKSZ to start with. (That is enough for all
- * "normal" records, but very large commit or abort records might need
- * more space.)
+ * Allocate or enlarge readRecordBuf as needed. To avoid useless small
+ * increases, round its size to a multiple of BLCKSZ, and make sure it's
+ * at least 4*BLCKSZ to start with. (That is enough for all "normal"
+ * records, but very large commit or abort records might need more space.)
*/
total_len = record->xl_tot_len;
if (total_len > readRecordBufSize)
@@ -2927,7 +2911,7 @@ got_record:;
MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len))
{
nextRecord = (XLogRecord *) ((char *) contrecord +
- MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len));
+ MAXALIGN(SizeOfXLogContRecord + contrecord->xl_rem_len));
}
EndRecPtr.xlogid = readId;
EndRecPtr.xrecoff = readSeg * XLogSegSize + readOff +
@@ -2991,8 +2975,8 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode)
char sysident_str[32];
/*
- * Format sysids separately to keep platform-dependent format
- * code out of the translatable message string.
+ * Format sysids separately to keep platform-dependent format code
+ * out of the translatable message string.
*/
snprintf(fhdrident_str, sizeof(fhdrident_str), UINT64_FORMAT,
longhdr->xlp_sysid);
@@ -3000,15 +2984,15 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode)
ControlFile->system_identifier);
ereport(emode,
(errmsg("WAL file is from different system"),
- errdetail("WAL file SYSID is %s, pg_control SYSID is %s",
- fhdrident_str, sysident_str)));
+ errdetail("WAL file SYSID is %s, pg_control SYSID is %s",
+ fhdrident_str, sysident_str)));
return false;
}
if (longhdr->xlp_seg_size != XLogSegSize)
{
ereport(emode,
(errmsg("WAL file is from different system"),
- errdetail("Incorrect XLOG_SEG_SIZE in page header.")));
+ errdetail("Incorrect XLOG_SEG_SIZE in page header.")));
return false;
}
}
@@ -3018,7 +3002,7 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode)
{
ereport(emode,
(errmsg("unexpected pageaddr %X/%X in log file %u, segment %u, offset %u",
- hdr->xlp_pageaddr.xlogid, hdr->xlp_pageaddr.xrecoff,
+ hdr->xlp_pageaddr.xlogid, hdr->xlp_pageaddr.xrecoff,
readId, readSeg, readOff)));
return false;
}
@@ -3040,9 +3024,9 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode)
* immediate parent's TLI, we should never see TLI go backwards across
* successive pages of a consistent WAL sequence.
*
- * Of course this check should only be applied when advancing
- * sequentially across pages; therefore ReadRecord resets lastPageTLI
- * to zero when going to a random page.
+ * Of course this check should only be applied when advancing sequentially
+ * across pages; therefore ReadRecord resets lastPageTLI to zero when
+ * going to a random page.
*/
if (hdr->xlp_tli < lastPageTLI)
{
@@ -3123,7 +3107,7 @@ readTimeLineHistory(TimeLineID targetTLI)
tli <= (TimeLineID) linitial_int(result))
ereport(FATAL,
(errmsg("invalid data in history file: %s", fline),
- errhint("Timeline IDs must be in increasing sequence.")));
+ errhint("Timeline IDs must be in increasing sequence.")));
/* Build list with newest item first */
result = lcons_int((int) tli, result);
@@ -3137,7 +3121,7 @@ readTimeLineHistory(TimeLineID targetTLI)
targetTLI <= (TimeLineID) linitial_int(result))
ereport(FATAL,
(errmsg("invalid data in history file \"%s\"", path),
- errhint("Timeline IDs must be less than child timeline's ID.")));
+ errhint("Timeline IDs must be less than child timeline's ID.")));
result = lcons_int((int) targetTLI, result);
@@ -3196,8 +3180,8 @@ findNewestTimeLine(TimeLineID startTLI)
TimeLineID probeTLI;
/*
- * The algorithm is just to probe for the existence of timeline
- * history files. XXX is it useful to allow gaps in the sequence?
+ * The algorithm is just to probe for the existence of timeline history
+ * files. XXX is it useful to allow gaps in the sequence?
*/
newestTLI = startTLI;
@@ -3302,14 +3286,13 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
unlink(tmppath);
/*
- * if write didn't set errno, assume problem is no disk
- * space
+ * if write didn't set errno, assume problem is no disk space
*/
errno = save_errno ? save_errno : ENOSPC;
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write to file \"%s\": %m", tmppath)));
+ errmsg("could not write to file \"%s\": %m", tmppath)));
}
}
close(srcfd);
@@ -3454,11 +3437,11 @@ WriteControlFile(void)
FIN_CRC32(ControlFile->crc);
/*
- * We write out BLCKSZ bytes into pg_control, zero-padding the excess
- * over sizeof(ControlFileData). This reduces the odds of
- * premature-EOF errors when reading pg_control. We'll still fail
- * when we check the contents of the file, but hopefully with a more
- * specific error than "couldn't read pg_control".
+ * We write out BLCKSZ bytes into pg_control, zero-padding the excess over
+ * sizeof(ControlFileData). This reduces the odds of premature-EOF errors
+ * when reading pg_control. We'll still fail when we check the contents
+ * of the file, but hopefully with a more specific error than "couldn't
+ * read pg_control".
*/
if (sizeof(ControlFileData) > BLCKSZ)
ereport(PANIC,
@@ -3524,17 +3507,17 @@ ReadControlFile(void)
close(fd);
/*
- * Check for expected pg_control format version. If this is wrong,
- * the CRC check will likely fail because we'll be checking the wrong
- * number of bytes. Complaining about wrong version will probably be
- * more enlightening than complaining about wrong CRC.
+ * Check for expected pg_control format version. If this is wrong, the
+ * CRC check will likely fail because we'll be checking the wrong number
+ * of bytes. Complaining about wrong version will probably be more
+ * enlightening than complaining about wrong CRC.
*/
if (ControlFile->pg_control_version != PG_CONTROL_VERSION)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with PG_CONTROL_VERSION %d,"
- " but the server was compiled with PG_CONTROL_VERSION %d.",
- ControlFile->pg_control_version, PG_CONTROL_VERSION),
+ " but the server was compiled with PG_CONTROL_VERSION %d.",
+ ControlFile->pg_control_version, PG_CONTROL_VERSION),
errhint("It looks like you need to initdb.")));
/* Now check the CRC. */
INIT_CRC32(crc);
@@ -3548,31 +3531,30 @@ ReadControlFile(void)
(errmsg("incorrect checksum in control file")));
/*
- * Do compatibility checking immediately. We do this here for 2
- * reasons:
+ * Do compatibility checking immediately. We do this here for 2 reasons:
*
- * (1) if the database isn't compatible with the backend executable, we
- * want to abort before we can possibly do any damage;
+ * (1) if the database isn't compatible with the backend executable, we want
+ * to abort before we can possibly do any damage;
*
* (2) this code is executed in the postmaster, so the setlocale() will
- * propagate to forked backends, which aren't going to read this file
- * for themselves. (These locale settings are considered critical
+ * propagate to forked backends, which aren't going to read this file for
+ * themselves. (These locale settings are considered critical
* compatibility items because they can affect sort order of indexes.)
*/
if (ControlFile->catalog_version_no != CATALOG_VERSION_NO)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with CATALOG_VERSION_NO %d,"
- " but the server was compiled with CATALOG_VERSION_NO %d.",
- ControlFile->catalog_version_no, CATALOG_VERSION_NO),
+ " but the server was compiled with CATALOG_VERSION_NO %d.",
+ ControlFile->catalog_version_no, CATALOG_VERSION_NO),
errhint("It looks like you need to initdb.")));
if (ControlFile->maxAlign != MAXIMUM_ALIGNOF)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
- errdetail("The database cluster was initialized with MAXALIGN %d,"
- " but the server was compiled with MAXALIGN %d.",
- ControlFile->maxAlign, MAXIMUM_ALIGNOF),
- errhint("It looks like you need to initdb.")));
+ errdetail("The database cluster was initialized with MAXALIGN %d,"
+ " but the server was compiled with MAXALIGN %d.",
+ ControlFile->maxAlign, MAXIMUM_ALIGNOF),
+ errhint("It looks like you need to initdb.")));
if (ControlFile->floatFormat != FLOATFORMAT_VALUE)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
@@ -3581,76 +3563,76 @@ ReadControlFile(void)
if (ControlFile->blcksz != BLCKSZ)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
- errdetail("The database cluster was initialized with BLCKSZ %d,"
- " but the server was compiled with BLCKSZ %d.",
- ControlFile->blcksz, BLCKSZ),
- errhint("It looks like you need to recompile or initdb.")));
+ errdetail("The database cluster was initialized with BLCKSZ %d,"
+ " but the server was compiled with BLCKSZ %d.",
+ ControlFile->blcksz, BLCKSZ),
+ errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->relseg_size != RELSEG_SIZE)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
- errdetail("The database cluster was initialized with RELSEG_SIZE %d,"
- " but the server was compiled with RELSEG_SIZE %d.",
- ControlFile->relseg_size, RELSEG_SIZE),
- errhint("It looks like you need to recompile or initdb.")));
+ errdetail("The database cluster was initialized with RELSEG_SIZE %d,"
+ " but the server was compiled with RELSEG_SIZE %d.",
+ ControlFile->relseg_size, RELSEG_SIZE),
+ errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->xlog_seg_size != XLOG_SEG_SIZE)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with XLOG_SEG_SIZE %d,"
- " but the server was compiled with XLOG_SEG_SIZE %d.",
+ " but the server was compiled with XLOG_SEG_SIZE %d.",
ControlFile->xlog_seg_size, XLOG_SEG_SIZE),
- errhint("It looks like you need to recompile or initdb.")));
+ errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->nameDataLen != NAMEDATALEN)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
- errdetail("The database cluster was initialized with NAMEDATALEN %d,"
- " but the server was compiled with NAMEDATALEN %d.",
- ControlFile->nameDataLen, NAMEDATALEN),
- errhint("It looks like you need to recompile or initdb.")));
+ errdetail("The database cluster was initialized with NAMEDATALEN %d,"
+ " but the server was compiled with NAMEDATALEN %d.",
+ ControlFile->nameDataLen, NAMEDATALEN),
+ errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->indexMaxKeys != INDEX_MAX_KEYS)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with INDEX_MAX_KEYS %d,"
- " but the server was compiled with INDEX_MAX_KEYS %d.",
+ " but the server was compiled with INDEX_MAX_KEYS %d.",
ControlFile->indexMaxKeys, INDEX_MAX_KEYS),
- errhint("It looks like you need to recompile or initdb.")));
+ errhint("It looks like you need to recompile or initdb.")));
#ifdef HAVE_INT64_TIMESTAMP
if (ControlFile->enableIntTimes != TRUE)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized without HAVE_INT64_TIMESTAMP"
- " but the server was compiled with HAVE_INT64_TIMESTAMP."),
- errhint("It looks like you need to recompile or initdb.")));
+ " but the server was compiled with HAVE_INT64_TIMESTAMP."),
+ errhint("It looks like you need to recompile or initdb.")));
#else
if (ControlFile->enableIntTimes != FALSE)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with HAVE_INT64_TIMESTAMP"
- " but the server was compiled without HAVE_INT64_TIMESTAMP."),
- errhint("It looks like you need to recompile or initdb.")));
+ " but the server was compiled without HAVE_INT64_TIMESTAMP."),
+ errhint("It looks like you need to recompile or initdb.")));
#endif
if (ControlFile->localeBuflen != LOCALE_NAME_BUFLEN)
ereport(FATAL,
(errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with LOCALE_NAME_BUFLEN %d,"
- " but the server was compiled with LOCALE_NAME_BUFLEN %d.",
+ " but the server was compiled with LOCALE_NAME_BUFLEN %d.",
ControlFile->localeBuflen, LOCALE_NAME_BUFLEN),
- errhint("It looks like you need to recompile or initdb.")));
+ errhint("It looks like you need to recompile or initdb.")));
if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
ereport(FATAL,
- (errmsg("database files are incompatible with operating system"),
- errdetail("The database cluster was initialized with LC_COLLATE \"%s\","
- " which is not recognized by setlocale().",
- ControlFile->lc_collate),
- errhint("It looks like you need to initdb or install locale support.")));
+ (errmsg("database files are incompatible with operating system"),
+ errdetail("The database cluster was initialized with LC_COLLATE \"%s\","
+ " which is not recognized by setlocale().",
+ ControlFile->lc_collate),
+ errhint("It looks like you need to initdb or install locale support.")));
if (setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL)
ereport(FATAL,
- (errmsg("database files are incompatible with operating system"),
- errdetail("The database cluster was initialized with LC_CTYPE \"%s\","
- " which is not recognized by setlocale().",
- ControlFile->lc_ctype),
- errhint("It looks like you need to initdb or install locale support.")));
+ (errmsg("database files are incompatible with operating system"),
+ errdetail("The database cluster was initialized with LC_CTYPE \"%s\","
+ " which is not recognized by setlocale().",
+ ControlFile->lc_ctype),
+ errhint("It looks like you need to initdb or install locale support.")));
/* Make the fixed locale settings visible as GUC variables, too */
SetConfigOption("lc_collate", ControlFile->lc_collate,
@@ -3719,9 +3701,9 @@ XLOGShmemSize(void)
size = add_size(size, mul_size(BLCKSZ, XLOGbuffers));
/*
- * Note: we don't count ControlFileData, it comes out of the "slop
- * factor" added by CreateSharedMemoryAndSemaphores. This lets us
- * use this routine again below to compute the actual allocation size.
+ * Note: we don't count ControlFileData, it comes out of the "slop factor"
+ * added by CreateSharedMemoryAndSemaphores. This lets us use this
+ * routine again below to compute the actual allocation size.
*/
return size;
@@ -3749,9 +3731,9 @@ XLOGShmemInit(void)
memset(XLogCtl, 0, sizeof(XLogCtlData));
/*
- * Since XLogCtlData contains XLogRecPtr fields, its sizeof should be
- * a multiple of the alignment for same, so no extra alignment padding
- * is needed here.
+ * Since XLogCtlData contains XLogRecPtr fields, its sizeof should be a
+ * multiple of the alignment for same, so no extra alignment padding is
+ * needed here.
*/
allocptr = ((char *) XLogCtl) + sizeof(XLogCtlData);
XLogCtl->xlblocks = (XLogRecPtr *) allocptr;
@@ -3766,18 +3748,19 @@ XLOGShmemInit(void)
memset(XLogCtl->pages, 0, (Size) BLCKSZ * XLOGbuffers);
/*
- * Do basic initialization of XLogCtl shared data. (StartupXLOG will
- * fill in additional info.)
+ * Do basic initialization of XLogCtl shared data. (StartupXLOG will fill
+ * in additional info.)
*/
- XLogCtl->XLogCacheByte = (Size) BLCKSZ * XLOGbuffers;
+ XLogCtl->XLogCacheByte = (Size) BLCKSZ *XLOGbuffers;
+
XLogCtl->XLogCacheBlck = XLOGbuffers - 1;
XLogCtl->Insert.currpage = (XLogPageHeader) (XLogCtl->pages);
SpinLockInit(&XLogCtl->info_lck);
/*
- * If we are not in bootstrap mode, pg_control should already exist.
- * Read and validate it immediately (see comments in ReadControlFile()
- * for the reasons why).
+ * If we are not in bootstrap mode, pg_control should already exist. Read
+ * and validate it immediately (see comments in ReadControlFile() for the
+ * reasons why).
*/
if (!IsBootstrapProcessingMode())
ReadControlFile();
@@ -3801,17 +3784,16 @@ BootStrapXLOG(void)
pg_crc32 crc;
/*
- * Select a hopefully-unique system identifier code for this
- * installation. We use the result of gettimeofday(), including the
- * fractional seconds field, as being about as unique as we can easily
- * get. (Think not to use random(), since it hasn't been seeded and
- * there's no portable way to seed it other than the system clock
- * value...) The upper half of the uint64 value is just the tv_sec
- * part, while the lower half is the XOR of tv_sec and tv_usec. This
- * is to ensure that we don't lose uniqueness unnecessarily if
- * "uint64" is really only 32 bits wide. A person knowing this
- * encoding can determine the initialization time of the installation,
- * which could perhaps be useful sometimes.
+ * Select a hopefully-unique system identifier code for this installation.
+ * We use the result of gettimeofday(), including the fractional seconds
+ * field, as being about as unique as we can easily get. (Think not to
+ * use random(), since it hasn't been seeded and there's no portable way
+ * to seed it other than the system clock value...) The upper half of the
+ * uint64 value is just the tv_sec part, while the lower half is the XOR
+ * of tv_sec and tv_usec. This is to ensure that we don't lose uniqueness
+ * unnecessarily if "uint64" is really only 32 bits wide. A person
+ * knowing this encoding can determine the initialization time of the
+ * installation, which could perhaps be useful sometimes.
*/
gettimeofday(&tv, NULL);
sysidentifier = ((uint64) tv.tv_sec) << 32;
@@ -3821,7 +3803,7 @@ BootStrapXLOG(void)
ThisTimeLineID = 1;
/* page buffer must be aligned suitably for O_DIRECT */
- buffer = (char *) palloc(BLCKSZ + ALIGNOF_XLOG_BUFFER);
+ buffer = (char *) palloc(BLCKSZ + ALIGNOF_XLOG_BUFFER);
page = (XLogPageHeader) TYPEALIGN(ALIGNOF_XLOG_BUFFER, buffer);
memset(page, 0, BLCKSZ);
@@ -3882,18 +3864,18 @@ BootStrapXLOG(void)
errno = ENOSPC;
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not write bootstrap transaction log file: %m")));
+ errmsg("could not write bootstrap transaction log file: %m")));
}
if (pg_fsync(openLogFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not fsync bootstrap transaction log file: %m")));
+ errmsg("could not fsync bootstrap transaction log file: %m")));
if (close(openLogFile))
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not close bootstrap transaction log file: %m")));
+ errmsg("could not close bootstrap transaction log file: %m")));
openLogFile = -1;
@@ -4036,8 +4018,8 @@ readRecoveryCommandFile(void)
recoveryTargetXid = (TransactionId) strtoul(tok2, NULL, 0);
if (errno == EINVAL || errno == ERANGE)
ereport(FATAL,
- (errmsg("recovery_target_xid is not a valid number: \"%s\"",
- tok2)));
+ (errmsg("recovery_target_xid is not a valid number: \"%s\"",
+ tok2)));
ereport(LOG,
(errmsg("recovery_target_xid = %u",
recoveryTargetXid)));
@@ -4056,17 +4038,17 @@ readRecoveryCommandFile(void)
recoveryTargetExact = false;
/*
- * Convert the time string given by the user to the time_t
- * format. We use type abstime's input converter because we
- * know abstime has the same representation as time_t.
+ * Convert the time string given by the user to the time_t format.
+ * We use type abstime's input converter because we know abstime
+ * has the same representation as time_t.
*/
recoveryTargetTime = (time_t)
DatumGetAbsoluteTime(DirectFunctionCall1(abstimein,
- CStringGetDatum(tok2)));
+ CStringGetDatum(tok2)));
ereport(LOG,
(errmsg("recovery_target_time = %s",
- DatumGetCString(DirectFunctionCall1(abstimeout,
- AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime))))));
+ DatumGetCString(DirectFunctionCall1(abstimeout,
+ AbsoluteTimeGetDatum((AbsoluteTime) recoveryTargetTime))))));
}
else if (strcmp(tok1, "recovery_target_inclusive") == 0)
{
@@ -4095,7 +4077,7 @@ readRecoveryCommandFile(void)
ereport(FATAL,
(errmsg("syntax error in recovery command file: %s",
cmdline),
- errhint("Lines should have the format parameter = 'value'.")));
+ errhint("Lines should have the format parameter = 'value'.")));
/* Check that required parameters were supplied */
if (recoveryRestoreCommand == NULL)
@@ -4107,10 +4089,10 @@ readRecoveryCommandFile(void)
InArchiveRecovery = true;
/*
- * If user specified recovery_target_timeline, validate it or compute
- * the "latest" value. We can't do this until after we've gotten the
- * restore command and set InArchiveRecovery, because we need to fetch
- * timeline history files from the archive.
+ * If user specified recovery_target_timeline, validate it or compute the
+ * "latest" value. We can't do this until after we've gotten the restore
+ * command and set InArchiveRecovery, because we need to fetch timeline
+ * history files from the archive.
*/
if (rtliGiven)
{
@@ -4119,8 +4101,8 @@ readRecoveryCommandFile(void)
/* Timeline 1 does not have a history file, all else should */
if (rtli != 1 && !existsTimeLineHistory(rtli))
ereport(FATAL,
- (errmsg("recovery_target_timeline %u does not exist",
- rtli)));
+ (errmsg("recovery_target_timeline %u does not exist",
+ rtli)));
recoveryTargetTLI = rtli;
}
else
@@ -4146,9 +4128,9 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
InArchiveRecovery = false;
/*
- * We should have the ending log segment currently open. Verify, and
- * then close it (to avoid problems on Windows with trying to rename
- * or delete an open file).
+ * We should have the ending log segment currently open. Verify, and then
+ * close it (to avoid problems on Windows with trying to rename or delete
+ * an open file).
*/
Assert(readFile >= 0);
Assert(readId == endLogId);
@@ -4158,17 +4140,17 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
readFile = -1;
/*
- * If the segment was fetched from archival storage, we want to
- * replace the existing xlog segment (if any) with the archival
- * version. This is because whatever is in XLOGDIR is very possibly
- * older than what we have from the archives, since it could have come
- * from restoring a PGDATA backup. In any case, the archival version
- * certainly is more descriptive of what our current database state
- * is, because that is what we replayed from.
+ * If the segment was fetched from archival storage, we want to replace
+ * the existing xlog segment (if any) with the archival version. This is
+ * because whatever is in XLOGDIR is very possibly older than what we have
+ * from the archives, since it could have come from restoring a PGDATA
+ * backup. In any case, the archival version certainly is more
+ * descriptive of what our current database state is, because that is what
+ * we replayed from.
*
- * Note that if we are establishing a new timeline, ThisTimeLineID is
- * already set to the new value, and so we will create a new file
- * instead of overwriting any existing file.
+ * Note that if we are establishing a new timeline, ThisTimeLineID is already
+ * set to the new value, and so we will create a new file instead of
+ * overwriting any existing file.
*/
snprintf(recoveryPath, MAXPGPATH, XLOGDIR "/RECOVERYXLOG");
XLogFilePath(xlogpath, ThisTimeLineID, endLogId, endLogSeg);
@@ -4195,9 +4177,9 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
unlink(recoveryPath); /* ignore any error */
/*
- * If we are establishing a new timeline, we have to copy data
- * from the last WAL segment of the old timeline to create a
- * starting WAL segment for the new timeline.
+ * If we are establishing a new timeline, we have to copy data from
+ * the last WAL segment of the old timeline to create a starting WAL
+ * segment for the new timeline.
*/
if (endTLI != ThisTimeLineID)
XLogFileCopy(endLogId, endLogSeg,
@@ -4205,8 +4187,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
}
/*
- * Let's just make real sure there are not .ready or .done flags
- * posted for the new segment.
+ * Let's just make real sure there are not .ready or .done flags posted
+ * for the new segment.
*/
XLogFileName(xlogpath, ThisTimeLineID, endLogId, endLogSeg);
XLogArchiveCleanup(xlogpath);
@@ -4216,8 +4198,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
unlink(recoveryPath); /* ignore any error */
/*
- * Rename the config file out of the way, so that we don't
- * accidentally re-enter archive recovery mode in a subsequent crash.
+ * Rename the config file out of the way, so that we don't accidentally
+ * re-enter archive recovery mode in a subsequent crash.
*/
unlink(RECOVERY_COMMAND_DONE);
if (rename(RECOVERY_COMMAND_FILE, RECOVERY_COMMAND_DONE) != 0)
@@ -4278,9 +4260,9 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
* transactionid
*
* when testing for an xid, we MUST test for equality only, since
- * transactions are numbered in the order they start, not the
- * order they complete. A higher numbered xid will complete before
- * you about 50% of the time...
+ * transactions are numbered in the order they start, not the order
+ * they complete. A higher numbered xid will complete before you about
+ * 50% of the time...
*/
stopsHere = (record->xl_xid == recoveryTargetXid);
if (stopsHere)
@@ -4289,9 +4271,9 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
else
{
/*
- * there can be many transactions that share the same commit time,
- * so we stop after the last one, if we are inclusive, or stop at
- * the first one if we are exclusive
+ * there can be many transactions that share the same commit time, so
+ * we stop after the last one, if we are inclusive, or stop at the
+ * first one if we are exclusive
*/
if (recoveryTargetInclusive)
stopsHere = (recordXtime > recoveryTargetTime);
@@ -4312,22 +4294,22 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
if (recoveryStopAfter)
ereport(LOG,
(errmsg("recovery stopping after commit of transaction %u, time %s",
- recoveryStopXid, str_time(recoveryStopTime))));
+ recoveryStopXid, str_time(recoveryStopTime))));
else
ereport(LOG,
(errmsg("recovery stopping before commit of transaction %u, time %s",
- recoveryStopXid, str_time(recoveryStopTime))));
+ recoveryStopXid, str_time(recoveryStopTime))));
}
else
{
if (recoveryStopAfter)
ereport(LOG,
(errmsg("recovery stopping after abort of transaction %u, time %s",
- recoveryStopXid, str_time(recoveryStopTime))));
+ recoveryStopXid, str_time(recoveryStopTime))));
else
ereport(LOG,
(errmsg("recovery stopping before abort of transaction %u, time %s",
- recoveryStopXid, str_time(recoveryStopTime))));
+ recoveryStopXid, str_time(recoveryStopTime))));
}
}
@@ -4359,8 +4341,8 @@ StartupXLOG(void)
/*
* Read control file and check XLOG status looks valid.
*
- * Note: in most control paths, *ControlFile is already valid and we need
- * not do ReadControlFile() here, but might as well do it to be sure.
+ * Note: in most control paths, *ControlFile is already valid and we need not
+ * do ReadControlFile() here, but might as well do it to be sure.
*/
ReadControlFile();
@@ -4381,10 +4363,10 @@ StartupXLOG(void)
str_time(ControlFile->time))));
else if (ControlFile->state == DB_IN_RECOVERY)
ereport(LOG,
- (errmsg("database system was interrupted while in recovery at %s",
- str_time(ControlFile->time)),
- errhint("This probably means that some data is corrupted and"
- " you will have to use the last backup for recovery.")));
+ (errmsg("database system was interrupted while in recovery at %s",
+ str_time(ControlFile->time)),
+ errhint("This probably means that some data is corrupted and"
+ " you will have to use the last backup for recovery.")));
else if (ControlFile->state == DB_IN_PRODUCTION)
ereport(LOG,
(errmsg("database system was interrupted at %s",
@@ -4397,8 +4379,8 @@ StartupXLOG(void)
#endif
/*
- * Initialize on the assumption we want to recover to the same
- * timeline that's active according to pg_control.
+ * Initialize on the assumption we want to recover to the same timeline
+ * that's active according to pg_control.
*/
recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;
@@ -4417,7 +4399,7 @@ StartupXLOG(void)
* timeline.
*/
if (!list_member_int(expectedTLIs,
- (int) ControlFile->checkPointCopy.ThisTimeLineID))
+ (int) ControlFile->checkPointCopy.ThisTimeLineID))
ereport(FATAL,
(errmsg("requested timeline %u is not a child of database system timeline %u",
recoveryTargetTLI,
@@ -4426,30 +4408,29 @@ StartupXLOG(void)
if (read_backup_label(&checkPointLoc))
{
/*
- * When a backup_label file is present, we want to roll forward
- * from the checkpoint it identifies, rather than using
- * pg_control.
+ * When a backup_label file is present, we want to roll forward from
+ * the checkpoint it identifies, rather than using pg_control.
*/
record = ReadCheckpointRecord(checkPointLoc, 0);
if (record != NULL)
{
ereport(LOG,
(errmsg("checkpoint record is at %X/%X",
- checkPointLoc.xlogid, checkPointLoc.xrecoff)));
+ checkPointLoc.xlogid, checkPointLoc.xrecoff)));
InRecovery = true; /* force recovery even if SHUTDOWNED */
}
else
{
ereport(PANIC,
- (errmsg("could not locate required checkpoint record"),
- errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".", DataDir)));
+ (errmsg("could not locate required checkpoint record"),
+ errhint("If you are not restoring from a backup, try removing the file \"%s/backup_label\".", DataDir)));
}
}
else
{
/*
- * Get the last valid checkpoint record. If the latest one
- * according to pg_control is broken, try the next-to-last one.
+ * Get the last valid checkpoint record. If the latest one according
+ * to pg_control is broken, try the next-to-last one.
*/
checkPointLoc = ControlFile->checkPoint;
record = ReadCheckpointRecord(checkPointLoc, 1);
@@ -4457,7 +4438,7 @@ StartupXLOG(void)
{
ereport(LOG,
(errmsg("checkpoint record is at %X/%X",
- checkPointLoc.xlogid, checkPointLoc.xrecoff)));
+ checkPointLoc.xlogid, checkPointLoc.xrecoff)));
}
else
{
@@ -4466,14 +4447,13 @@ StartupXLOG(void)
if (record != NULL)
{
ereport(LOG,
- (errmsg("using previous checkpoint record at %X/%X",
- checkPointLoc.xlogid, checkPointLoc.xrecoff)));
- InRecovery = true; /* force recovery even if
- * SHUTDOWNED */
+ (errmsg("using previous checkpoint record at %X/%X",
+ checkPointLoc.xlogid, checkPointLoc.xrecoff)));
+ InRecovery = true; /* force recovery even if SHUTDOWNED */
}
else
ereport(PANIC,
- (errmsg("could not locate a valid checkpoint record")));
+ (errmsg("could not locate a valid checkpoint record")));
}
}
@@ -4482,10 +4462,10 @@ StartupXLOG(void)
wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);
ereport(LOG,
- (errmsg("redo record is at %X/%X; undo record is at %X/%X; shutdown %s",
- checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
- checkPoint.undo.xlogid, checkPoint.undo.xrecoff,
- wasShutdown ? "TRUE" : "FALSE")));
+ (errmsg("redo record is at %X/%X; undo record is at %X/%X; shutdown %s",
+ checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
+ checkPoint.undo.xlogid, checkPoint.undo.xrecoff,
+ wasShutdown ? "TRUE" : "FALSE")));
ereport(LOG,
(errmsg("next transaction ID: %u; next OID: %u",
checkPoint.nextXid, checkPoint.nextOid)));
@@ -4502,9 +4482,9 @@ StartupXLOG(void)
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
/*
- * We must replay WAL entries using the same TimeLineID they were
- * created under, so temporarily adopt the TLI indicated by the
- * checkpoint (see also xlog_redo()).
+ * We must replay WAL entries using the same TimeLineID they were created
+ * under, so temporarily adopt the TLI indicated by the checkpoint (see
+ * also xlog_redo()).
*/
ThisTimeLineID = checkPoint.ThisTimeLineID;
@@ -4518,15 +4498,15 @@ StartupXLOG(void)
/*
* Check whether we need to force recovery from WAL. If it appears to
- * have been a clean shutdown and we did not have a recovery.conf
- * file, then assume no recovery needed.
+ * have been a clean shutdown and we did not have a recovery.conf file,
+ * then assume no recovery needed.
*/
if (XLByteLT(checkPoint.undo, RecPtr) ||
XLByteLT(checkPoint.redo, RecPtr))
{
if (wasShutdown)
ereport(PANIC,
- (errmsg("invalid redo/undo record in shutdown checkpoint")));
+ (errmsg("invalid redo/undo record in shutdown checkpoint")));
InRecovery = true;
}
else if (ControlFile->state != DB_SHUTDOWNED)
@@ -4563,8 +4543,8 @@ StartupXLOG(void)
}
/*
- * Find the first record that logically follows the checkpoint ---
- * it might physically precede it, though.
+ * Find the first record that logically follows the checkpoint --- it
+ * might physically precede it, though.
*/
if (XLByteLT(checkPoint.redo, RecPtr))
{
@@ -4603,7 +4583,7 @@ StartupXLOG(void)
xlog_outrec(buf, record);
strcat(buf, " - ");
RmgrTable[record->xl_rmid].rm_desc(buf,
- record->xl_info, XLogRecGetData(record));
+ record->xl_info, XLogRecGetData(record));
elog(LOG, "%s", buf);
}
#endif
@@ -4621,7 +4601,7 @@ StartupXLOG(void)
/* nextXid must be beyond record's xid */
if (TransactionIdFollowsOrEquals(record->xl_xid,
- ShmemVariableCache->nextXid))
+ ShmemVariableCache->nextXid))
{
ShmemVariableCache->nextXid = record->xl_xid;
TransactionIdAdvance(ShmemVariableCache->nextXid);
@@ -4655,8 +4635,8 @@ StartupXLOG(void)
}
/*
- * Re-fetch the last valid or last applied record, so we can identify
- * the exact endpoint of what we consider the valid portion of WAL.
+ * Re-fetch the last valid or last applied record, so we can identify the
+ * exact endpoint of what we consider the valid portion of WAL.
*/
record = ReadRecord(&LastRec, PANIC);
EndOfLog = EndRecPtr;
@@ -4682,8 +4662,8 @@ StartupXLOG(void)
*
* If we stopped short of the end of WAL during recovery, then we are
* generating a new timeline and must assign it a unique new ID.
- * Otherwise, we can just extend the timeline we were in when we ran
- * out of WAL.
+ * Otherwise, we can just extend the timeline we were in when we ran out
+ * of WAL.
*/
if (needNewTimeLine)
{
@@ -4698,10 +4678,10 @@ StartupXLOG(void)
XLogCtl->ThisTimeLineID = ThisTimeLineID;
/*
- * We are now done reading the old WAL. Turn off archive fetching if
- * it was active, and make a writable copy of the last WAL segment.
- * (Note that we also have a copy of the last block of the old WAL in
- * readBuf; we will use that below.)
+ * We are now done reading the old WAL. Turn off archive fetching if it
+ * was active, and make a writable copy of the last WAL segment. (Note
+ * that we also have a copy of the last block of the old WAL in readBuf;
+ * we will use that below.)
*/
if (InArchiveRecovery)
exitArchiveRecovery(curFileTLI, endLogId, endLogSeg);
@@ -4724,9 +4704,9 @@ StartupXLOG(void)
((EndOfLog.xrecoff - 1) / BLCKSZ + 1) * BLCKSZ;
/*
- * Tricky point here: readBuf contains the *last* block that the
- * LastRec record spans, not the one it starts in. The last block is
- * indeed the one we want to use.
+ * Tricky point here: readBuf contains the *last* block that the LastRec
+ * record spans, not the one it starts in. The last block is indeed the
+ * one we want to use.
*/
Assert(readOff == (XLogCtl->xlblocks[0].xrecoff - BLCKSZ) % XLogSegSize);
memcpy((char *) Insert->currpage, readBuf, BLCKSZ);
@@ -4752,9 +4732,8 @@ StartupXLOG(void)
else
{
/*
- * Whenever Write.LogwrtResult points to exactly the end of a
- * page, Write.curridx must point to the *next* page (see
- * XLogWrite()).
+ * Whenever Write.LogwrtResult points to exactly the end of a page,
+ * Write.curridx must point to the *next* page (see XLogWrite()).
*
* Note: it might seem we should do AdvanceXLInsertBuffer() here, but
* this is sufficient. The first actual attempt to insert a log
@@ -4785,17 +4764,16 @@ StartupXLOG(void)
pgstat_reset_all();
/*
- * Perform a new checkpoint to update our recovery activity to
- * disk.
+ * Perform a new checkpoint to update our recovery activity to disk.
*
- * Note that we write a shutdown checkpoint rather than an on-line
- * one. This is not particularly critical, but since we may be
- * assigning a new TLI, using a shutdown checkpoint allows us to
- * have the rule that TLI only changes in shutdown checkpoints,
- * which allows some extra error checking in xlog_redo.
+ * Note that we write a shutdown checkpoint rather than an on-line one.
+ * This is not particularly critical, but since we may be assigning a
+ * new TLI, using a shutdown checkpoint allows us to have the rule
+ * that TLI only changes in shutdown checkpoints, which allows some
+ * extra error checking in xlog_redo.
*
- * In case we had to use the secondary checkpoint, make sure that it
- * will still be shown as the secondary checkpoint after this
+ * In case we had to use the secondary checkpoint, make sure that it will
+ * still be shown as the secondary checkpoint after this
* CreateCheckPoint operation; we don't want the broken primary
* checkpoint to become prevCheckPoint...
*/
@@ -4810,8 +4788,8 @@ StartupXLOG(void)
XLogCloseRelationCache();
/*
- * Now that we've checkpointed the recovery, it's safe to flush
- * old backup_label, if present.
+ * Now that we've checkpointed the recovery, it's safe to flush old
+ * backup_label, if present.
*/
remove_backup_label();
}
@@ -4878,7 +4856,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt)
{
case 1:
ereport(LOG,
- (errmsg("invalid primary checkpoint link in control file")));
+ (errmsg("invalid primary checkpoint link in control file")));
break;
case 2:
ereport(LOG,
@@ -4886,7 +4864,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt)
break;
default:
ereport(LOG,
- (errmsg("invalid checkpoint link in backup_label file")));
+ (errmsg("invalid checkpoint link in backup_label file")));
break;
}
return NULL;
@@ -4927,7 +4905,7 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt)
break;
default:
ereport(LOG,
- (errmsg("invalid resource manager ID in checkpoint record")));
+ (errmsg("invalid resource manager ID in checkpoint record")));
break;
}
return NULL;
@@ -4939,11 +4917,11 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt)
{
case 1:
ereport(LOG,
- (errmsg("invalid xl_info in primary checkpoint record")));
+ (errmsg("invalid xl_info in primary checkpoint record")));
break;
case 2:
ereport(LOG,
- (errmsg("invalid xl_info in secondary checkpoint record")));
+ (errmsg("invalid xl_info in secondary checkpoint record")));
break;
default:
ereport(LOG,
@@ -4959,11 +4937,11 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt)
{
case 1:
ereport(LOG,
- (errmsg("invalid length of primary checkpoint record")));
+ (errmsg("invalid length of primary checkpoint record")));
break;
case 2:
ereport(LOG,
- (errmsg("invalid length of secondary checkpoint record")));
+ (errmsg("invalid length of secondary checkpoint record")));
break;
default:
ereport(LOG,
@@ -5084,10 +5062,10 @@ CreateCheckPoint(bool shutdown, bool force)
int nsegsrecycled = 0;
/*
- * Acquire CheckpointLock to ensure only one checkpoint happens at a
- * time. (This is just pro forma, since in the present system
- * structure there is only one process that is allowed to issue
- * checkpoints at any given time.)
+ * Acquire CheckpointLock to ensure only one checkpoint happens at a time.
+ * (This is just pro forma, since in the present system structure there is
+ * only one process that is allowed to issue checkpoints at any given
+ * time.)
*/
LWLockAcquire(CheckpointLock, LW_EXCLUSIVE);
@@ -5108,10 +5086,10 @@ CreateCheckPoint(bool shutdown, bool force)
checkPoint.time = time(NULL);
/*
- * We must hold CheckpointStartLock while determining the checkpoint
- * REDO pointer. This ensures that any concurrent transaction commits
- * will be either not yet logged, or logged and recorded in pg_clog.
- * See notes in RecordTransactionCommit().
+ * We must hold CheckpointStartLock while determining the checkpoint REDO
+ * pointer. This ensures that any concurrent transaction commits will be
+ * either not yet logged, or logged and recorded in pg_clog. See notes in
+ * RecordTransactionCommit().
*/
LWLockAcquire(CheckpointStartLock, LW_EXCLUSIVE);
@@ -5119,20 +5097,19 @@ CreateCheckPoint(bool shutdown, bool force)
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
/*
- * If this isn't a shutdown or forced checkpoint, and we have not
- * inserted any XLOG records since the start of the last checkpoint,
- * skip the checkpoint. The idea here is to avoid inserting duplicate
- * checkpoints when the system is idle. That wastes log space, and
- * more importantly it exposes us to possible loss of both current and
- * previous checkpoint records if the machine crashes just as we're
- * writing the update. (Perhaps it'd make even more sense to
- * checkpoint only when the previous checkpoint record is in a
- * different xlog page?)
+ * If this isn't a shutdown or forced checkpoint, and we have not inserted
+ * any XLOG records since the start of the last checkpoint, skip the
+ * checkpoint. The idea here is to avoid inserting duplicate checkpoints
+ * when the system is idle. That wastes log space, and more importantly it
+ * exposes us to possible loss of both current and previous checkpoint
+ * records if the machine crashes just as we're writing the update.
+ * (Perhaps it'd make even more sense to checkpoint only when the previous
+ * checkpoint record is in a different xlog page?)
*
- * We have to make two tests to determine that nothing has happened since
- * the start of the last checkpoint: current insertion point must
- * match the end of the last checkpoint record, and its redo pointer
- * must point to itself.
+ * We have to make two tests to determine that nothing has happened since the
+ * start of the last checkpoint: current insertion point must match the
+ * end of the last checkpoint record, and its redo pointer must point to
+ * itself.
*/
if (!shutdown && !force)
{
@@ -5158,10 +5135,10 @@ CreateCheckPoint(bool shutdown, bool force)
/*
* Compute new REDO record ptr = location of next XLOG record.
*
- * NB: this is NOT necessarily where the checkpoint record itself will
- * be, since other backends may insert more XLOG records while we're
- * off doing the buffer flush work. Those XLOG records are logically
- * after the checkpoint, even though physically before it. Got that?
+ * NB: this is NOT necessarily where the checkpoint record itself will be,
+ * since other backends may insert more XLOG records while we're off doing
+ * the buffer flush work. Those XLOG records are logically after the
+ * checkpoint, even though physically before it. Got that?
*/
freespace = INSERT_FREESPACE(Insert);
if (freespace < SizeOfXLogRecord)
@@ -5173,16 +5150,15 @@ CreateCheckPoint(bool shutdown, bool force)
INSERT_RECPTR(checkPoint.redo, Insert, Insert->curridx);
/*
- * Here we update the shared RedoRecPtr for future XLogInsert calls;
- * this must be done while holding the insert lock AND the info_lck.
+ * Here we update the shared RedoRecPtr for future XLogInsert calls; this
+ * must be done while holding the insert lock AND the info_lck.
*
* Note: if we fail to complete the checkpoint, RedoRecPtr will be left
- * pointing past where it really needs to point. This is okay; the
- * only consequence is that XLogInsert might back up whole buffers
- * that it didn't really need to. We can't postpone advancing
- * RedoRecPtr because XLogInserts that happen while we are dumping
- * buffers must assume that their buffer changes are not included in
- * the checkpoint.
+ * pointing past where it really needs to point. This is okay; the only
+ * consequence is that XLogInsert might back up whole buffers that it
+ * didn't really need to. We can't postpone advancing RedoRecPtr because
+ * XLogInserts that happen while we are dumping buffers must assume that
+ * their buffer changes are not included in the checkpoint.
*/
{
/* use volatile pointer to prevent code rearrangement */
@@ -5219,15 +5195,15 @@ CreateCheckPoint(bool shutdown, bool force)
&checkPoint.nextMultiOffset);
/*
- * Having constructed the checkpoint record, ensure all shmem disk
- * buffers and commit-log buffers are flushed to disk.
+ * Having constructed the checkpoint record, ensure all shmem disk buffers
+ * and commit-log buffers are flushed to disk.
*
- * This I/O could fail for various reasons. If so, we will fail to
- * complete the checkpoint, but there is no reason to force a system
- * panic. Accordingly, exit critical section while doing it. (If
- * we are doing a shutdown checkpoint, we probably *should* panic ---
- * but that will happen anyway because we'll still be inside the
- * critical section established by ShutdownXLOG.)
+ * This I/O could fail for various reasons. If so, we will fail to complete
+ * the checkpoint, but there is no reason to force a system panic.
+ * Accordingly, exit critical section while doing it. (If we are doing a
+ * shutdown checkpoint, we probably *should* panic --- but that will
+ * happen anyway because we'll still be inside the critical section
+ * established by ShutdownXLOG.)
*/
END_CRIT_SECTION();
@@ -5260,8 +5236,8 @@ CreateCheckPoint(bool shutdown, bool force)
XLogFlush(recptr);
/*
- * We now have ProcLastRecPtr = start of actual checkpoint record,
- * recptr = end of actual checkpoint record.
+ * We now have ProcLastRecPtr = start of actual checkpoint record, recptr
+ * = end of actual checkpoint record.
*/
if (shutdown && !XLByteEQ(checkPoint.redo, ProcLastRecPtr))
ereport(PANIC,
@@ -5287,8 +5263,8 @@ CreateCheckPoint(bool shutdown, bool force)
LWLockRelease(ControlFileLock);
/*
- * We are now done with critical updates; no need for system panic if
- * we have trouble while fooling with offline log segments.
+ * We are now done with critical updates; no need for system panic if we
+ * have trouble while fooling with offline log segments.
*/
END_CRIT_SECTION();
@@ -5304,19 +5280,18 @@ CreateCheckPoint(bool shutdown, bool force)
}
/*
- * Make more log segments if needed. (Do this after deleting offline
- * log segments, to avoid having peak disk space usage higher than
- * necessary.)
+ * Make more log segments if needed. (Do this after deleting offline log
+ * segments, to avoid having peak disk space usage higher than necessary.)
*/
if (!shutdown)
nsegsadded = PreallocXlogFiles(recptr);
/*
- * Truncate pg_subtrans if possible. We can throw away all data
- * before the oldest XMIN of any running transaction. No future
- * transaction will attempt to reference any pg_subtrans entry older
- * than that (see Asserts in subtrans.c). During recovery, though, we
- * mustn't do this because StartupSUBTRANS hasn't been called yet.
+ * Truncate pg_subtrans if possible. We can throw away all data before
+ * the oldest XMIN of any running transaction. No future transaction will
+ * attempt to reference any pg_subtrans entry older than that (see Asserts
+ * in subtrans.c). During recovery, though, we mustn't do this because
+ * StartupSUBTRANS hasn't been called yet.
*/
if (!InRecovery)
TruncateSUBTRANS(GetOldestXmin(true));
@@ -5342,13 +5317,14 @@ XLogPutNextOid(Oid nextOid)
rdata.buffer = InvalidBuffer;
rdata.next = NULL;
(void) XLogInsert(RM_XLOG_ID, XLOG_NEXTOID, &rdata);
+
/*
* We need not flush the NEXTOID record immediately, because any of the
- * just-allocated OIDs could only reach disk as part of a tuple insert
- * or update that would have its own XLOG record that must follow the
- * NEXTOID record. Therefore, the standard buffer LSN interlock applied
- * to those records will ensure no such OID reaches disk before the
- * NEXTOID record does.
+ * just-allocated OIDs could only reach disk as part of a tuple insert or
+ * update that would have its own XLOG record that must follow the NEXTOID
+ * record. Therefore, the standard buffer LSN interlock applied to those
+ * records will ensure no such OID reaches disk before the NEXTOID record
+ * does.
*/
}
@@ -5384,8 +5360,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
checkPoint.nextMultiOffset);
/*
- * TLI may change in a shutdown checkpoint, but it shouldn't
- * decrease
+ * TLI may change in a shutdown checkpoint, but it shouldn't decrease
*/
if (checkPoint.ThisTimeLineID != ThisTimeLineID)
{
@@ -5394,7 +5369,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
(int) checkPoint.ThisTimeLineID))
ereport(PANIC,
(errmsg("unexpected timeline ID %u (after %u) in checkpoint record",
- checkPoint.ThisTimeLineID, ThisTimeLineID)));
+ checkPoint.ThisTimeLineID, ThisTimeLineID)));
/* Following WAL records should be run with new TLI */
ThisTimeLineID = checkPoint.ThisTimeLineID;
}
@@ -5441,7 +5416,7 @@ xlog_desc(char *buf, uint8 xl_info, char *rec)
checkpoint->nextOid,
checkpoint->nextMulti,
checkpoint->nextMultiOffset,
- (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
+ (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
}
else if (info == XLOG_NEXTOID)
{
@@ -5535,23 +5510,23 @@ assign_xlog_sync_method(const char *method, bool doit, GucSource source)
/*
* To ensure that no blocks escape unsynced, force an fsync on the
* currently open log segment (if any). Also, if the open flag is
- * changing, close the log file so it will be reopened (with new
- * flag bit) at next use.
+ * changing, close the log file so it will be reopened (with new flag
+ * bit) at next use.
*/
if (openLogFile >= 0)
{
if (pg_fsync(openLogFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not fsync log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not fsync log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
if (open_sync_bit != new_sync_bit)
{
if (close(openLogFile))
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not close log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not close log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
openLogFile = -1;
}
}
@@ -5575,16 +5550,16 @@ issue_xlog_fsync(void)
if (pg_fsync_no_writethrough(openLogFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not fsync log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not fsync log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
break;
#ifdef HAVE_FSYNC_WRITETHROUGH
case SYNC_METHOD_FSYNC_WRITETHROUGH:
if (pg_fsync_writethrough(openLogFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not fsync write-through log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not fsync write-through log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
break;
#endif
#ifdef HAVE_FDATASYNC
@@ -5592,8 +5567,8 @@ issue_xlog_fsync(void)
if (pg_fdatasync(openLogFile) != 0)
ereport(PANIC,
(errcode_for_file_access(),
- errmsg("could not fdatasync log file %u, segment %u: %m",
- openLogId, openLogSeg)));
+ errmsg("could not fdatasync log file %u, segment %u: %m",
+ openLogId, openLogSeg)));
break;
#endif
case SYNC_METHOD_OPEN:
@@ -5640,25 +5615,25 @@ pg_start_backup(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
(errmsg("WAL archiving is not active"),
- (errhint("archive_command must be defined before "
- "online backups can be made safely.")))));
+ (errhint("archive_command must be defined before "
+ "online backups can be made safely.")))));
backupidstr = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(backupid)));
+ PointerGetDatum(backupid)));
/*
- * Force a CHECKPOINT. This is not strictly necessary, but it seems
- * like a good idea to minimize the amount of past WAL needed to use
- * the backup. Also, this guarantees that two successive backup runs
- * will have different checkpoint positions and hence different
- * history file names, even if nothing happened in between.
+ * Force a CHECKPOINT. This is not strictly necessary, but it seems like
+ * a good idea to minimize the amount of past WAL needed to use the
+ * backup. Also, this guarantees that two successive backup runs will
+ * have different checkpoint positions and hence different history file
+ * names, even if nothing happened in between.
*/
RequestCheckpoint(true, false);
/*
- * Now we need to fetch the checkpoint record location, and also its
- * REDO pointer. The oldest point in WAL that would be needed to
- * restore starting from the checkpoint is precisely the REDO pointer.
+ * Now we need to fetch the checkpoint record location, and also its REDO
+ * pointer. The oldest point in WAL that would be needed to restore
+ * starting from the checkpoint is precisely the REDO pointer.
*/
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
checkpointloc = ControlFile->checkPoint;
@@ -5669,10 +5644,10 @@ pg_start_backup(PG_FUNCTION_ARGS)
XLogFileName(xlogfilename, ThisTimeLineID, _logId, _logSeg);
/*
- * We deliberately use strftime/localtime not the src/timezone
- * functions, so that backup labels will consistently be recorded in
- * the same timezone regardless of TimeZone setting. This matches
- * elog.c's practice.
+ * We deliberately use strftime/localtime not the src/timezone functions,
+ * so that backup labels will consistently be recorded in the same
+ * timezone regardless of TimeZone setting. This matches elog.c's
+ * practice.
*/
stamp_time = time(NULL);
strftime(strfbuf, sizeof(strfbuf),
@@ -5680,8 +5655,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
localtime(&stamp_time));
/*
- * Check for existing backup label --- implies a backup is already
- * running
+ * Check for existing backup label --- implies a backup is already running
*/
if (stat(BACKUP_LABEL_FILE, &stat_buf) != 0)
{
@@ -5725,7 +5699,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
snprintf(xlogfilename, sizeof(xlogfilename), "%X/%X",
startpoint.xlogid, startpoint.xrecoff);
result = DatumGetTextP(DirectFunctionCall1(textin,
- CStringGetDatum(xlogfilename)));
+ CStringGetDatum(xlogfilename)));
PG_RETURN_TEXT_P(result);
}
@@ -5762,8 +5736,8 @@ pg_stop_backup(PG_FUNCTION_ARGS)
(errmsg("must be superuser to run a backup"))));
/*
- * Get the current end-of-WAL position; it will be unsafe to use this
- * dump to restore to a point in advance of this time.
+ * Get the current end-of-WAL position; it will be unsafe to use this dump
+ * to restore to a point in advance of this time.
*/
LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
INSERT_RECPTR(stoppoint, Insert, Insert->curridx);
@@ -5773,10 +5747,10 @@ pg_stop_backup(PG_FUNCTION_ARGS)
XLogFileName(stopxlogfilename, ThisTimeLineID, _logId, _logSeg);
/*
- * We deliberately use strftime/localtime not the src/timezone
- * functions, so that backup labels will consistently be recorded in
- * the same timezone regardless of TimeZone setting. This matches
- * elog.c's practice.
+ * We deliberately use strftime/localtime not the src/timezone functions,
+ * so that backup labels will consistently be recorded in the same
+ * timezone regardless of TimeZone setting. This matches elog.c's
+ * practice.
*/
stamp_time = time(NULL);
strftime(strfbuf, sizeof(strfbuf),
@@ -5800,9 +5774,8 @@ pg_stop_backup(PG_FUNCTION_ARGS)
}
/*
- * Read and parse the START WAL LOCATION line (this code is pretty
- * crude, but we are not expecting any variability in the file
- * format).
+ * Read and parse the START WAL LOCATION line (this code is pretty crude,
+ * but we are not expecting any variability in the file format).
*/
if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %24s)%c",
&startpoint.xlogid, &startpoint.xrecoff, startxlogfilename,
@@ -5869,7 +5842,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
snprintf(stopxlogfilename, sizeof(stopxlogfilename), "%X/%X",
stoppoint.xlogid, stoppoint.xrecoff);
result = DatumGetTextP(DirectFunctionCall1(textin,
- CStringGetDatum(stopxlogfilename)));
+ CStringGetDatum(stopxlogfilename)));
PG_RETURN_TEXT_P(result);
}
@@ -5921,9 +5894,9 @@ read_backup_label(XLogRecPtr *checkPointLoc)
}
/*
- * Read and parse the START WAL LOCATION and CHECKPOINT lines (this
- * code is pretty crude, but we are not expecting any variability in
- * the file format).
+ * Read and parse the START WAL LOCATION and CHECKPOINT lines (this code
+ * is pretty crude, but we are not expecting any variability in the file
+ * format).
*/
if (fscanf(lfp, "START WAL LOCATION: %X/%X (file %08X%16s)%c",
&startpoint.xlogid, &startpoint.xrecoff, &tli,
@@ -5963,17 +5936,17 @@ read_backup_label(XLogRecPtr *checkPointLoc)
* Parse history file to identify stop point.
*/
if (fscanf(fp, "START WAL LOCATION: %X/%X (file %24s)%c",
- &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename,
+ &startpoint.xlogid, &startpoint.xrecoff, startxlogfilename,
&ch) != 4 || ch != '\n')
ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("invalid data in file \"%s\"", histfilename)));
+ errmsg("invalid data in file \"%s\"", histfilename)));
if (fscanf(fp, "STOP WAL LOCATION: %X/%X (file %24s)%c",
- &stoppoint.xlogid, &stoppoint.xrecoff, stopxlogfilename,
+ &stoppoint.xlogid, &stoppoint.xrecoff, stopxlogfilename,
&ch) != 4 || ch != '\n')
ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("invalid data in file \"%s\"", histfilename)));
+ errmsg("invalid data in file \"%s\"", histfilename)));
recoveryMinXlogOffset = stoppoint;
if (ferror(fp) || FreeFile(fp))
ereport(FATAL,
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index 55caf84a04..485aa52474 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.38 2005/06/06 17:01:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.39 2005/10/15 02:49:11 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -121,7 +121,7 @@ _xl_remove_hash_entry(XLogRelDesc *rdesc)
rdesc->moreRecently->lessRecently = rdesc->lessRecently;
hentry = (XLogRelCacheEntry *) hash_search(_xlrelcache,
- (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL);
+ (void *) &(rdesc->reldata.rd_node), HASH_REMOVE, NULL);
if (hentry == NULL)
elog(PANIC, "_xl_remove_hash_entry: file was not found in cache");
@@ -211,11 +211,11 @@ XLogOpenRelation(RelFileNode rnode)
res->reldata.rd_node = rnode;
/*
- * We set up the lockRelId in case anything tries to lock the
- * dummy relation. Note that this is fairly bogus since relNode
- * may be different from the relation's OID. It shouldn't really
- * matter though, since we are presumably running by ourselves and
- * can't have any lock conflicts ...
+ * We set up the lockRelId in case anything tries to lock the dummy
+ * relation. Note that this is fairly bogus since relNode may be
+ * different from the relation's OID. It shouldn't really matter
+ * though, since we are presumably running by ourselves and can't have
+ * any lock conflicts ...
*/
res->reldata.rd_lockInfo.lockRelId.dbId = rnode.dbNode;
res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode;
@@ -233,13 +233,13 @@ XLogOpenRelation(RelFileNode rnode)
RelationOpenSmgr(&(res->reldata));
/*
- * Create the target file if it doesn't already exist. This lets
- * us cope if the replay sequence contains writes to a relation
- * that is later deleted. (The original coding of this routine
- * would instead return NULL, causing the writes to be suppressed.
- * But that seems like it risks losing valuable data if the
- * filesystem loses an inode during a crash. Better to write the
- * data until we are actually told to delete the file.)
+ * Create the target file if it doesn't already exist. This lets us
+ * cope if the replay sequence contains writes to a relation that is
+ * later deleted. (The original coding of this routine would instead
+ * return NULL, causing the writes to be suppressed. But that seems
+ * like it risks losing valuable data if the filesystem loses an inode
+ * during a crash. Better to write the data until we are actually
+ * told to delete the file.)
*/
smgrcreate(res->reldata.rd_smgr, res->reldata.rd_istemp, true);
}