diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-29 22:28:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-29 22:28:24 +0000 |
commit | 3a694bb0a16fea1662f1ffd31506a72effdd4a93 (patch) | |
tree | 50bbf16b3117aada49b2709f524b3bdcf1a36815 /contrib/userlock/user_locks.c | |
parent | 32d3b47e6f05c7137debddb68730a25fe1bb0cd6 (diff) |
Restructure LOCKTAG as per discussions of a couple months ago.
Essentially, we shoehorn in a lockable-object-type field by taking
a byte away from the lockmethodid, which can surely fit in one byte
instead of two. This allows less artificial definitions of all the
other fields of LOCKTAG; we can get rid of the special pg_xactlock
pseudo-relation, and also support locks on individual tuples and
general database objects (including shared objects). None of those
possibilities are actually exploited just yet, however.
I removed pg_xactlock from pg_class, but did not force initdb for
that change. At this point, relkind 's' (SPECIAL) is unused and
could be removed entirely.
Diffstat (limited to 'contrib/userlock/user_locks.c')
-rw-r--r-- | contrib/userlock/user_locks.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/contrib/userlock/user_locks.c b/contrib/userlock/user_locks.c index 3dee92ea316..207610084b1 100644 --- a/contrib/userlock/user_locks.c +++ b/contrib/userlock/user_locks.c @@ -18,16 +18,20 @@ #include "user_locks.h" +#define SET_LOCKTAG_USERLOCK(locktag,id1,id2) \ + ((locktag).locktag_field1 = (id1), \ + (locktag).locktag_field2 = (id2), \ + (locktag).locktag_field3 = MyDatabaseId, \ + (locktag).locktag_field4 = 0, \ + (locktag).locktag_type = LOCKTAG_USERLOCK) + + int user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode) { LOCKTAG tag; - memset(&tag, 0, sizeof(LOCKTAG)); - tag.dbId = MyDatabaseId; - tag.relId = 0; - tag.objId.blkno = (BlockNumber) id2; - tag.offnum = (OffsetNumber) (id1 & 0xffff); + SET_LOCKTAG_USERLOCK(tag, id1, id2); return LockAcquire(USER_LOCKMETHOD, &tag, InvalidTransactionId, lockmode, true); @@ -38,11 +42,7 @@ user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode) { LOCKTAG tag; - memset(&tag, 0, sizeof(LOCKTAG)); - tag.dbId = MyDatabaseId; - tag.relId = 0; - tag.objId.blkno = (BlockNumber) id2; - tag.offnum = (OffsetNumber) (id1 & 0xffff); + SET_LOCKTAG_USERLOCK(tag, id1, id2); return LockRelease(USER_LOCKMETHOD, &tag, InvalidTransactionId, lockmode); } @@ -77,13 +77,3 @@ user_unlock_all(void) { return LockReleaseAll(USER_LOCKMETHOD, true); } - -/* end of file */ - -/* - * Local Variables: - * tab-width: 4 - * c-indent-level: 4 - * c-basic-offset: 4 - * End: - */ |