diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/htup.h | 41 | ||||
| -rw-r--r-- | src/include/access/xact.h | 19 | ||||
| -rw-r--r-- | src/include/miscadmin.h | 3 | ||||
| -rw-r--r-- | src/include/storage/proc.h | 23 | ||||
| -rw-r--r-- | src/include/storage/sinval.h | 5 |
5 files changed, 54 insertions, 37 deletions
diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 37ba1164ec..971a279b9c 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.67 2004/07/11 18:01:45 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.68 2004/08/01 17:32:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -68,34 +68,17 @@ * object ID (if HEAP_HASOID is set in t_infomask) * user data fields * - * We store five "virtual" fields Xmin, Cmin, Xmax, Cmax, and Xvac - * in just three physical fields. Xmin is always really stored, but - * Cmin and Xmax share a field, as do Cmax and Xvac. This works because - * we know that there are only a limited number of states that a tuple can - * be in, and that Cmin and Cmax are only interesting for the lifetime of - * the inserting and deleting transactions respectively. We have the - * following possible states of a tuple: + * We store five "virtual" fields Xmin, Cmin, Xmax, Cmax, and Xvac in four + * physical fields. Xmin, Cmin and Xmax are always really stored, but + * Cmax and Xvac share a field. This works because we know that there are + * only a limited number of states that a tuple can be in, and that Cmax + * is only interesting for the lifetime of the deleting transaction. + * This assumes that VACUUM FULL never tries to move a tuple whose Cmax + * is still interesting (ie, delete-in-progress). * - * XMIN CMIN XMAX CMAX XVAC - * - * NEW (never deleted, not moved by vacuum): - * valid valid invalid invalid invalid - * - * DELETED BY CREATING XACT: - * valid valid = XMIN valid invalid - * - * DELETED BY OTHER XACT: - * valid unneeded valid valid invalid - * - * MOVED BY VACUUM FULL: - * valid unneeded maybe-valid unneeded valid - * - * This assumes that VACUUM FULL never tries to move a tuple whose Cmin or - * Cmax is still interesting (ie, insert-in-progress or delete-in-progress). - * - * This table shows that if we use an infomask bit to handle the case - * XMAX=XMIN specially, we never need to store Cmin and Xmax at the same - * time. Nor do we need to store Cmax and Xvac at the same time. + * Note that in 7.3 and 7.4 a similar idea was applied to Xmax and Cmin. + * However, with the advent of subtransactions, a tuple may need both Xmax + * and Cmin simultaneously, so this is no longer possible. * * Following the fixed header fields, the nulls bitmap is stored (beginning * at t_bits). The bitmap is *not* stored if t_infomask shows that there @@ -416,7 +399,7 @@ typedef HeapTupleData *HeapTuple; * WAL record definitions for heapam.c's WAL operations * * XLOG allows to store some information in high 4 bits of log - * record xl_info field + * record xl_info field. We use 3 for opcode and one for init bit. */ #define XLOG_HEAP_INSERT 0x00 #define XLOG_HEAP_DELETE 0x10 diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 532dcf51b0..16b7de333a 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.68 2004/07/31 07:39:19 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.69 2004/08/01 17:32:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -42,9 +42,18 @@ extern bool DefaultXactReadOnly; extern bool XactReadOnly; /* - * end-of-transaction cleanup callbacks for dynamically loaded modules + * start- and end-of-transaction callbacks for dynamically loaded modules */ -typedef void (*EOXactCallback) (bool isCommit, void *arg); +typedef enum +{ + XACT_EVENT_ABORT, + XACT_EVENT_COMMIT, + XACT_EVENT_START_SUB, + XACT_EVENT_ABORT_SUB, + XACT_EVENT_COMMIT_SUB +} XactEvent; + +typedef void (*XactCallback) (XactEvent event, TransactionId parentXid, void *arg); /* ---------------- @@ -118,8 +127,8 @@ extern void AbortOutOfAnyTransaction(void); extern void PreventTransactionChain(void *stmtNode, const char *stmtType); extern void RequireTransactionChain(void *stmtNode, const char *stmtType); extern bool IsInTransactionChain(void *stmtNode); -extern void RegisterEOXactCallback(EOXactCallback callback, void *arg); -extern void UnregisterEOXactCallback(EOXactCallback callback, void *arg); +extern void RegisterXactCallback(XactCallback callback, void *arg); +extern void UnregisterXactCallback(XactCallback callback, void *arg); extern void RecordTransactionCommit(void); diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 0a508861b2..3f7c0946d7 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.163 2004/06/18 06:14:10 tgl Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.164 2004/08/01 17:32:20 tgl Exp $ * * NOTES * some of the information in this file should be moved to other files. @@ -308,6 +308,7 @@ extern void BaseInit(void); extern void IgnoreSystemIndexes(bool mode); extern bool IsIgnoringSystemIndexes(void); extern void SetReindexProcessing(Oid heapOid, Oid indexOid); +extern void ResetReindexProcessing(void); extern bool ReindexIsProcessingHeap(Oid heapOid); extern bool ReindexIsProcessingIndex(Oid indexOid); extern void CreateDataDirLockFile(const char *datadir, bool amPostmaster); diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index c2411bef07..4f7f39003a 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.71 2004/07/21 20:34:49 momjian Exp $ + * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.72 2004/08/01 17:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -21,6 +21,25 @@ /* + * Each backend advertises up to PGPROC_MAX_CACHED_SUBXIDS TransactionIds + * for non-aborted subtransactions of its current top transaction. These + * have to be treated as running XIDs by other backends. + * + * We also keep track of whether the cache overflowed (ie, the transaction has + * generated at least one subtransaction that didn't fit in the cache). + * If none of the caches have overflowed, we can assume that an XID that's not + * listed anywhere in the PGPROC array is not a running transaction. Else we + * have to look at pg_subtrans. + */ +#define PGPROC_MAX_CACHED_SUBXIDS 64 /* XXX guessed-at value */ + +struct XidCache { + bool overflowed; + int nxids; + TransactionId xids[PGPROC_MAX_CACHED_SUBXIDS]; +}; + +/* * Each backend has a PGPROC struct in shared memory. There is also a list of * currently-unused PGPROC structs that will be reallocated to new backends. * @@ -68,6 +87,8 @@ struct PGPROC SHM_QUEUE procHolders; /* list of PROCLOCK objects for locks held * or awaited by this backend */ + + struct XidCache subxids; /* cache for subtransaction XIDs */ }; /* NOTE: "typedef struct PGPROC PGPROC" appears in storage/lock.h. */ diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h index 8476920050..5ac995a29d 100644 --- a/src/include/storage/sinval.h +++ b/src/include/storage/sinval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.35 2004/06/02 21:29:29 momjian Exp $ + * $PostgreSQL: pgsql/src/include/storage/sinval.h,v 1.36 2004/08/01 17:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -104,6 +104,9 @@ extern int CountEmptyBackendSlots(void); /* Use "struct PGPROC", not PGPROC, to avoid including proc.h here */ extern struct PGPROC *BackendIdGetProc(BackendId procId); +extern void XidCacheRemoveRunningXids(TransactionId xid, + int nxids, TransactionId *xids); + /* signal handler for catchup events (SIGUSR1) */ extern void CatchupInterruptHandler(SIGNAL_ARGS); |
