Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3f7fbf8

Browse files
committed
Initial MVCC code.
New code for locking buffer' context.
1 parent c5a2716 commit 3f7fbf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1382
-1273
lines changed

src/backend/access/gist/gist.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ gistbuild(Relation heap,
104104
Buffer buffer = InvalidBuffer;
105105
bool *compvec;
106106

107-
/* GiSTs only know how to do stupid locking now */
108-
RelationSetLockForWrite(index);
107+
/* no locking is needed */
109108

110109
setheapoverride(true); /* so we can see the new pg_index tuple */
111110
initGISTstate(&giststate, index);
@@ -269,7 +268,6 @@ gistbuild(Relation heap,
269268

270269
/* okay, all heap tuples are indexed */
271270
heap_endscan(scan);
272-
RelationUnsetLockForWrite(index);
273271

274272
if (pred != NULL || oldPred != NULL)
275273
{
@@ -343,15 +341,19 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
343341
itup = index_formtuple(RelationGetDescr(r), datum, nulls);
344342
itup->t_tid = *ht_ctid;
345343

344+
/*
345+
* Notes in ExecUtils:ExecOpenIndices()
346+
*
346347
RelationSetLockForWrite(r);
348+
*/
349+
347350
res = gistdoinsert(r, itup, &giststate);
348351
for (i = 0; i < r->rd_att->natts; i++)
349352
if (compvec[i] == TRUE)
350353
pfree((char *) datum[i]);
351354
pfree(itup);
352355
pfree(compvec);
353356

354-
/* XXX two-phase locking -- don't unlock the relation until EOT */
355357
return res;
356358
}
357359

@@ -1103,8 +1105,12 @@ gistdelete(Relation r, ItemPointer tid)
11031105
Buffer buf;
11041106
Page page;
11051107

1106-
/* must write-lock on delete */
1108+
/*
1109+
* Notes in ExecUtils:ExecOpenIndices()
1110+
* Also note that only vacuum deletes index tuples now...
1111+
*
11071112
RelationSetLockForWrite(r);
1113+
*/
11081114

11091115
blkno = ItemPointerGetBlockNumber(tid);
11101116
offnum = ItemPointerGetOffsetNumber(tid);
@@ -1120,7 +1126,6 @@ gistdelete(Relation r, ItemPointer tid)
11201126

11211127
WriteBuffer(buf);
11221128

1123-
/* XXX -- two-phase locking, don't release the write lock */
11241129
}
11251130

11261131
void

src/backend/access/gist/gistscan.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ gistbeginscan(Relation r,
6565
{
6666
IndexScanDesc s;
6767

68+
/*
69+
* Let index_beginscan does its work...
70+
*
6871
RelationSetLockForRead(r);
72+
*/
73+
6974
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
7075
gistregscan(s);
7176

src/backend/access/hash/hashpage.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.17 1998/09/01 03:20:58 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.18 1998/12/15 12:45:10 vadim Exp $
1111
*
1212
* NOTES
1313
* Postgres hash pages look like ordinary relation pages. The opaque
@@ -81,7 +81,7 @@ _hash_metapinit(Relation rel)
8181

8282
/* can't be sharing this with anyone, now... */
8383
if (USELOCKING)
84-
RelationSetLockForWrite(rel);
84+
LockRelation(rel, AccessExclusiveLock);
8585

8686
if ((nblocks = RelationGetNumberOfBlocks(rel)) != 0)
8787
{
@@ -169,7 +169,7 @@ _hash_metapinit(Relation rel)
169169
_hash_relbuf(rel, metabuf, HASH_WRITE);
170170

171171
if (USELOCKING)
172-
RelationUnsetLockForWrite(rel);
172+
UnlockRelation(rel, AccessExclusiveLock);
173173
}
174174

175175
/*
@@ -316,19 +316,16 @@ _hash_setpagelock(Relation rel,
316316
BlockNumber blkno,
317317
int access)
318318
{
319-
ItemPointerData iptr;
320319

321320
if (USELOCKING)
322321
{
323-
ItemPointerSet(&iptr, blkno, 1);
324-
325322
switch (access)
326323
{
327324
case HASH_WRITE:
328-
RelationSetSingleWLockPage(rel, &iptr);
325+
LockPage(rel, blkno, ExclusiveLock);
329326
break;
330327
case HASH_READ:
331-
RelationSetSingleRLockPage(rel, &iptr);
328+
LockPage(rel, blkno, ShareLock);
332329
break;
333330
default:
334331
elog(ERROR, "_hash_setpagelock: invalid access (%d) on blk %x: %s",
@@ -343,19 +340,16 @@ _hash_unsetpagelock(Relation rel,
343340
BlockNumber blkno,
344341
int access)
345342
{
346-
ItemPointerData iptr;
347343

348344
if (USELOCKING)
349345
{
350-
ItemPointerSet(&iptr, blkno, 1);
351-
352346
switch (access)
353347
{
354348
case HASH_WRITE:
355-
RelationUnsetSingleWLockPage(rel, &iptr);
349+
UnlockPage(rel, blkno, ExclusiveLock);
356350
break;
357351
case HASH_READ:
358-
RelationUnsetSingleRLockPage(rel, &iptr);
352+
UnlockPage(rel, blkno, ShareLock);
359353
break;
360354
default:
361355
elog(ERROR, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s",

0 commit comments

Comments
 (0)