00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "server/postgres.h"
00013
00014 #include "server/miscadmin.h"
00015 #include "server/storage/lmgr.h"
00016 #include "server/storage/proc.h"
00017
00018 #include "user_locks.h"
00019
00020
00021 int
00022 user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode)
00023 {
00024 LOCKTAG tag;
00025
00026 memset(&tag, 0, sizeof(LOCKTAG));
00027 tag.dbId = MyDatabaseId;
00028 tag.relId = 0;
00029 tag.objId.blkno = (BlockNumber) id2;
00030 tag.offnum = (OffsetNumber) (id1 & 0xffff);
00031
00032 return LockAcquire(USER_LOCKMETHOD, &tag, InvalidTransactionId,
00033 lockmode, true);
00034 }
00035
00036 int
00037 user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode)
00038 {
00039 LOCKTAG tag;
00040
00041 memset(&tag, 0, sizeof(LOCKTAG));
00042 tag.dbId = MyDatabaseId;
00043 tag.relId = 0;
00044 tag.objId.blkno = (BlockNumber) id2;
00045 tag.offnum = (OffsetNumber) (id1 & 0xffff);
00046
00047 return LockRelease(USER_LOCKMETHOD, &tag, InvalidTransactionId, lockmode);
00048 }
00049
00050 int
00051 user_write_lock(uint32 id1, uint32 id2)
00052 {
00053 return user_lock(id1, id2, ExclusiveLock);
00054 }
00055
00056
00057 int
00058 user_write_unlock(uint32 id1, uint32 id2)
00059 {
00060 return user_unlock(id1, id2, ExclusiveLock);
00061 }
00062
00063 int
00064 user_write_lock_oid(Oid oid)
00065 {
00066 return user_lock(0, oid, ExclusiveLock);
00067 }
00068
00069 int
00070 user_write_unlock_oid(Oid oid)
00071 {
00072 return user_unlock(0, oid, ExclusiveLock);
00073 }
00074
00075 int
00076 user_unlock_all(void)
00077 {
00078 return LockReleaseAll(USER_LOCKMETHOD, MyProc, false,
00079 InvalidTransactionId);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090