mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
pgindent run. Make it all clean.
This commit is contained in:
@@ -9,21 +9,21 @@
|
||||
#include "storage/smgr.h"
|
||||
#include "commands/sequence.h"
|
||||
|
||||
RmgrData RmgrTable[] = {
|
||||
{"XLOG", xlog_redo, xlog_undo, xlog_desc},
|
||||
{"Transaction", xact_redo, xact_undo, xact_desc},
|
||||
{"Storage", smgr_redo, smgr_undo, smgr_desc},
|
||||
{"Reserved 3", NULL, NULL, NULL},
|
||||
{"Reserved 4", NULL, NULL, NULL},
|
||||
{"Reserved 5", NULL, NULL, NULL},
|
||||
{"Reserved 6", NULL, NULL, NULL},
|
||||
{"Reserved 7", NULL, NULL, NULL},
|
||||
{"Reserved 8", NULL, NULL, NULL},
|
||||
{"Reserved 9", NULL, NULL, NULL},
|
||||
{"Heap", heap_redo, heap_undo, heap_desc},
|
||||
{"Btree", btree_redo, btree_undo, btree_desc},
|
||||
{"Hash", hash_redo, hash_undo, hash_desc},
|
||||
{"Rtree", rtree_redo, rtree_undo, rtree_desc},
|
||||
{"Gist", gist_redo, gist_undo, gist_desc},
|
||||
{"Sequence", seq_redo, seq_undo, seq_desc}
|
||||
RmgrData RmgrTable[] = {
|
||||
{"XLOG", xlog_redo, xlog_undo, xlog_desc},
|
||||
{"Transaction", xact_redo, xact_undo, xact_desc},
|
||||
{"Storage", smgr_redo, smgr_undo, smgr_desc},
|
||||
{"Reserved 3", NULL, NULL, NULL},
|
||||
{"Reserved 4", NULL, NULL, NULL},
|
||||
{"Reserved 5", NULL, NULL, NULL},
|
||||
{"Reserved 6", NULL, NULL, NULL},
|
||||
{"Reserved 7", NULL, NULL, NULL},
|
||||
{"Reserved 8", NULL, NULL, NULL},
|
||||
{"Reserved 9", NULL, NULL, NULL},
|
||||
{"Heap", heap_redo, heap_undo, heap_desc},
|
||||
{"Btree", btree_redo, btree_undo, btree_desc},
|
||||
{"Hash", hash_redo, hash_undo, hash_desc},
|
||||
{"Rtree", rtree_redo, rtree_undo, rtree_desc},
|
||||
{"Gist", gist_redo, gist_undo, gist_desc},
|
||||
{"Sequence", seq_redo, seq_undo, seq_desc}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.41 2001/03/18 20:18:59 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.42 2001/03/22 03:59:17 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains the high level access-method interface to the
|
||||
@@ -427,8 +427,8 @@ InitializeTransactionLog(void)
|
||||
TransactionLogUpdate(AmiTransactionId, XID_COMMIT);
|
||||
TransactionIdStore(AmiTransactionId, &cachedTestXid);
|
||||
cachedTestXidStatus = XID_COMMIT;
|
||||
Assert(!IsUnderPostmaster &&
|
||||
ShmemVariableCache->nextXid <= FirstTransactionId);
|
||||
Assert(!IsUnderPostmaster &&
|
||||
ShmemVariableCache->nextXid <= FirstTransactionId);
|
||||
ShmemVariableCache->nextXid = FirstTransactionId;
|
||||
}
|
||||
else if (RecoveryCheckingEnabled())
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.28 2001/01/24 19:42:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.29 2001/03/22 03:59:17 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains support functions for the high
|
||||
@@ -186,7 +186,7 @@ TransBlockGetXidStatus(Block tblock,
|
||||
bits8 bit2;
|
||||
BitIndex offset;
|
||||
|
||||
tblock = (Block) ((char*) tblock + sizeof(XLogRecPtr));
|
||||
tblock = (Block) ((char *) tblock + sizeof(XLogRecPtr));
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
@@ -229,7 +229,7 @@ TransBlockSetXidStatus(Block tblock,
|
||||
Index index;
|
||||
BitIndex offset;
|
||||
|
||||
tblock = (Block) ((char*) tblock + sizeof(XLogRecPtr));
|
||||
tblock = (Block) ((char *) tblock + sizeof(XLogRecPtr));
|
||||
|
||||
/* ----------------
|
||||
* calculate the index into the transaction data where
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2000, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.37 2001/03/18 20:18:59 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.38 2001/03/22 03:59:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -23,8 +23,8 @@
|
||||
#define VAR_OID_PREFETCH 8192
|
||||
|
||||
/* Spinlocks for serializing generation of XIDs and OIDs, respectively */
|
||||
SPINLOCK XidGenLockId;
|
||||
SPINLOCK OidGenLockId;
|
||||
SPINLOCK XidGenLockId;
|
||||
SPINLOCK OidGenLockId;
|
||||
|
||||
/* pointer to "variable cache" in shared memory (set up by shmem.c) */
|
||||
VariableCache ShmemVariableCache = NULL;
|
||||
@@ -32,9 +32,10 @@ VariableCache ShmemVariableCache = NULL;
|
||||
void
|
||||
GetNewTransactionId(TransactionId *xid)
|
||||
{
|
||||
|
||||
/*
|
||||
* During bootstrap initialization, we return the special
|
||||
* bootstrap transaction id.
|
||||
* During bootstrap initialization, we return the special bootstrap
|
||||
* transaction id.
|
||||
*/
|
||||
if (AMI_OVERRIDE)
|
||||
{
|
||||
@@ -60,9 +61,10 @@ GetNewTransactionId(TransactionId *xid)
|
||||
void
|
||||
ReadNewTransactionId(TransactionId *xid)
|
||||
{
|
||||
|
||||
/*
|
||||
* During bootstrap initialization, we return the special
|
||||
* bootstrap transaction id.
|
||||
* During bootstrap initialization, we return the special bootstrap
|
||||
* transaction id.
|
||||
*/
|
||||
if (AMI_OVERRIDE)
|
||||
{
|
||||
@@ -80,7 +82,7 @@ ReadNewTransactionId(TransactionId *xid)
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static Oid lastSeenOid = InvalidOid;
|
||||
static Oid lastSeenOid = InvalidOid;
|
||||
|
||||
void
|
||||
GetNewObjectId(Oid *oid_return)
|
||||
@@ -119,10 +121,10 @@ CheckMaxObjectId(Oid assigned_oid)
|
||||
}
|
||||
|
||||
/* If we are in the logged oid range, just bump nextOid up */
|
||||
if (assigned_oid <= ShmemVariableCache->nextOid +
|
||||
ShmemVariableCache->oidCount - 1)
|
||||
if (assigned_oid <= ShmemVariableCache->nextOid +
|
||||
ShmemVariableCache->oidCount - 1)
|
||||
{
|
||||
ShmemVariableCache->oidCount -=
|
||||
ShmemVariableCache->oidCount -=
|
||||
assigned_oid - ShmemVariableCache->nextOid + 1;
|
||||
ShmemVariableCache->nextOid = assigned_oid + 1;
|
||||
SpinRelease(OidGenLockId);
|
||||
@@ -130,10 +132,9 @@ CheckMaxObjectId(Oid assigned_oid)
|
||||
}
|
||||
|
||||
/*
|
||||
* We have exceeded the logged oid range.
|
||||
* We should lock the database and kill all other backends
|
||||
* but we are loading oid's that we can not guarantee are unique
|
||||
* anyway, so we must rely on the user.
|
||||
* We have exceeded the logged oid range. We should lock the database
|
||||
* and kill all other backends but we are loading oid's that we can
|
||||
* not guarantee are unique anyway, so we must rely on the user.
|
||||
*/
|
||||
|
||||
XLogPutNextOid(assigned_oid + VAR_OID_PREFETCH);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.99 2001/03/13 01:17:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.100 2001/03/22 03:59:18 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@@ -222,9 +222,10 @@ int DefaultXactIsoLevel = XACT_READ_COMMITTED;
|
||||
int XactIsoLevel;
|
||||
|
||||
int CommitDelay = 0; /* precommit delay in microseconds */
|
||||
int CommitSiblings = 5; /* number of concurrent xacts needed to sleep */
|
||||
int CommitSiblings = 5; /* number of concurrent xacts needed to
|
||||
* sleep */
|
||||
|
||||
static void (*_RollbackFunc)(void*) = NULL;
|
||||
static void (*_RollbackFunc) (void *) = NULL;
|
||||
static void *_RollbackData = NULL;
|
||||
|
||||
/* ----------------
|
||||
@@ -666,39 +667,40 @@ RecordTransactionCommit()
|
||||
|
||||
if (MyLastRecPtr.xrecoff != 0)
|
||||
{
|
||||
XLogRecData rdata;
|
||||
xl_xact_commit xlrec;
|
||||
XLogRecPtr recptr;
|
||||
XLogRecData rdata;
|
||||
xl_xact_commit xlrec;
|
||||
XLogRecPtr recptr;
|
||||
|
||||
BufmgrCommit();
|
||||
|
||||
xlrec.xtime = time(NULL);
|
||||
rdata.buffer = InvalidBuffer;
|
||||
rdata.data = (char *)(&xlrec);
|
||||
rdata.data = (char *) (&xlrec);
|
||||
rdata.len = SizeOfXactCommit;
|
||||
rdata.next = NULL;
|
||||
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/*
|
||||
* SHOULD SAVE ARRAY OF RELFILENODE-s TO DROP
|
||||
*/
|
||||
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_COMMIT, &rdata);
|
||||
|
||||
/*
|
||||
* Sleep before commit! 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.)
|
||||
/*
|
||||
* Sleep before commit! 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.)
|
||||
*
|
||||
* 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 &&
|
||||
CountActiveBackends() >= CommitSiblings)
|
||||
{
|
||||
struct timeval delay;
|
||||
struct timeval delay;
|
||||
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_usec = CommitDelay;
|
||||
@@ -812,13 +814,13 @@ RecordTransactionAbort(void)
|
||||
*/
|
||||
if (MyLastRecPtr.xrecoff != 0 && !TransactionIdDidCommit(xid))
|
||||
{
|
||||
XLogRecData rdata;
|
||||
xl_xact_abort xlrec;
|
||||
XLogRecPtr recptr;
|
||||
XLogRecData rdata;
|
||||
xl_xact_abort xlrec;
|
||||
XLogRecPtr recptr;
|
||||
|
||||
xlrec.xtime = time(NULL);
|
||||
rdata.buffer = InvalidBuffer;
|
||||
rdata.data = (char *)(&xlrec);
|
||||
rdata.data = (char *) (&xlrec);
|
||||
rdata.len = SizeOfXactAbort;
|
||||
rdata.next = NULL;
|
||||
|
||||
@@ -879,7 +881,7 @@ AtAbort_Memory(void)
|
||||
{
|
||||
/* ----------------
|
||||
* Make sure we are in a valid context (not a child of
|
||||
* TransactionCommandContext...). Note that it is possible
|
||||
* TransactionCommandContext...). 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.
|
||||
* ----------------
|
||||
@@ -896,9 +898,7 @@ AtAbort_Memory(void)
|
||||
MemoryContextResetAndDeleteChildren(TransactionCommandContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
MemoryContextSwitchTo(TopMemoryContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1021,6 +1021,7 @@ CurrentXactInProgress(void)
|
||||
{
|
||||
return CurrentTransactionState->state == TRANS_INPROGRESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* --------------------------------
|
||||
@@ -1106,7 +1107,7 @@ CommitTransaction(void)
|
||||
AtCommit_Memory();
|
||||
AtEOXact_Files();
|
||||
|
||||
SharedBufferChanged = false; /* safest place to do it */
|
||||
SharedBufferChanged = false;/* safest place to do it */
|
||||
|
||||
/* ----------------
|
||||
* done with commit processing, set current transaction
|
||||
@@ -1143,15 +1144,16 @@ AbortTransaction(void)
|
||||
|
||||
/*
|
||||
* Release any spinlocks or buffer context locks we might be holding
|
||||
* as quickly as possible. (Real locks, however, must be held till
|
||||
* we finish aborting.) Releasing spinlocks is critical since we
|
||||
* might try to grab them again while cleaning up!
|
||||
* as quickly as possible. (Real locks, however, must be held till we
|
||||
* finish aborting.) Releasing spinlocks is critical since we might
|
||||
* try to grab them again while cleaning up!
|
||||
*/
|
||||
ProcReleaseSpins(NULL);
|
||||
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();
|
||||
|
||||
@@ -1203,7 +1205,7 @@ AbortTransaction(void)
|
||||
AtEOXact_Files();
|
||||
AtAbort_Locks();
|
||||
|
||||
SharedBufferChanged = false; /* safest place to do it */
|
||||
SharedBufferChanged = false;/* safest place to do it */
|
||||
|
||||
/* ----------------
|
||||
* State remains TRANS_ABORT until CleanupTransaction().
|
||||
@@ -1327,8 +1329,8 @@ StartTransactionCommand(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* We must switch to TransactionCommandContext before returning.
|
||||
* This is already done if we called StartTransaction, otherwise not.
|
||||
* We must switch to TransactionCommandContext before returning. This
|
||||
* is already done if we called StartTransaction, otherwise not.
|
||||
*/
|
||||
Assert(TransactionCommandContext != NULL);
|
||||
MemoryContextSwitchTo(TransactionCommandContext);
|
||||
@@ -1757,7 +1759,7 @@ IsTransactionBlock(void)
|
||||
void
|
||||
xact_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
{
|
||||
uint8 info = record->xl_info & ~XLR_INFO_MASK;
|
||||
uint8 info = record->xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_XACT_COMMIT)
|
||||
{
|
||||
@@ -1765,9 +1767,7 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
/* SHOULD REMOVE FILES OF ALL DROPPED RELATIONS */
|
||||
}
|
||||
else if (info == XLOG_XACT_ABORT)
|
||||
{
|
||||
TransactionIdAbort(record->xl_xid);
|
||||
}
|
||||
else
|
||||
elog(STOP, "xact_redo: unknown op code %u", info);
|
||||
}
|
||||
@@ -1775,43 +1775,43 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
void
|
||||
xact_undo(XLogRecPtr lsn, XLogRecord *record)
|
||||
{
|
||||
uint8 info = record->xl_info & ~XLR_INFO_MASK;
|
||||
uint8 info = record->xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_XACT_COMMIT) /* shouldn't be called by XLOG */
|
||||
if (info == XLOG_XACT_COMMIT) /* shouldn't be called by XLOG */
|
||||
elog(STOP, "xact_undo: can't undo committed xaction");
|
||||
else if (info != XLOG_XACT_ABORT)
|
||||
elog(STOP, "xact_redo: unknown op code %u", info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xact_desc(char *buf, uint8 xl_info, char* rec)
|
||||
xact_desc(char *buf, uint8 xl_info, char *rec)
|
||||
{
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_XACT_COMMIT)
|
||||
{
|
||||
xl_xact_commit *xlrec = (xl_xact_commit*) rec;
|
||||
struct tm *tm = localtime(&xlrec->xtime);
|
||||
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
|
||||
struct tm *tm = localtime(&xlrec->xtime);
|
||||
|
||||
sprintf(buf + strlen(buf), "commit: %04u-%02u-%02u %02u:%02u:%02u",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
}
|
||||
else if (info == XLOG_XACT_ABORT)
|
||||
{
|
||||
xl_xact_abort *xlrec = (xl_xact_abort*) rec;
|
||||
struct tm *tm = localtime(&xlrec->xtime);
|
||||
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
|
||||
struct tm *tm = localtime(&xlrec->xtime);
|
||||
|
||||
sprintf(buf + strlen(buf), "abort: %04u-%02u-%02u %02u:%02u:%02u",
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
}
|
||||
else
|
||||
strcat(buf, "UNKNOWN");
|
||||
}
|
||||
|
||||
void
|
||||
XactPushRollback(void (*func) (void *), void* data)
|
||||
XactPushRollback(void (*func) (void *), void *data)
|
||||
{
|
||||
#ifdef XLOG_II
|
||||
if (_RollbackFunc != NULL)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xid.c,v 1.29 2001/01/24 19:42:51 momjian Exp $
|
||||
* $Id: xid.c,v 1.30 2001/03/22 03:59:18 momjian Exp $
|
||||
*
|
||||
* OLD COMMENTS
|
||||
* XXX WARNING
|
||||
@@ -26,8 +26,8 @@
|
||||
/*
|
||||
* TransactionId is typedef'd as uint32, so...
|
||||
*/
|
||||
#define PG_GETARG_TRANSACTIONID(n) PG_GETARG_UINT32(n)
|
||||
#define PG_RETURN_TRANSACTIONID(x) PG_RETURN_UINT32(x)
|
||||
#define PG_GETARG_TRANSACTIONID(n) PG_GETARG_UINT32(n)
|
||||
#define PG_RETURN_TRANSACTIONID(x) PG_RETURN_UINT32(x)
|
||||
|
||||
|
||||
extern TransactionId NullTransactionId;
|
||||
@@ -49,6 +49,7 @@ Datum
|
||||
xidout(PG_FUNCTION_ARGS)
|
||||
{
|
||||
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
|
||||
|
||||
/* maximum 32 bit unsigned integer representation takes 10 chars */
|
||||
char *representation = palloc(11);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.14 2001/03/13 01:17:05 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlogutils.c,v 1.15 2001/03/22 03:59:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,26 +37,26 @@
|
||||
* xaction/command and return
|
||||
*
|
||||
* - -1 if not
|
||||
* - 0 if there is no tuple at all
|
||||
* - 1 if yes
|
||||
* - 0 if there is no tuple at all
|
||||
* - 1 if yes
|
||||
*/
|
||||
int
|
||||
XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
TransactionId xid, CommandId cid)
|
||||
XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
TransactionId xid, CommandId cid)
|
||||
{
|
||||
Relation reln;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
ItemId lp;
|
||||
HeapTupleHeader htup;
|
||||
Relation reln;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
ItemId lp;
|
||||
HeapTupleHeader htup;
|
||||
|
||||
reln = XLogOpenRelation(false, RM_HEAP_ID, hnode);
|
||||
if (!RelationIsValid(reln))
|
||||
return(0);
|
||||
return (0);
|
||||
|
||||
buffer = ReadBuffer(reln, ItemPointerGetBlockNumber(iptr));
|
||||
if (!BufferIsValid(buffer))
|
||||
return(0);
|
||||
return (0);
|
||||
|
||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||
page = (Page) BufferGetPage(buffer);
|
||||
@@ -64,13 +64,13 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr));
|
||||
if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
htup = (HeapTupleHeader) PageGetItem(page, lp);
|
||||
@@ -79,11 +79,11 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
if (htup->t_xmin != xid || htup->t_cmin != cid)
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -95,19 +95,19 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
bool
|
||||
XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
|
||||
{
|
||||
Relation reln;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
ItemId lp;
|
||||
HeapTupleHeader htup;
|
||||
Relation reln;
|
||||
Buffer buffer;
|
||||
Page page;
|
||||
ItemId lp;
|
||||
HeapTupleHeader htup;
|
||||
|
||||
reln = XLogOpenRelation(false, RM_HEAP_ID, hnode);
|
||||
if (!RelationIsValid(reln))
|
||||
return(false);
|
||||
return (false);
|
||||
|
||||
buffer = ReadBuffer(reln, ItemPointerGetBlockNumber(iptr));
|
||||
if (!BufferIsValid(buffer))
|
||||
return(false);
|
||||
return (false);
|
||||
|
||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||
page = (Page) BufferGetPage(buffer);
|
||||
@@ -115,21 +115,21 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
|
||||
ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(false);
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (PageGetSUI(page) != ThisStartUpID)
|
||||
{
|
||||
Assert(PageGetSUI(page) < ThisStartUpID);
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(true);
|
||||
return (true);
|
||||
}
|
||||
|
||||
lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr));
|
||||
if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(false);
|
||||
return (false);
|
||||
}
|
||||
|
||||
htup = (HeapTupleHeader) PageGetItem(page, lp);
|
||||
@@ -140,22 +140,22 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
|
||||
{
|
||||
if (htup->t_infomask & HEAP_XMIN_INVALID ||
|
||||
(htup->t_infomask & HEAP_MOVED_IN &&
|
||||
TransactionIdDidAbort((TransactionId)htup->t_cmin)) ||
|
||||
TransactionIdDidAbort((TransactionId) htup->t_cmin)) ||
|
||||
TransactionIdDidAbort(htup->t_xmin))
|
||||
{
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(false);
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
UnlockAndReleaseBuffer(buffer);
|
||||
return(true);
|
||||
return (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Open pg_log in recovery
|
||||
*/
|
||||
extern Relation LogRelation; /* pg_log relation */
|
||||
extern Relation LogRelation; /* pg_log relation */
|
||||
|
||||
void
|
||||
XLogOpenLogRelation(void)
|
||||
@@ -189,32 +189,32 @@ XLogOpenLogRelation(void)
|
||||
Buffer
|
||||
XLogReadBuffer(bool extend, Relation reln, BlockNumber blkno)
|
||||
{
|
||||
BlockNumber lastblock = RelationGetNumberOfBlocks(reln);
|
||||
BlockNumber lastblock = RelationGetNumberOfBlocks(reln);
|
||||
Buffer buffer;
|
||||
|
||||
if (blkno >= lastblock)
|
||||
{
|
||||
buffer = InvalidBuffer;
|
||||
if (extend) /* we do this in recovery only - no locks */
|
||||
if (extend) /* we do this in recovery only - no locks */
|
||||
{
|
||||
Assert(InRecovery);
|
||||
while (lastblock <= blkno)
|
||||
{
|
||||
if (buffer != InvalidBuffer)
|
||||
ReleaseBuffer(buffer); /* must be WriteBuffer()? */
|
||||
ReleaseBuffer(buffer); /* must be WriteBuffer()? */
|
||||
buffer = ReadBuffer(reln, P_NEW);
|
||||
lastblock++;
|
||||
}
|
||||
}
|
||||
if (buffer != InvalidBuffer)
|
||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
return(buffer);
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
buffer = ReadBuffer(reln, blkno);
|
||||
if (buffer != InvalidBuffer)
|
||||
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
|
||||
return(buffer);
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -223,32 +223,33 @@ XLogReadBuffer(bool extend, Relation reln, BlockNumber blkno)
|
||||
|
||||
typedef struct XLogRelDesc
|
||||
{
|
||||
RelationData reldata;
|
||||
struct XLogRelDesc *lessRecently;
|
||||
struct XLogRelDesc *moreRecently;
|
||||
RelationData reldata;
|
||||
struct XLogRelDesc *lessRecently;
|
||||
struct XLogRelDesc *moreRecently;
|
||||
} XLogRelDesc;
|
||||
|
||||
typedef struct XLogRelCacheEntry
|
||||
{
|
||||
RelFileNode rnode;
|
||||
XLogRelDesc *rdesc;
|
||||
RelFileNode rnode;
|
||||
XLogRelDesc *rdesc;
|
||||
} XLogRelCacheEntry;
|
||||
|
||||
static HTAB *_xlrelcache;
|
||||
static XLogRelDesc *_xlrelarr = NULL;
|
||||
static Form_pg_class _xlpgcarr = NULL;
|
||||
static int _xlast = 0;
|
||||
static int _xlcnt = 0;
|
||||
#define _XLOG_RELCACHESIZE 512
|
||||
static HTAB *_xlrelcache;
|
||||
static XLogRelDesc *_xlrelarr = NULL;
|
||||
static Form_pg_class _xlpgcarr = NULL;
|
||||
static int _xlast = 0;
|
||||
static int _xlcnt = 0;
|
||||
|
||||
#define _XLOG_RELCACHESIZE 512
|
||||
|
||||
static void
|
||||
_xl_init_rel_cache(void)
|
||||
{
|
||||
HASHCTL ctl;
|
||||
HASHCTL ctl;
|
||||
|
||||
_xlcnt = _XLOG_RELCACHESIZE;
|
||||
_xlast = 0;
|
||||
_xlrelarr = (XLogRelDesc*) malloc(sizeof(XLogRelDesc) * _xlcnt);
|
||||
_xlrelarr = (XLogRelDesc *) malloc(sizeof(XLogRelDesc) * _xlcnt);
|
||||
memset(_xlrelarr, 0, sizeof(XLogRelDesc) * _xlcnt);
|
||||
_xlpgcarr = (Form_pg_class) malloc(sizeof(FormData_pg_class) * _xlcnt);
|
||||
memset(_xlpgcarr, 0, sizeof(FormData_pg_class) * _xlcnt);
|
||||
@@ -258,26 +259,26 @@ _xl_init_rel_cache(void)
|
||||
|
||||
memset(&ctl, 0, (int) sizeof(ctl));
|
||||
ctl.keysize = sizeof(RelFileNode);
|
||||
ctl.datasize = sizeof(XLogRelDesc*);
|
||||
ctl.datasize = sizeof(XLogRelDesc *);
|
||||
ctl.hash = tag_hash;
|
||||
|
||||
_xlrelcache = hash_create(_XLOG_RELCACHESIZE, &ctl,
|
||||
HASH_ELEM | HASH_FUNCTION);
|
||||
HASH_ELEM | HASH_FUNCTION);
|
||||
}
|
||||
|
||||
static void
|
||||
_xl_remove_hash_entry(XLogRelDesc **edata, Datum dummy)
|
||||
{
|
||||
XLogRelCacheEntry *hentry;
|
||||
bool found;
|
||||
XLogRelDesc *rdesc = *edata;
|
||||
Form_pg_class tpgc = rdesc->reldata.rd_rel;
|
||||
XLogRelCacheEntry *hentry;
|
||||
bool found;
|
||||
XLogRelDesc *rdesc = *edata;
|
||||
Form_pg_class tpgc = rdesc->reldata.rd_rel;
|
||||
|
||||
rdesc->lessRecently->moreRecently = rdesc->moreRecently;
|
||||
rdesc->moreRecently->lessRecently = rdesc->lessRecently;
|
||||
|
||||
hentry = (XLogRelCacheEntry*) hash_search(_xlrelcache,
|
||||
(char*)&(rdesc->reldata.rd_node), HASH_REMOVE, &found);
|
||||
hentry = (XLogRelCacheEntry *) hash_search(_xlrelcache,
|
||||
(char *) &(rdesc->reldata.rd_node), HASH_REMOVE, &found);
|
||||
|
||||
if (hentry == NULL)
|
||||
elog(STOP, "_xl_remove_hash_entry: can't delete from cache");
|
||||
@@ -294,16 +295,16 @@ _xl_remove_hash_entry(XLogRelDesc **edata, Datum dummy)
|
||||
return;
|
||||
}
|
||||
|
||||
static XLogRelDesc*
|
||||
static XLogRelDesc *
|
||||
_xl_new_reldesc(void)
|
||||
{
|
||||
XLogRelDesc *res;
|
||||
XLogRelDesc *res;
|
||||
|
||||
_xlast++;
|
||||
if (_xlast < _xlcnt)
|
||||
{
|
||||
_xlrelarr[_xlast].reldata.rd_rel = &(_xlpgcarr[_xlast]);
|
||||
return(&(_xlrelarr[_xlast]));
|
||||
return (&(_xlrelarr[_xlast]));
|
||||
}
|
||||
|
||||
/* reuse */
|
||||
@@ -312,7 +313,7 @@ _xl_new_reldesc(void)
|
||||
_xl_remove_hash_entry(&res, 0);
|
||||
|
||||
_xlast--;
|
||||
return(res);
|
||||
return (res);
|
||||
}
|
||||
|
||||
|
||||
@@ -344,12 +345,12 @@ XLogCloseRelationCache(void)
|
||||
Relation
|
||||
XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
|
||||
{
|
||||
XLogRelDesc *res;
|
||||
XLogRelCacheEntry *hentry;
|
||||
bool found;
|
||||
XLogRelDesc *res;
|
||||
XLogRelCacheEntry *hentry;
|
||||
bool found;
|
||||
|
||||
hentry = (XLogRelCacheEntry*)
|
||||
hash_search(_xlrelcache, (char*)&rnode, HASH_FIND, &found);
|
||||
hentry = (XLogRelCacheEntry *)
|
||||
hash_search(_xlrelcache, (char *) &rnode, HASH_FIND, &found);
|
||||
|
||||
if (hentry == NULL)
|
||||
elog(STOP, "XLogOpenRelation: error in cache");
|
||||
@@ -372,8 +373,8 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
|
||||
res->reldata.rd_lockInfo.lockRelId.relId = rnode.relNode;
|
||||
res->reldata.rd_node = rnode;
|
||||
|
||||
hentry = (XLogRelCacheEntry*)
|
||||
hash_search(_xlrelcache, (char*)&rnode, HASH_ENTER, &found);
|
||||
hentry = (XLogRelCacheEntry *)
|
||||
hash_search(_xlrelcache, (char *) &rnode, HASH_ENTER, &found);
|
||||
|
||||
if (hentry == NULL)
|
||||
elog(STOP, "XLogOpenRelation: can't insert into cache");
|
||||
@@ -385,7 +386,7 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
|
||||
|
||||
res->reldata.rd_fd = -1;
|
||||
res->reldata.rd_fd = smgropen(DEFAULT_SMGR, &(res->reldata),
|
||||
true /* allow failure */);
|
||||
true /* allow failure */ );
|
||||
}
|
||||
|
||||
res->moreRecently = &(_xlrelarr[0]);
|
||||
@@ -393,8 +394,8 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
|
||||
_xlrelarr[0].lessRecently = res;
|
||||
res->lessRecently->moreRecently = res;
|
||||
|
||||
if (res->reldata.rd_fd < 0) /* file doesn't exist */
|
||||
return(NULL);
|
||||
if (res->reldata.rd_fd < 0) /* file doesn't exist */
|
||||
return (NULL);
|
||||
|
||||
return(&(res->reldata));
|
||||
return (&(res->reldata));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user