typedef struct LTAG
authorVadim B. Mikheev
Tue, 1 Jun 1999 09:35:39 +0000 (09:35 +0000)
committerVadim B. Mikheev
Tue, 1 Jun 1999 09:35:39 +0000 (09:35 +0000)
{
    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...

contrib/userlock/user_locks.c
src/include/storage/lock.h

index c3a6e8676bba6098e03330d7b7f9468b49228c70..27415dabb903c3fd91b6b3baed235a55ec8eea17 100644 (file)
 
 #include "postgres.h"
 #include "miscadmin.h"
-#include "storage/lock.h"
+#include "storage/lmgr.h"
 #include "storage/proc.h"
-#include "storage/multilev.h"
 #include "utils/elog.h"
 
 #include "user_locks.h"
 
 int
-user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
+user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode)
 {
    LOCKTAG     tag;
 
    memset(&tag, 0, sizeof(LOCKTAG));
    tag.dbId = MyDatabaseId;
    tag.relId = 0;
-   tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
-   tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
-   tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
+   tag.objId.blkno = (BlockNumber) id2;
+   tag.offnum = (OffsetNumber) (id1 & 0xffff);
 
    return LockAcquire(USER_LOCKMETHOD, &tag, lockmode);
 }
 
 int
-user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
+user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode)
 {
    LOCKTAG     tag;
 
    memset(&tag, 0, sizeof(LOCKTAG));
    tag.dbId = MyDatabaseId;
    tag.relId = 0;
-   tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
-   tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
-   tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
+   tag.objId.blkno = (BlockNumber) id2;
+   tag.offnum = (OffsetNumber) (id1 & 0xffff);
 
    return LockRelease(USER_LOCKMETHOD, &tag, lockmode);
 }
 
 int
-user_write_lock(unsigned int id1, unsigned int id2)
+user_write_lock(uint32 id1, uint32 id2)
 {
-   return user_lock(id1, id2, WRITE_LOCK);
+   return user_lock(id1, id2, ExclusiveLock);
 }
 
 
 int
-user_write_unlock(unsigned int id1, unsigned int id2)
+user_write_unlock(uint32 id1, uint32 id2)
 {
-   return user_unlock(id1, id2, WRITE_LOCK);
+   return user_unlock(id1, id2, ExclusiveLock);
 }
 
 int
 user_write_lock_oid(Oid oid)
 {
-   return user_lock(0, oid, WRITE_LOCK);
+   return user_lock(0, oid, ExclusiveLock);
 }
 
 int
 user_write_unlock_oid(Oid oid)
 {
-   return user_unlock(0, oid, WRITE_LOCK);
+   return user_unlock(0, oid, ExclusiveLock);
 }
 
 int
index 8693231a8c65ec3878180f927ff8a57ddaba76af..37b7b053ee8c29c0365e46ffa62639385a36f396 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: lock.h,v 1.29 1999/05/29 06:14:42 vadim Exp $
+ * $Id: lock.h,v 1.30 1999/06/01 09:35:39 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,14 +61,19 @@ typedef int LOCKMETHOD;
 
 typedef struct LTAG
 {
-   Oid         relId;
-   Oid         dbId;
+   Oid             relId;
+   Oid             dbId;
    union
    {
-       BlockNumber blkno;
-       TransactionId xid;
-   }           objId;
-   uint16      lockmethod;     /* needed by user locks */
+       BlockNumber     blkno;
+       TransactionId   xid;
+   }               objId;
+   /* 
+    * 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;
 
 #define TAGSIZE (sizeof(LOCKTAG))