Header And Logo

PostgreSQL
| The world's most advanced open source database.

lmgr.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * lmgr.h
00004  *    POSTGRES lock manager definitions.
00005  *
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/include/storage/lmgr.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef LMGR_H
00015 #define LMGR_H
00016 
00017 #include "lib/stringinfo.h"
00018 #include "storage/itemptr.h"
00019 #include "storage/lock.h"
00020 #include "utils/rel.h"
00021 
00022 
00023 extern void RelationInitLockInfo(Relation relation);
00024 
00025 /* Lock a relation */
00026 extern void LockRelationOid(Oid relid, LOCKMODE lockmode);
00027 extern bool ConditionalLockRelationOid(Oid relid, LOCKMODE lockmode);
00028 extern void UnlockRelationId(LockRelId *relid, LOCKMODE lockmode);
00029 extern void UnlockRelationOid(Oid relid, LOCKMODE lockmode);
00030 
00031 extern void LockRelation(Relation relation, LOCKMODE lockmode);
00032 extern bool ConditionalLockRelation(Relation relation, LOCKMODE lockmode);
00033 extern void UnlockRelation(Relation relation, LOCKMODE lockmode);
00034 extern bool LockHasWaitersRelation(Relation relation, LOCKMODE lockmode);
00035 
00036 extern void LockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode);
00037 extern void UnlockRelationIdForSession(LockRelId *relid, LOCKMODE lockmode);
00038 
00039 /* Lock a relation for extension */
00040 extern void LockRelationForExtension(Relation relation, LOCKMODE lockmode);
00041 extern void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode);
00042 
00043 /* Lock a page (currently only used within indexes) */
00044 extern void LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
00045 extern bool ConditionalLockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
00046 extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
00047 
00048 /* Lock a tuple (see heap_lock_tuple before assuming you understand this) */
00049 extern void LockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode);
00050 extern bool ConditionalLockTuple(Relation relation, ItemPointer tid,
00051                      LOCKMODE lockmode);
00052 extern void UnlockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode);
00053 
00054 /* Lock an XID (used to wait for a transaction to finish) */
00055 extern void XactLockTableInsert(TransactionId xid);
00056 extern void XactLockTableDelete(TransactionId xid);
00057 extern void XactLockTableWait(TransactionId xid);
00058 extern bool ConditionalXactLockTableWait(TransactionId xid);
00059 
00060 /* Lock a general object (other than a relation) of the current database */
00061 extern void LockDatabaseObject(Oid classid, Oid objid, uint16 objsubid,
00062                    LOCKMODE lockmode);
00063 extern void UnlockDatabaseObject(Oid classid, Oid objid, uint16 objsubid,
00064                      LOCKMODE lockmode);
00065 
00066 /* Lock a shared-across-databases object (other than a relation) */
00067 extern void LockSharedObject(Oid classid, Oid objid, uint16 objsubid,
00068                  LOCKMODE lockmode);
00069 extern void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid,
00070                    LOCKMODE lockmode);
00071 
00072 extern void LockSharedObjectForSession(Oid classid, Oid objid, uint16 objsubid,
00073                            LOCKMODE lockmode);
00074 extern void UnlockSharedObjectForSession(Oid classid, Oid objid, uint16 objsubid,
00075                              LOCKMODE lockmode);
00076 
00077 /* Describe a locktag for error messages */
00078 extern void DescribeLockTag(StringInfo buf, const LOCKTAG *tag);
00079 
00080 #endif   /* LMGR_H */