diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/xact.h | 14 | ||||
-rw-r--r-- | src/include/executor/executor.h | 42 | ||||
-rw-r--r-- | src/include/storage/bufmgr.h | 59 | ||||
-rw-r--r-- | src/include/storage/bufpage.h | 18 | ||||
-rw-r--r-- | src/include/utils/tqual.h | 49 |
5 files changed, 166 insertions, 16 deletions
diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 60bd8cab611..7abcb63e697 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: xact.h,v 1.12 1998/02/26 04:40:32 momjian Exp $ + * $Id: xact.h,v 1.13 1998/04/24 14:42:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,6 +60,17 @@ typedef TransactionStateData *TransactionState; #define StoreInvalidTransactionId(dest) \ (*((TransactionId*)dest) = NullTransactionId) + +/* ---------------------------------------------------------------- + * TransactionIdEquals + * ---------------------------------------------------------------- + */ +#define TransactionIdEquals(id1, id2) \ +( \ + ((bool) ((id1) == (id2))) \ +) + + /* ---------------- * extern definitions * ---------------- @@ -95,7 +106,6 @@ extern TransactionId DisabledTransactionId; extern TransactionId xidin(char *representation); extern char *xidout(TransactionId transactionId); extern bool xideq(TransactionId xid1, TransactionId xid2); -extern bool TransactionIdEquals(TransactionId id1, TransactionId id2); extern bool TransactionIdIsLessThan(TransactionId id1, TransactionId id2); extern void TransactionIdAdd(TransactionId *xid, int value); diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 0ce8dc3fc9f..17ff71c2f98 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.21 1998/02/26 04:41:19 momjian Exp $ + * $Id: executor.h,v 1.22 1998/04/24 14:43:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,10 +14,48 @@ #define EXECUTOR_H #include <catalog/pg_index.h> +#include <storage/bufmgr.h> #include <access/itup.h> #include <stdio.h> #include <executor/execdesc.h> +/* ---------------- + * TupIsNull + * + * This is used mainly to detect when there are no more + * tuples to process. + * ---------------- + */ +/* return: true if tuple in slot is NULL, slot is slot to test */ +#define TupIsNull(slot) \ +( \ + ((slot) == NULL) ? \ + true \ + : \ + ( \ + ((slot)->val == NULL) ? \ + true \ + : \ + false \ + ) \ +) + +/* -------------------------------- + * ExecIncrSlotBufferRefcnt + * + * When we pass around buffers in the tuple table, we have to + * be careful to increment reference counts appropriately. + * This is used mainly in the mergejoin code. + * -------------------------------- + */ +#define ExecIncrSlotBufferRefcnt(slot) \ +( \ + BufferIsValid((slot)->ttc_buffer) ? \ + IncrBufferRefCount((slot)->ttc_buffer) \ + : (void)NULL \ +) + + /* * prototypes from functions in execAmi.c */ @@ -107,8 +145,6 @@ extern TupleDesc ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc); extern void ExecSetSlotDescriptorIsNew(TupleTableSlot *slot, bool isNew); -extern void ExecIncrSlotBufferRefcnt(TupleTableSlot *slot); -extern bool TupIsNull(TupleTableSlot *slot); extern void ExecInitResultTupleSlot(EState *estate, CommonState *commonstate); extern void ExecInitScanTupleSlot(EState *estate, diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index fdc3abcee43..f27e9d1ed3a 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufmgr.h,v 1.18 1998/02/26 04:43:22 momjian Exp $ + * $Id: bufmgr.h,v 1.19 1998/04/24 14:43:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ #include <storage/ipc.h> #include <storage/block.h> #include <storage/buf.h> +#include <storage/buf_internals.h> #include <utils/rel.h> /* @@ -73,6 +74,59 @@ extern int ShowPinTrace; #define BUFFER_LATE_WRITE 1 /* delayed write: mark as DIRTY */ /* + * BufferIsValid -- + * True iff the refcnt of the local buffer is > 0 + * Note: + * BufferIsValid(InvalidBuffer) is False. + * BufferIsValid(UnknownBuffer) is False. + */ +#define BufferIsValid(bufnum) \ +( \ + BufferIsLocal(bufnum) ? \ + ((bufnum) >= -NLocBuffer && LocalRefCount[-(bufnum) - 1] > 0) \ + : \ + ( \ + BAD_BUFFER_ID(bufnum) ? \ + false \ + : \ + (PrivateRefCount[(bufnum) - 1] > 0) \ + ) \ +) + +#define IncrBufferRefCount(buffer) \ +( \ + BufferIsLocal(buffer) ? \ + ( \ + (void)AssertMacro(LocalRefCount[-(buffer) - 1] >= 0), \ + (void)LocalRefCount[-(buffer) - 1]++ \ + ) \ + : \ + ( \ + (void)AssertMacro(!BAD_BUFFER_ID(buffer)), \ + (void)AssertMacro(PrivateRefCount[(buffer) - 1] >= 0), \ + (void)PrivateRefCount[(buffer) - 1]++ \ + ) \ +) + +/* + * BufferGetBlock -- + * Returns a reference to a disk page image associated with a buffer. + * + * Note: + * Assumes buffer is valid. + */ +#define BufferGetBlock(buffer) \ +( \ + (void)AssertMacro(BufferIsValid(buffer)), \ +\ + BufferIsLocal(buffer) ? \ + ((Block) MAKE_PTR(LocalBufferDescriptors[-(buffer) - 1].data)) \ + : \ + ((Block) MAKE_PTR(BufferDescriptors[(buffer) - 1].data)) \ +) + + +/* * prototypes for functions in bufmgr.c */ extern Buffer @@ -91,17 +145,14 @@ extern void ResetBufferUsage(void); extern void ResetBufferPool(void); extern int BufferPoolCheckLeak(void); extern void FlushBufferPool(int StableMainMemoryFlag); -extern bool BufferIsValid(Buffer bufnum); extern BlockNumber BufferGetBlockNumber(Buffer buffer); extern Relation BufferGetRelation(Buffer buffer); extern BlockNumber RelationGetNumberOfBlocks(Relation relation); -extern Block BufferGetBlock(Buffer buffer); extern void ReleaseRelationBuffers(Relation rdesc); extern void DropBuffers(Oid dbid); extern void PrintBufferDescs(void); extern void PrintPinnedBufs(void); extern int BufferShmemSize(void); -extern void IncrBufferRefCount(Buffer buffer); extern int ReleaseBuffer(Buffer buffer); extern void BufferRefCountReset(int *refcountsave); diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 2be7093e4c7..c0701fc963d 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufpage.h,v 1.17 1998/02/26 04:43:24 momjian Exp $ + * $Id: bufpage.h,v 1.18 1998/04/24 14:43:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -280,6 +280,21 @@ typedef enum */ #define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) +/* + * PageGetMaxOffsetNumber -- + * Returns the maximum offset number used by the given page. + * + * NOTE: The offset is invalid if the page is non-empty. + * Test whether PageIsEmpty before calling this routine + * and/or using its return value. + */ +#define PageGetMaxOffsetNumber(page) \ +( \ + (((PageHeader) (page))->pd_lower - \ + (sizeof(PageHeaderData) - sizeof(ItemIdData))) \ + / sizeof(ItemIdData) \ +) + /* ---------------------------------------------------------------- * extern declarations @@ -292,7 +307,6 @@ PageAddItem(Page page, Item item, Size size, OffsetNumber offsetNumber, ItemIdFlags flags); extern Page PageGetTempPage(Page page, Size specialSize); extern void PageRestoreTempPage(Page tempPage, Page oldPage); -extern OffsetNumber PageGetMaxOffsetNumber(Page page); extern void PageRepairFragmentation(Page page); extern Size PageGetFreeSpace(Page page); extern void PageManagerModeSet(PageManagerMode mode); diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index 6ee27af2c27..ab14efb52e2 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tqual.h,v 1.11 1997/11/20 23:24:03 momjian Exp $ + * $Id: tqual.h,v 1.12 1998/04/24 14:43:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,12 +15,51 @@ #include <access/htup.h> -/* As above, plus updates in this command */ +extern TransactionId HeapSpecialTransactionId; +extern CommandId HeapSpecialCommandId; -extern void setheapoverride(bool on); -extern bool heapisoverride(void); +/* + * HeapTupleSatisfiesVisibility -- + * True iff heap tuple satsifies a time qual. + * + * Note: + * Assumes heap tuple is valid. + */ +#define HeapTupleSatisfiesVisibility(tuple, seeself) \ +( \ + TransactionIdEquals((tuple)->t_xmax, AmiTransactionId) ? \ + false \ + : \ + ( \ + ((seeself) == true || heapisoverride()) ? \ + HeapTupleSatisfiesItself(tuple) \ + : \ + HeapTupleSatisfiesNow(tuple) \ + ) \ +) -extern bool HeapTupleSatisfiesVisibility(HeapTuple tuple, bool seeself); +#define heapisoverride() \ +( \ + (!TransactionIdIsValid(HeapSpecialTransactionId)) ? \ + false \ + : \ + ( \ + (!TransactionIdEquals(GetCurrentTransactionId(), \ + HeapSpecialTransactionId) || \ + GetCurrentCommandId() != HeapSpecialCommandId) ? \ + ( \ + HeapSpecialTransactionId = InvalidTransactionId, \ + false \ + ) \ + : \ + true \ + ) \ +) + +extern bool HeapTupleSatisfiesItself(HeapTuple tuple); +extern bool HeapTupleSatisfiesNow(HeapTuple tuple); + +extern void setheapoverride(bool on); #endif /* TQUAL_H */ |