diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-04 22:06:27 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-09-04 22:06:27 +0000 |
| commit | 7a3693716dad968569d3b91ce203841f1293370d (patch) | |
| tree | 60e513010279ef799fb63bab5cdc6c3187b1ae7e /src/backend/storage/lmgr/lmgr.c | |
| parent | ca43f71ca5c24497ad6f2904fd7ac9ce9b2bf75a (diff) | |
| download | postgresql-7a3693716dad968569d3b91ce203841f1293370d.tar.gz | |
Reimplement hash index locking algorithms, per my recent proposal to
pghackers. This fixes the problem recently reported by Markus KrÌutner
(hash bucket split corrupts the state of scans being done concurrently),
and I believe it also fixes all the known problems with deadlocks in
hash index operations. Hash indexes are still not really ready for prime
time (since they aren't WAL-logged), but this is a step forward.
Diffstat (limited to 'src/backend/storage/lmgr/lmgr.c')
| -rw-r--r-- | src/backend/storage/lmgr/lmgr.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index 12845f5593..c4fceb0096 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.59 2003/08/17 22:41:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.60 2003/09/04 22:06:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,7 @@ LockRelation(Relation relation, LOCKMODE lockmode) * As above, but only lock if we can get the lock without blocking. * Returns TRUE iff the lock was acquired. * - * NOTE: we do not currently need conditional versions of the other + * NOTE: we do not currently need conditional versions of all the * LockXXX routines in this file, but they could easily be added if needed. */ bool @@ -265,6 +265,26 @@ LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode) } /* + * ConditionalLockPage + * + * As above, but only lock if we can get the lock without blocking. + * Returns TRUE iff the lock was acquired. + */ +bool +ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode) +{ + LOCKTAG tag; + + MemSet(&tag, 0, sizeof(tag)); + tag.relId = relation->rd_lockInfo.lockRelId.relId; + tag.dbId = relation->rd_lockInfo.lockRelId.dbId; + tag.objId.blkno = blkno; + + return LockAcquire(LockTableId, &tag, GetCurrentTransactionId(), + lockmode, true); +} + +/* * UnlockPage */ void |
