1 /*-------------------------------------------------------------------------
4 * set single locks in the multi-level lock hierarchy
6 * Sometimes we don't want to set all levels of the multi-level
7 * lock hierarchy at once. This allows us to set and release
8 * one level at a time. It's useful in index scans when
9 * you can set an intent lock at the beginning and thereafter
10 * only set page locks. Tends to speed things up.
12 * Copyright (c) 1994, Regents of the University of California
16 * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.7 1998/06/30 02:33:32 momjian Exp $
18 *-------------------------------------------------------------------------
24 #include "storage/lmgr.h" /* where the declarations go */
25 #include "storage/lock.h"
26 #include "storage/multilev.h"
27 #include "utils/rel.h"
30 * SingleLockReln -- lock a relation
32 * Returns: TRUE if the lock can be set, FALSE otherwise.
35 SingleLockReln(LockInfo linfo, LOCKMODE lockmode, int action)
40 * LOCKTAG has two bytes of padding, unfortunately. The hash function
41 * will return miss if the padding bytes aren't zero'd.
43 MemSet(&tag, 0, sizeof(tag));
44 tag.relId = linfo->lRelId.relId;
45 tag.dbId = linfo->lRelId.dbId;
46 BlockIdSet(&(tag.tupleId.ip_blkid), InvalidBlockNumber);
47 tag.tupleId.ip_posid = InvalidOffsetNumber;
50 return (LockRelease(MultiTableId, &tag, lockmode));
52 return (LockAcquire(MultiTableId, &tag, lockmode));
56 * SingleLockPage -- use multi-level lock table, but lock
57 * only at the page level.
59 * Assumes that an INTENT lock has already been set in the
60 * multi-level lock table.
64 SingleLockPage(LockInfo linfo,
72 * LOCKTAG has two bytes of padding, unfortunately. The hash function
73 * will return miss if the padding bytes aren't zero'd.
75 MemSet(&tag, 0, sizeof(tag));
76 tag.relId = linfo->lRelId.relId;
77 tag.dbId = linfo->lRelId.dbId;
78 BlockIdCopy(&(tag.tupleId.ip_blkid), &(tidPtr->ip_blkid));
79 tag.tupleId.ip_posid = InvalidOffsetNumber;
83 return (LockRelease(MultiTableId, &tag, lockmode));
85 return (LockAcquire(MultiTableId, &tag, lockmode));