diff options
author | Tom Lane | 2005-06-08 15:50:28 +0000 |
---|---|---|
committer | Tom Lane | 2005-06-08 15:50:28 +0000 |
commit | f5b2f60bd1084e218358adba04604147e5429233 (patch) | |
tree | 276b7d36fa97284ef5b37e53f488e6f3532b78d7 /src/include | |
parent | 593badd30b09c6bc11930d4a26ff70830a5a9092 (diff) |
Change WAL-logging scheme for multixacts to be more like regular
transaction IDs, rather than like subtrans; in particular, the information
now survives a database restart. Per previous discussion, this is
essential for PITR log shipping and for 2PC.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/htup.h | 4 | ||||
-rw-r--r-- | src/include/access/multixact.h | 37 | ||||
-rw-r--r-- | src/include/access/xlog.h | 3 | ||||
-rw-r--r-- | src/include/c.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_control.h | 6 |
5 files changed, 43 insertions, 11 deletions
diff --git a/src/include/access/htup.h b/src/include/access/htup.h index adeb05fd560..e394afd3139 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -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/include/access/htup.h,v 1.74 2005/04/28 21:47:17 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.75 2005/06/08 15:50:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -505,6 +505,8 @@ typedef struct xl_heap_newpage typedef struct xl_heap_lock { xl_heaptid target; /* locked tuple id */ + TransactionId locking_xid; /* might be a MultiXactId not xid */ + bool xid_is_mxact; /* is it? */ bool shared_lock; /* shared or exclusive row lock? */ } xl_heap_lock; diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index 65d19704c40..2199b05f2c5 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -6,16 +6,38 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.2 2005/05/03 19:42:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.3 2005/06/08 15:50:28 tgl Exp $ */ #ifndef MULTIXACT_H #define MULTIXACT_H +#include "access/xlog.h" + #define InvalidMultiXactId ((MultiXactId) 0) #define FirstMultiXactId ((MultiXactId) 1) #define MultiXactIdIsValid(multi) ((multi) != InvalidMultiXactId) +/* ---------------- + * multixact-related XLOG entries + * ---------------- + */ + +#define XLOG_MULTIXACT_ZERO_OFF_PAGE 0x00 +#define XLOG_MULTIXACT_ZERO_MEM_PAGE 0x10 +#define XLOG_MULTIXACT_CREATE_ID 0x20 + +typedef struct xl_multixact_create +{ + MultiXactId mid; /* new MultiXact's ID */ + MultiXactOffset moff; /* its starting offset in members file */ + int32 nxids; /* number of member XIDs */ + TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */ +} xl_multixact_create; + +#define MinSizeOfMultiXactCreate offsetof(xl_multixact_create, xids) + + extern MultiXactId MultiXactIdCreate(TransactionId xid1, TransactionId xid2); extern MultiXactId MultiXactIdExpand(MultiXactId multi, TransactionId xid); extern bool MultiXactIdIsRunning(MultiXactId multi); @@ -29,9 +51,16 @@ extern void MultiXactShmemInit(void); extern void BootStrapMultiXact(void); extern void StartupMultiXact(void); extern void ShutdownMultiXact(void); -extern MultiXactId MultiXactGetCheckptMulti(bool is_shutdown); +extern void MultiXactGetCheckptMulti(bool is_shutdown, + MultiXactId *nextMulti, + MultiXactOffset *nextMultiOffset); extern void CheckPointMultiXact(void); -extern void MultiXactSetNextMXact(MultiXactId nextMulti); -extern void MultiXactAdvanceNextMXact(MultiXactId minMulti); +extern void MultiXactSetNextMXact(MultiXactId nextMulti, + MultiXactOffset nextMultiOffset); +extern void MultiXactAdvanceNextMXact(MultiXactId minMulti, + MultiXactOffset minMultiOffset); + +extern void multixact_redo(XLogRecPtr lsn, XLogRecord *record); +extern void multixact_desc(char *buf, uint8 xl_info, char *rec); #endif /* MULTIXACT_H */ diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 7547d7f5b9f..ead4619b027 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.64 2005/06/06 20:22:58 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.65 2005/06/08 15:50:28 tgl Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -165,7 +165,6 @@ extern void ShutdownXLOG(int code, Datum arg); extern void InitXLOGAccess(void); extern void CreateCheckPoint(bool shutdown, bool force); extern void XLogPutNextOid(Oid nextOid); -extern void XLogPutNextMultiXactId(MultiXactId multi); extern XLogRecPtr GetRedoRecPtr(void); #endif /* XLOG_H */ diff --git a/src/include/c.h b/src/include/c.h index 6318c5573dd..1a920387747 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.184 2005/05/25 21:40:41 momjian Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.185 2005/06/08 15:50:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -388,6 +388,8 @@ typedef uint32 SubTransactionId; /* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */ typedef TransactionId MultiXactId; +typedef uint32 MultiXactOffset; + typedef uint32 CommandId; #define FirstCommandId ((CommandId) 0) diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h index 3f96b6bf261..73f32b55ade 100644 --- a/src/include/catalog/pg_control.h +++ b/src/include/catalog/pg_control.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.22 2005/06/02 05:55:29 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.23 2005/06/08 15:50:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ /* Version identifier for this pg_control format */ -#define PG_CONTROL_VERSION 810 +#define PG_CONTROL_VERSION 811 /* * Body of CheckPoint XLOG records. This is declared here because we keep @@ -40,13 +40,13 @@ typedef struct CheckPoint TransactionId nextXid; /* next free XID */ Oid nextOid; /* next free OID */ MultiXactId nextMulti; /* next free MultiXactId */ + MultiXactOffset nextMultiOffset; /* next free MultiXact offset */ time_t time; /* time stamp of checkpoint */ } CheckPoint; /* XLOG info values for XLOG rmgr */ #define XLOG_CHECKPOINT_SHUTDOWN 0x00 #define XLOG_CHECKPOINT_ONLINE 0x10 -#define XLOG_NEXTMULTI 0x20 #define XLOG_NEXTOID 0x30 |