mirror of
https://github.com/postgres/postgres.git
synced 2025-10-24 01:29:19 +03:00
Replace implementation of pg_log as a relation accessed through the
buffer manager with 'pg_clog', a specialized access method modeled on pg_xlog. This simplifies startup (don't need to play games to open pg_log; among other things, OverrideTransactionSystem goes away), should improve performance a little, and opens the door to recycling commit log space by removing no-longer-needed segments of the commit log. Actual recycling is not there yet, but I felt I should commit this part separately since it'd still be useful if we chose not to do transaction ID wraparound.
This commit is contained in:
47
src/include/access/clog.h
Normal file
47
src/include/access/clog.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* clog.h
|
||||
*
|
||||
* PostgreSQL transaction-commit-log manager
|
||||
*
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: clog.h,v 1.1 2001/08/25 18:52:42 tgl Exp $
|
||||
*/
|
||||
#ifndef CLOG_H
|
||||
#define CLOG_H
|
||||
|
||||
#include "access/xlog.h"
|
||||
|
||||
/*
|
||||
* Possible transaction statuses --- note that all-zeroes is the initial
|
||||
* state.
|
||||
*/
|
||||
typedef int XidStatus;
|
||||
|
||||
#define TRANSACTION_STATUS_IN_PROGRESS 0x00
|
||||
#define TRANSACTION_STATUS_COMMITTED 0x01
|
||||
#define TRANSACTION_STATUS_ABORTED 0x02
|
||||
/* 0x03 is available without changing commit log space allocation */
|
||||
|
||||
|
||||
extern void TransactionIdSetStatus(TransactionId xid, XidStatus status);
|
||||
extern XidStatus TransactionIdGetStatus(TransactionId xid);
|
||||
|
||||
extern int CLOGShmemSize(void);
|
||||
extern void CLOGShmemInit(void);
|
||||
extern void BootStrapCLOG(void);
|
||||
extern void StartupCLOG(void);
|
||||
extern void ShutdownCLOG(void);
|
||||
extern void CheckPointCLOG(void);
|
||||
extern void ExtendCLOG(TransactionId newestXact);
|
||||
extern void TruncateCLOG(TransactionId oldestXact);
|
||||
|
||||
/* XLOG stuff */
|
||||
#define CLOG_ZEROPAGE 0x00
|
||||
|
||||
extern void clog_redo(XLogRecPtr lsn, XLogRecord *record);
|
||||
extern void clog_undo(XLogRecPtr lsn, XLogRecord *record);
|
||||
extern void clog_desc(char *buf, uint8 xl_info, char *rec);
|
||||
|
||||
#endif /* CLOG_H */
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
*
|
||||
* rmgr.h
|
||||
*
|
||||
* Resource managers definition
|
||||
*
|
||||
* $Id: rmgr.h,v 1.6 2001/08/25 18:52:42 tgl Exp $
|
||||
*/
|
||||
#ifndef RMGR_H
|
||||
#define RMGR_H
|
||||
@@ -16,6 +16,7 @@ typedef uint8 RmgrId;
|
||||
#define RM_XLOG_ID 0
|
||||
#define RM_XACT_ID 1
|
||||
#define RM_SMGR_ID 2
|
||||
#define RM_CLOG_ID 3
|
||||
#define RM_HEAP_ID 10
|
||||
#define RM_BTREE_ID 11
|
||||
#define RM_HASH_ID 12
|
||||
|
||||
@@ -7,33 +7,30 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: transam.h,v 1.38 2001/08/23 23:06:38 tgl Exp $
|
||||
* $Id: transam.h,v 1.39 2001/08/25 18:52:42 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TRANSAM_H
|
||||
#define TRANSAM_H
|
||||
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/spin.h"
|
||||
|
||||
|
||||
/* ----------------
|
||||
* Special transaction ID values
|
||||
*
|
||||
* We do not use any transaction IDs less than 512 --- this leaves the first
|
||||
* 128 bytes of pg_log available for special purposes such as version number
|
||||
* storage. (Currently, we do not actually use them for anything.)
|
||||
*
|
||||
* BootstrapTransactionId is the XID for "bootstrap" operations. It should
|
||||
* BootstrapTransactionId is the XID for "bootstrap" operations, and
|
||||
* FrozenTransactionId is used for very old tuples. Both should
|
||||
* always be considered valid.
|
||||
*
|
||||
* FirstNormalTransactionId is the first "normal" transaction id.
|
||||
* ----------------
|
||||
*/
|
||||
#define InvalidTransactionId ((TransactionId) 0)
|
||||
#define DisabledTransactionId ((TransactionId) 1)
|
||||
#define BootstrapTransactionId ((TransactionId) 512)
|
||||
#define FirstNormalTransactionId ((TransactionId) 514)
|
||||
#define BootstrapTransactionId ((TransactionId) 1)
|
||||
#define FrozenTransactionId ((TransactionId) 2)
|
||||
#define FirstNormalTransactionId ((TransactionId) 3)
|
||||
|
||||
/* ----------------
|
||||
* transaction ID manipulation macros
|
||||
@@ -56,19 +53,6 @@
|
||||
(dest) = FirstNormalTransactionId; \
|
||||
} while(0)
|
||||
|
||||
/* ----------------
|
||||
* transaction status values
|
||||
*
|
||||
* someday we will use "11" = 3 = XID_COMMIT_CHILD to mean the
|
||||
* commiting of child xactions.
|
||||
* ----------------
|
||||
*/
|
||||
#define XID_INPROGRESS 0 /* transaction in progress */
|
||||
#define XID_ABORT 1 /* transaction aborted */
|
||||
#define XID_COMMIT 2 /* transaction commited */
|
||||
#define XID_COMMIT_CHILD 3 /* child xact commited */
|
||||
|
||||
typedef unsigned char XidStatus; /* (2 bits) */
|
||||
|
||||
/* ----------
|
||||
* Object ID (OID) zero is InvalidOid.
|
||||
@@ -116,25 +100,15 @@ typedef VariableCacheData *VariableCache;
|
||||
/*
|
||||
* prototypes for functions in transam/transam.c
|
||||
*/
|
||||
extern void InitializeTransactionLog(void);
|
||||
extern void AmiTransactionOverride(bool flag);
|
||||
extern bool TransactionIdDidCommit(TransactionId transactionId);
|
||||
extern bool TransactionIdDidAbort(TransactionId transactionId);
|
||||
extern void TransactionIdCommit(TransactionId transactionId);
|
||||
extern void TransactionIdAbort(TransactionId transactionId);
|
||||
|
||||
/* in transam/transsup.c */
|
||||
extern void AmiTransactionOverride(bool flag);
|
||||
extern void TransComputeBlockNumber(Relation relation,
|
||||
TransactionId transactionId, BlockNumber *blockNumberOutP);
|
||||
extern XidStatus TransBlockNumberGetXidStatus(Relation relation,
|
||||
BlockNumber blockNumber, TransactionId xid, bool *failP);
|
||||
extern void TransBlockNumberSetXidStatus(Relation relation,
|
||||
BlockNumber blockNumber, TransactionId xid, XidStatus xstatus,
|
||||
bool *failP);
|
||||
|
||||
/* in transam/varsup.c */
|
||||
extern void GetNewTransactionId(TransactionId *xid);
|
||||
extern void ReadNewTransactionId(TransactionId *xid);
|
||||
extern TransactionId GetNewTransactionId(void);
|
||||
extern TransactionId ReadNewTransactionId(void);
|
||||
extern Oid GetNewObjectId(void);
|
||||
extern void CheckMaxObjectId(Oid assigned_oid);
|
||||
|
||||
@@ -143,9 +117,6 @@ extern void CheckMaxObjectId(Oid assigned_oid);
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
/* in transam.c */
|
||||
extern Relation LogRelation;
|
||||
|
||||
/* in xact.c */
|
||||
extern bool AMI_OVERRIDE;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xact.h,v 1.34 2001/07/12 04:11:13 tgl Exp $
|
||||
* $Id: xact.h,v 1.35 2001/08/25 18:52:42 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -54,7 +54,6 @@ typedef TransactionStateData *TransactionState;
|
||||
#define TRANS_INPROGRESS 2
|
||||
#define TRANS_COMMIT 3
|
||||
#define TRANS_ABORT 4
|
||||
#define TRANS_DISABLED 5
|
||||
|
||||
/* ----------------
|
||||
* transaction block states
|
||||
@@ -100,7 +99,6 @@ extern int TransactionFlushEnabled(void);
|
||||
extern void SetTransactionFlushEnabled(bool state);
|
||||
|
||||
extern bool IsAbortedTransactionBlockState(void);
|
||||
extern void OverrideTransactionSystem(bool flag);
|
||||
extern TransactionId GetCurrentTransactionId(void);
|
||||
extern CommandId GetCurrentCommandId(void);
|
||||
extern CommandId GetScanCommandId(void);
|
||||
@@ -110,7 +108,6 @@ extern bool TransactionIdIsCurrentTransactionId(TransactionId xid);
|
||||
extern bool CommandIdIsCurrentCommandId(CommandId cid);
|
||||
extern bool CommandIdGEScanCommandId(CommandId cid);
|
||||
extern void CommandCounterIncrement(void);
|
||||
extern void InitializeTransactionSystem(void);
|
||||
extern void StartTransactionCommand(void);
|
||||
extern void CommitTransactionCommand(void);
|
||||
extern void AbortCurrentTransaction(void);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xlog.h,v 1.24 2001/07/19 02:12:35 tgl Exp $
|
||||
* $Id: xlog.h,v 1.25 2001/08/25 18:52:42 tgl Exp $
|
||||
*/
|
||||
#ifndef XLOG_H
|
||||
#define XLOG_H
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "access/rmgr.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/xlogdefs.h"
|
||||
#include "storage/bufmgr.h"
|
||||
#include "utils/pg_crc.h"
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xlogdefs.h,v 1.3 2001/03/22 04:00:32 momjian Exp $
|
||||
* $Id: xlogdefs.h,v 1.4 2001/08/25 18:52:42 tgl Exp $
|
||||
*/
|
||||
#ifndef XLOG_DEFS_H
|
||||
#define XLOG_DEFS_H
|
||||
@@ -52,7 +52,7 @@ typedef struct XLogRecPtr
|
||||
|
||||
/*
|
||||
* StartUpID (SUI) - system startups counter. It's to allow removing
|
||||
* pg_log after shutdown, in future.
|
||||
* pg_clog after shutdown, in future.
|
||||
*/
|
||||
typedef uint32 StartUpID;
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: xlogutils.h,v 1.7 2001/03/22 04:00:32 momjian Exp $
|
||||
* $Id: xlogutils.h,v 1.8 2001/08/25 18:52:42 tgl Exp $
|
||||
*/
|
||||
#ifndef XLOG_UTILS_H
|
||||
#define XLOG_UTILS_H
|
||||
|
||||
#include "access/rmgr.h"
|
||||
#include "storage/buf.h"
|
||||
#include "storage/itemptr.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
extern int XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
|
||||
TransactionId xid, CommandId cid);
|
||||
extern bool XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr);
|
||||
|
||||
extern void XLogOpenLogRelation(void);
|
||||
|
||||
extern void XLogInitRelationCache(void);
|
||||
extern void XLogCloseRelationCache(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user