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

Commit bbf37e9

Browse files
committed
typedef struct LTAG
{ Oid relId; Oid dbId; union { BlockNumber blkno; TransactionId xid; } objId; > > Added: > /* > * offnum should be part of objId.tupleId above, but would increase > * sizeof(LOCKTAG) and so moved here; currently used by userlocks only. > */ > OffsetNumber offnum; uint16 lockmethod; /* needed by userlocks */ } LOCKTAG; gmake clean required... User locks are ready for 6.5 release...
1 parent 42a02c4 commit bbf37e9

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

contrib/userlock/user_locks.c

+13-16
Original file line numberDiff line numberDiff line change
@@ -16,66 +16,63 @@
1616

1717
#include "postgres.h"
1818
#include "miscadmin.h"
19-
#include "storage/lock.h"
19+
#include "storage/lmgr.h"
2020
#include "storage/proc.h"
21-
#include "storage/multilev.h"
2221
#include "utils/elog.h"
2322

2423
#include "user_locks.h"
2524

2625
int
27-
user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
26+
user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode)
2827
{
2928
LOCKTAG tag;
3029

3130
memset(&tag, 0, sizeof(LOCKTAG));
3231
tag.dbId = MyDatabaseId;
3332
tag.relId = 0;
34-
tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
35-
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
36-
tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
33+
tag.objId.blkno = (BlockNumber) id2;
34+
tag.offnum = (OffsetNumber) (id1 & 0xffff);
3735

3836
return LockAcquire(USER_LOCKMETHOD, &tag, lockmode);
3937
}
4038

4139
int
42-
user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
40+
user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode)
4341
{
4442
LOCKTAG tag;
4543

4644
memset(&tag, 0, sizeof(LOCKTAG));
4745
tag.dbId = MyDatabaseId;
4846
tag.relId = 0;
49-
tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
50-
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
51-
tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
47+
tag.objId.blkno = (BlockNumber) id2;
48+
tag.offnum = (OffsetNumber) (id1 & 0xffff);
5249

5350
return LockRelease(USER_LOCKMETHOD, &tag, lockmode);
5451
}
5552

5653
int
57-
user_write_lock(unsigned int id1, unsigned int id2)
54+
user_write_lock(uint32 id1, uint32 id2)
5855
{
59-
return user_lock(id1, id2, WRITE_LOCK);
56+
return user_lock(id1, id2, ExclusiveLock);
6057
}
6158

6259

6360
int
64-
user_write_unlock(unsigned int id1, unsigned int id2)
61+
user_write_unlock(uint32 id1, uint32 id2)
6562
{
66-
return user_unlock(id1, id2, WRITE_LOCK);
63+
return user_unlock(id1, id2, ExclusiveLock);
6764
}
6865

6966
int
7067
user_write_lock_oid(Oid oid)
7168
{
72-
return user_lock(0, oid, WRITE_LOCK);
69+
return user_lock(0, oid, ExclusiveLock);
7370
}
7471

7572
int
7673
user_write_unlock_oid(Oid oid)
7774
{
78-
return user_unlock(0, oid, WRITE_LOCK);
75+
return user_unlock(0, oid, ExclusiveLock);
7976
}
8077

8178
int

src/include/storage/lock.h

+12-7
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: lock.h,v 1.29 1999/05/29 06:14:42 vadim Exp $
9+
* $Id: lock.h,v 1.30 1999/06/01 09:35:39 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -61,14 +61,19 @@ typedef int LOCKMETHOD;
6161

6262
typedef struct LTAG
6363
{
64-
Oid relId;
65-
Oid dbId;
64+
Oid relId;
65+
Oid dbId;
6666
union
6767
{
68-
BlockNumber blkno;
69-
TransactionId xid;
70-
} objId;
71-
uint16 lockmethod; /* needed by user locks */
68+
BlockNumber blkno;
69+
TransactionId xid;
70+
} objId;
71+
/*
72+
* offnum should be part of objId.tupleId above, but would increase
73+
* sizeof(LOCKTAG) and so moved here; currently used by userlocks only.
74+
*/
75+
OffsetNumber offnum;
76+
uint16 lockmethod; /* needed by userlocks */
7277
} LOCKTAG;
7378

7479
#define TAGSIZE (sizeof(LOCKTAG))

0 commit comments

Comments
 (0)