Skip to content

Commit 519cd36

Browse files
committed
Get rid of page-level locking in btree-s.
BT_READ/BT_WRITE are BUFFER_LOCK_SHARE/BUFFER_LOCK_EXCLUSIVE now. Also get rid of #define BT_VERSION_1 - we use version 1 as default for near two years now.
1 parent 7d443a8 commit 519cd36

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/include/access/nbtree.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nbtree.h,v 1.25 1999/05/25 16:13:32 momjian Exp $
9+
* $Id: nbtree.h,v 1.26 1999/05/25 18:31:28 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -19,7 +19,7 @@
1919
#include <storage/page.h>
2020
#include <access/funcindex.h>
2121
#include <access/itup.h>
22-
#include <storage/buf.h>
22+
#include <storage/bufmgr.h> /* don't remove, required by BT_READ/BT_WRITE */
2323
#include <storage/itemptr.h>
2424

2525
/*
@@ -107,26 +107,17 @@ typedef BTScanOpaqueData *BTScanOpaque;
107107

108108
typedef struct BTItemData
109109
{
110-
#ifndef BTREE_VERSION_1
111-
Oid bti_oid;
112-
int32 bti_dummy; /* padding to make bti_itup align at
113-
* 8-byte boundary */
114-
#endif
115110
IndexTupleData bti_itup;
116111
} BTItemData;
117112

118113
typedef BTItemData *BTItem;
119114

120-
#ifdef BTREE_VERSION_1
121115
#define BTItemSame(i1, i2) ( i1->bti_itup.t_tid.ip_blkid.bi_hi == \
122116
i2->bti_itup.t_tid.ip_blkid.bi_hi && \
123117
i1->bti_itup.t_tid.ip_blkid.bi_lo == \
124118
i2->bti_itup.t_tid.ip_blkid.bi_lo && \
125119
i1->bti_itup.t_tid.ip_posid == \
126120
i2->bti_itup.t_tid.ip_posid )
127-
#else
128-
#define BTItemSame(i1, i2) ( i1->bti_oid == i2->bti_oid )
129-
#endif
130121

131122
/*
132123
* BTStackData -- As we descend a tree, we push the (key, pointer)
@@ -165,8 +156,8 @@ typedef struct BTPageState
165156
* requests for pages, in order to do locking correctly.
166157
*/
167158

168-
#define BT_READ 0
169-
#define BT_WRITE 1
159+
#define BT_READ BUFFER_LOCK_SHARE
160+
#define BT_WRITE BUFFER_LOCK_EXCLUSIVE
170161

171162
/*
172163
* Similarly, the difference between insertion and non-insertion binary

src/include/config.h.in

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,6 @@ extern void srandom(unsigned int seed);
506506
*/
507507
#define FASTBUILD /* access/nbtree/nbtsort.c */
508508

509-
/*
510-
* BTREE_VERSION_1: we must guarantee that all tuples in A LEVEL
511-
* are unique, not in ALL INDEX. So, we can use bti_itup->t_tid
512-
* as unique identifier for a given index tuple (logical position
513-
* within a level) and take off bti_oid & bti_dummy (8 bytes total)
514-
* from btree items.
515-
*/
516-
#define BTREE_VERSION_1
517-
518509
/*
519510
* TBL_FREE_CMD_MEMORY: free memory allocated for an user query inside
520511
* transaction block after this query is done.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy