diff options
| author | Tom Lane | 2001-08-25 18:52:43 +0000 |
|---|---|---|
| committer | Tom Lane | 2001-08-25 18:52:43 +0000 |
| commit | 2589735da08c4e597accb6eab5ae65b6339ee630 (patch) | |
| tree | 829f7073292c6b55f86580863837441991638405 /src/include | |
| parent | 4699d81dc99ef1687e9396b57b0ed10f42699792 (diff) | |
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.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/clog.h | 47 | ||||
| -rw-r--r-- | src/include/access/rmgr.h | 3 | ||||
| -rw-r--r-- | src/include/access/transam.h | 49 | ||||
| -rw-r--r-- | src/include/access/xact.h | 5 | ||||
| -rw-r--r-- | src/include/access/xlog.h | 3 | ||||
| -rw-r--r-- | src/include/access/xlogdefs.h | 4 | ||||
| -rw-r--r-- | src/include/access/xlogutils.h | 6 | ||||
| -rw-r--r-- | src/include/catalog/catname.h | 3 | ||||
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_attribute.h | 24 | ||||
| -rw-r--r-- | src/include/catalog/pg_class.h | 5 | ||||
| -rw-r--r-- | src/include/catalog/pg_log.h | 41 | ||||
| -rw-r--r-- | src/include/catalog/pg_type.h | 3 | ||||
| -rw-r--r-- | src/include/storage/bufpage.h | 6 |
14 files changed, 79 insertions, 124 deletions
diff --git a/src/include/access/clog.h b/src/include/access/clog.h new file mode 100644 index 00000000000..4e44e8036cf --- /dev/null +++ b/src/include/access/clog.h @@ -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 */ diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h index af721e9fe76..b658422fd2b 100644 --- a/src/include/access/rmgr.h +++ b/src/include/access/rmgr.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 diff --git a/src/include/access/transam.h b/src/include/access/transam.h index 3833d97821a..f0d213361ac 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -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; diff --git a/src/include/access/xact.h b/src/include/access/xact.h index abbe16ced38..a9c7b674a95 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.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: 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); diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 73a60b2e0ce..dd5f0284a12 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -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" diff --git a/src/include/access/xlogdefs.h b/src/include/access/xlogdefs.h index d6af5eb4989..916474bd970 100644 --- a/src/include/access/xlogdefs.h +++ b/src/include/access/xlogdefs.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; diff --git a/src/include/access/xlogutils.h b/src/include/access/xlogutils.h index b31184b76bb..b427c836498 100644 --- a/src/include/access/xlogutils.h +++ b/src/include/access/xlogutils.h @@ -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); diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h index 2f2f2c90f44..804c672b281 100644 --- a/src/include/catalog/catname.h +++ b/src/include/catalog/catname.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: catname.h,v 1.19 2001/05/14 20:30:21 momjian Exp $ + * $Id: catname.h,v 1.20 2001/08/25 18:52:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,6 @@ #define LanguageRelationName "pg_language" #define LargeObjectRelationName "pg_largeobject" #define ListenerRelationName "pg_listener" -#define LogRelationName "pg_log" #define OperatorClassRelationName "pg_opclass" #define OperatorRelationName "pg_operator" #define ProcedureRelationName "pg_proc" diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index ea296593735..58d43a65293 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.91 2001/08/21 16:36:05 tgl Exp $ + * $Id: catversion.h,v 1.92 2001/08/25 18:52:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200108211 +#define CATALOG_VERSION_NO 200108241 #endif diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index ad8dc3a6e59..eb1ba77235e 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.74 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_attribute.h,v 1.75 2001/08/25 18:52:42 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -474,25 +474,13 @@ DATA(insert ( 1259 cmax 29 0 4 -6 0 -1 -1 t p f i f f)); DATA(insert ( 1259 tableoid 26 0 4 -7 0 -1 -1 t p f i f f)); /* ---------------- - * pg_log - this relation is modified by special purpose access - * method code. The following is garbage but is needed - * so that the reldesc code works properly. + * pg_xactlock - this is not a real relation, but is a placeholder + * to allow a relation OID to be used for transaction + * waits. We need a pg_xactlock entry in pg_class only to + * ensure that that OID can never be allocated to a real + * table; and this entry is just to link to that one. * ---------------- */ -#define Schema_pg_log \ -{ 1269, {"logfoo"}, 26, 0, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false } - -DATA(insert ( 1269 logfoo 26 0 4 1 0 -1 -1 t p f i f f)); - -/* ---------------- - * pg_xactlock - this relation is modified by special purpose access - * method code. The following is garbage but is needed - * so that the reldesc code works properly. - * ---------------- - */ -#define Schema_pg_xactlock \ -{ 376, {"xactlockfoo"}, 26, 0, 4, 1, 0, -1, -1, true, 'p', false, 'i', false, false } - DATA(insert ( 376 xactlockfoo 26 0 4 1 0 -1 -1 t p f i f f)); #endif /* PG_ATTRIBUTE_H */ diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 859bb9d1852..4f2708e3bd0 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_class.h,v 1.52 2001/08/10 18:57:40 tgl Exp $ + * $Id: pg_class.h,v 1.53 2001/08/25 18:52:43 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -144,8 +144,6 @@ DATA(insert OID = 1261 ( pg_group 87 PGUID 0 1261 0 0 0 0 f t r 3 0 0 0 0 0 f DESCR(""); DATA(insert OID = 1262 ( pg_database 88 PGUID 0 1262 0 0 0 0 f t r 7 0 0 0 0 0 t f f f _null_ )); DESCR(""); -DATA(insert OID = 1269 ( pg_log 99 PGUID 0 1269 0 0 0 0 f t s 1 0 0 0 0 0 f f f f _null_ )); -DESCR(""); DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 0 0 0 f t s 1 0 0 0 0 0 f f f f _null_ )); DESCR(""); @@ -156,7 +154,6 @@ DESCR(""); #define RelOid_pg_shadow 1260 #define RelOid_pg_group 1261 #define RelOid_pg_database 1262 -#define RelOid_pg_log 1269 /* Xact lock pseudo-table */ #define XactLockTableId 376 diff --git a/src/include/catalog/pg_log.h b/src/include/catalog/pg_log.h deleted file mode 100644 index 951aaf0efce..00000000000 --- a/src/include/catalog/pg_log.h +++ /dev/null @@ -1,41 +0,0 @@ -/*------------------------------------------------------------------------- - * - * pg_log.h - * the system log relation "pg_log" is not a "heap" relation. - * it is automatically created by the transam/ code and the - * information here is all bogus and is just here to make the - * relcache code happy. - * - * - * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * $Id: pg_log.h,v 1.9 2001/08/10 18:57:40 tgl Exp $ - * - * NOTES - * The structures and macros used by the transam/ code - * to access pg_log should some day go here -cim 6/18/90 - * - *------------------------------------------------------------------------- - */ -#ifndef PG_LOG_H -#define PG_LOG_H - -/* ---------------- - * postgres.h contains the system type definintions and the - * CATALOG(), BOOTSTRAP and DATA() sugar words so this file - * can be read by both genbki.sh and the C compiler. - * ---------------- - */ - -CATALOG(pg_log) BOOTSTRAP BKI_WITHOUT_OIDS -{ - Oid logfoo; -} FormData_pg_log; - -typedef FormData_pg_log *Form_pg_log; - -#define Natts_pg_log 1 -#define Anum_pg_log_logfoo 1 - -#endif /* PG_LOG_H */ diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index ffad5a7fe05..d5e02020291 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.109 2001/06/12 05:55:50 tgl Exp $ + * $Id: pg_type.h,v 1.110 2001/08/25 18:52:43 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -239,7 +239,6 @@ DATA(insert OID = 83 ( pg_class PGUID 4 4 t c t \054 1259 0 int4in int4out int4 DATA(insert OID = 86 ( pg_shadow PGUID 4 4 t c t \054 1260 0 int4in int4out int4in int4out i p _null_)); DATA(insert OID = 87 ( pg_group PGUID 4 4 t c t \054 1261 0 int4in int4out int4in int4out i p _null_)); DATA(insert OID = 88 ( pg_database PGUID 4 4 t c t \054 1262 0 int4in int4out int4in int4out i p _null_)); -DATA(insert OID = 99 ( pg_log PGUID 4 4 t c t \054 1269 0 int4in int4out int4in int4out i p _null_)); /* OIDS 100 - 199 */ diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 53532424452..b38b1677a0d 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.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: bufpage.h,v 1.42 2001/05/14 22:06:41 momjian Exp $ + * $Id: bufpage.h,v 1.43 2001/08/25 18:52:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -54,10 +54,6 @@ * obviously, a page is not formatted before it is initialized with by * a call to PageInit. * - * The contents of the special pg_log tables are raw disk blocks with - * special formats. these are the only "access methods" that need not - * write disk pages. - * * NOTES: * * linp1..N form an ItemId array. ItemPointers point into this array |
