From 3a694bb0a16fea1662f1ffd31506a72effdd4a93 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 29 Apr 2005 22:28:24 +0000 Subject: 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. --- contrib/userlock/user_locks.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'contrib/userlock/user_locks.c') diff --git a/contrib/userlock/user_locks.c b/contrib/userlock/user_locks.c index 3dee92ea31..207610084b 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: - */ -- cgit v1.2.1