mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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...
This commit is contained in:
@ -16,66 +16,63 @@
|
|||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "storage/lock.h"
|
#include "storage/lmgr.h"
|
||||||
#include "storage/proc.h"
|
#include "storage/proc.h"
|
||||||
#include "storage/multilev.h"
|
|
||||||
#include "utils/elog.h"
|
#include "utils/elog.h"
|
||||||
|
|
||||||
#include "user_locks.h"
|
#include "user_locks.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
user_lock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
|
user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
memset(&tag, 0, sizeof(LOCKTAG));
|
memset(&tag, 0, sizeof(LOCKTAG));
|
||||||
tag.dbId = MyDatabaseId;
|
tag.dbId = MyDatabaseId;
|
||||||
tag.relId = 0;
|
tag.relId = 0;
|
||||||
tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
|
tag.objId.blkno = (BlockNumber) id2;
|
||||||
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
|
tag.offnum = (OffsetNumber) (id1 & 0xffff);
|
||||||
tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
|
|
||||||
|
|
||||||
return LockAcquire(USER_LOCKMETHOD, &tag, lockmode);
|
return LockAcquire(USER_LOCKMETHOD, &tag, lockmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
user_unlock(unsigned int id1, unsigned int id2, LOCKMODE lockmode)
|
user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode)
|
||||||
{
|
{
|
||||||
LOCKTAG tag;
|
LOCKTAG tag;
|
||||||
|
|
||||||
memset(&tag, 0, sizeof(LOCKTAG));
|
memset(&tag, 0, sizeof(LOCKTAG));
|
||||||
tag.dbId = MyDatabaseId;
|
tag.dbId = MyDatabaseId;
|
||||||
tag.relId = 0;
|
tag.relId = 0;
|
||||||
tag.tupleId.ip_blkid.bi_hi = id2 >> 16;
|
tag.objId.blkno = (BlockNumber) id2;
|
||||||
tag.tupleId.ip_blkid.bi_lo = id2 & 0xffff;
|
tag.offnum = (OffsetNumber) (id1 & 0xffff);
|
||||||
tag.tupleId.ip_posid = (unsigned short) (id1 & 0xffff);
|
|
||||||
|
|
||||||
return LockRelease(USER_LOCKMETHOD, &tag, lockmode);
|
return LockRelease(USER_LOCKMETHOD, &tag, lockmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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
|
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
|
int
|
||||||
user_write_lock_oid(Oid oid)
|
user_write_lock_oid(Oid oid)
|
||||||
{
|
{
|
||||||
return user_lock(0, oid, WRITE_LOCK);
|
return user_lock(0, oid, ExclusiveLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
user_write_unlock_oid(Oid oid)
|
user_write_unlock_oid(Oid oid)
|
||||||
{
|
{
|
||||||
return user_unlock(0, oid, WRITE_LOCK);
|
return user_unlock(0, oid, ExclusiveLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -68,7 +68,12 @@ typedef struct LTAG
|
|||||||
BlockNumber blkno;
|
BlockNumber blkno;
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
} objId;
|
} objId;
|
||||||
uint16 lockmethod; /* needed by user locks */
|
/*
|
||||||
|
* 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;
|
} LOCKTAG;
|
||||||
|
|
||||||
#define TAGSIZE (sizeof(LOCKTAG))
|
#define TAGSIZE (sizeof(LOCKTAG))
|
||||||
|
Reference in New Issue
Block a user