aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-06-09 18:16:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-06-09 18:16:59 +0000
commitbdadc9bf1c0900487c372f2403c7c064d177d68c (patch)
treea64acd263294e66f91b8f5868f083b75fb5c8507 /src/include
parent32479891305bb80f428f189d48a1661dbe39d4f4 (diff)
downloadpostgresql-bdadc9bf1c0900487c372f2403c7c064d177d68c.tar.gz
postgresql-bdadc9bf1c0900487c372f2403c7c064d177d68c.zip
Remove RelationGetBufferWithBuffer(), which is horribly confused about
appropriate pin-count manipulation, and instead use ReleaseAndReadBuffer. Make use of the fact that the passed-in buffer (if there is one) must be pinned to avoid grabbing the bufmgr spinlock when we are able to return this same buffer. Eliminate unnecessary 'previous tuple' and 'next tuple' fields of HeapScanDesc and IndexScanDesc, thereby removing a whole lot of bookkeeping from heap_getnext() and related routines.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/relscan.h39
-rw-r--r--src/include/access/skey.h9
-rw-r--r--src/include/storage/buf.h19
-rw-r--r--src/include/storage/bufmgr.h8
4 files changed, 28 insertions, 47 deletions
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index b97b52979e4..8bfb514b1e4 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.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: relscan.h,v 1.20 2001/01/24 19:43:19 momjian Exp $
+ * $Id: relscan.h,v 1.21 2001/06/09 18:16:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,25 +16,16 @@
#include "utils/tqual.h"
-typedef ItemPointerData MarkData;
typedef struct HeapScanDescData
{
Relation rs_rd; /* pointer to relation descriptor */
- HeapTupleData rs_ptup; /* previous tuple in scan */
- HeapTupleData rs_ctup; /* current tuple in scan */
- HeapTupleData rs_ntup; /* next tuple in scan */
- Buffer rs_pbuf; /* previous buffer in scan */
- Buffer rs_cbuf; /* current buffer in scan */
- Buffer rs_nbuf; /* next buffer in scan */
- ItemPointerData rs_mptid; /* marked previous tid */
- ItemPointerData rs_mctid; /* marked current tid */
- ItemPointerData rs_mntid; /* marked next tid */
- ItemPointerData rs_mcd; /* marked current delta XXX ??? */
+ HeapTupleData rs_ctup; /* current tuple in scan, if any */
+ Buffer rs_cbuf; /* current buffer in scan, if any */
+ /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
+ ItemPointerData rs_mctid; /* marked tid, if any */
Snapshot rs_snapshot; /* snapshot to see */
- bool rs_atend; /* restart scan at end? */
- uint16 rs_cdelta; /* current delta in chain */
- uint16 rs_nkeys; /* number of attributes in keys */
+ uint16 rs_nkeys; /* number of scan keys to select tuples */
ScanKey rs_key; /* key descriptors */
} HeapScanDescData;
@@ -43,22 +34,24 @@ typedef HeapScanDescData *HeapScanDesc;
typedef struct IndexScanDescData
{
Relation relation; /* relation descriptor */
- void *opaque; /* am-specific slot */
- ItemPointerData previousItemData; /* previous index pointer */
+ void *opaque; /* access-method-specific info */
ItemPointerData currentItemData; /* current index pointer */
- ItemPointerData nextItemData; /* next index pointer */
- MarkData previousMarkData; /* marked previous pointer */
- MarkData currentMarkData;/* marked current pointer */
- MarkData nextMarkData; /* marked next pointer */
+ ItemPointerData currentMarkData; /* marked current pointer */
uint8 flags; /* scan position flags */
bool scanFromEnd; /* restart scan at end? */
- uint16 numberOfKeys; /* number of key attributes */
- ScanKey keyData; /* key descriptor */
+ uint16 numberOfKeys; /* number of scan keys to select tuples */
+ ScanKey keyData; /* key descriptors */
FmgrInfo fn_getnext; /* cached lookup info for am's getnext fn */
} IndexScanDescData;
typedef IndexScanDescData *IndexScanDesc;
+/* IndexScanDesc flag bits (none of these are actually used currently) */
+#define ScanUnmarked 0x01
+#define ScanUncheckedPrevious 0x02
+#define ScanUncheckedNext 0x04
+
+
/* ----------------
* IndexScanDescPtr is used in the executor where we have to
* keep track of several index scans when using several indices
diff --git a/src/include/access/skey.h b/src/include/access/skey.h
index 2a00e26744e..4e49f51afb1 100644
--- a/src/include/access/skey.h
+++ b/src/include/access/skey.h
@@ -7,8 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: skey.h,v 1.15 2001/06/01 02:41:36 tgl Exp $
- *
+ * $Id: skey.h,v 1.16 2001/06/09 18:16:59 tgl Exp $
*
* Note:
* Needs more accessor/assignment routines.
@@ -20,6 +19,7 @@
#include "access/attnum.h"
#include "fmgr.h"
+
typedef struct ScanKeyData
{
bits16 sk_flags; /* flags */
@@ -38,11 +38,6 @@ typedef ScanKeyData *ScanKey;
#define SK_COMMUTE 0x8 /* commute function (not fully supported) */
-#define ScanUnmarked 0x01
-#define ScanUncheckedPrevious 0x02
-#define ScanUncheckedNext 0x04
-
-
/*
* prototypes for functions in access/common/scankey.c
*/
diff --git a/src/include/storage/buf.h b/src/include/storage/buf.h
index c65e4cc9975..f31d5d5cc8d 100644
--- a/src/include/storage/buf.h
+++ b/src/include/storage/buf.h
@@ -7,17 +7,22 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf.h,v 1.8 2001/01/24 19:43:27 momjian Exp $
+ * $Id: buf.h,v 1.9 2001/06/09 18:16:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef BUF_H
#define BUF_H
-#define InvalidBuffer (0)
-#define UnknownBuffer (-99999)
+/*
+ * Buffer identifiers.
+ *
+ * Zero is invalid, positive is the index of a shared buffer (1..NBuffers),
+ * negative is the index of a local buffer (-1 .. -NLocBuffer).
+ */
+typedef int Buffer;
-typedef long Buffer;
+#define InvalidBuffer 0
/*
* BufferIsInvalid
@@ -26,12 +31,6 @@ typedef long Buffer;
#define BufferIsInvalid(buffer) ((buffer) == InvalidBuffer)
/*
- * BufferIsUnknown
- * True iff the buffer is unknown.
- */
-#define BufferIsUnknown(buffer) ((buffer) == UnknownBuffer)
-
-/*
* BufferIsLocal
* True iff the buffer is local (not visible to other servers).
*/
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index d45c8888c1d..9d7f568e193 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.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: bufmgr.h,v 1.51 2001/05/12 19:58:28 tgl Exp $
+ * $Id: bufmgr.h,v 1.52 2001/06/09 18:16:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -75,10 +75,6 @@ extern long *LocalRefCount;
* True iff the given buffer number is valid (either as a shared
* or local buffer).
*
- * Note:
- * BufferIsValid(InvalidBuffer) is False.
- * BufferIsValid(UnknownBuffer) is False.
- *
* Note: For a long time this was defined the same as BufferIsPinned,
* that is it would say False if you didn't hold a pin on the buffer.
* I believe this was bogus and served only to mask logic errors.
@@ -158,8 +154,6 @@ extern long *LocalRefCount;
/*
* prototypes for functions in bufmgr.c
*/
-extern Buffer RelationGetBufferWithBuffer(Relation relation,
- BlockNumber blockNumber, Buffer buffer);
extern Buffer ReadBuffer(Relation reln, BlockNumber blockNum);
extern int WriteBuffer(Buffer buffer);
extern int WriteNoReleaseBuffer(Buffer buffer);