Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

user_locks.c

Go to the documentation of this file.
00001 /*
00002  * user_locks.c --
00003  *
00004  * This loadable module provides support for user-level long-term
00005  * cooperative locks.
00006  *
00007  * Copyright (C) 1999, Massimo Dal Zotto <dz@cs.unitn.it>
00008  *
00009  * This software is distributed under the GNU General Public License
00010  * either version 2, or (at your option) any later version.
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 /* end of file */
00083 
00084 /*
00085  * Local Variables:
00086  *      tab-width: 4
00087  *      c-indent-level: 4
00088  *      c-basic-offset: 4
00089  * End:
00090  */

Generated on Sat Mar 27 19:20:44 2004 for Literature by doxygen 1.3.6-20040222