/*
 * lmgr.h --
 *	POSTGRES lock manager definitions.
 *
 * Identification:
 *	$Header: RCS/lmgr.h,v 1.1 91/08/01 10:58:25 mer Exp $
 */

#ifndef	LMgrIncluded	/* Include this file only once */
#define LMgrIncluded	1

#include "tmp/postgres.h"

#include "storage/itemptr.h"
#include "storage/part.h"
#include "storage/pladt.h"
#include "storage/lock.h"
#include "utils/rel.h"

typedef struct LockInfoData  {
        bool                    initialized;
        LRelId                  lRelId;
        TransactionIdData       transactionIdData;
        uint16                  flags;
} LockInfoData;
typedef LockInfoData    *LockInfo;

/*
 * RelationGetLRelId --
 *	Returns "lock" relation identifier for a relation.
 */
extern
LRelId
RelationGetLRelId ARGS((
	Relation	relation
));

/*
 * LRelIdGetDatabaseId --
 *	Returns database identifier for a "lock" relation identifier.
 */
extern
ObjectId
LRelIdGetDatabaseId ARGS((
	Relation	relation
));

/*
 * LRelIdGetRelationId --
 *	Returns relation identifier for a "lock" relation identifier.
 */
extern
ObjectId
LRelIdGetRelationId ARGS((
	Relation	relation
));

/*
 * DatabaseIdIsMyDatabaseId --
 *	True iff database object identifier is valid in my present database.
 */
extern
bool
DatabaseIdIsMyDatabaseId ARGS((
	ObjectId	databaseId
));

/*
 * LRelIdContainsMyDatabaseId --
 *	True iff "lock" relation identifier is valid in my present database.
 */
extern
bool
LRelIdContainsMyDatabaseId ARGS((
	LRelId	lRelId
));

/*
 * RelationInitLockInfo --
 *	Initializes the lock information in a relation descriptor.
 */
extern
void
RelationInitLockInfo ARGS((
	Relation	relation
));

/*
 * RelationDiscardLockInfo --
 *	Discards the lock information in a relation descriptor.
 */
extern
void
RelationDiscardLockInfo ARGS((
	Relation	relation
));

/*
 * RelationSetLockForDescriptorOpen --
 *	Sets read locks for a relation descriptor.
 */
extern
void
RelationSetLockForDescriptorOpen ARGS((
	Relation	relation
));

/*
 * RelationSetLockForRead --
 *	Sets relation level read lock.
 */
extern
void
RelationSetLockForRead ARGS((
	Relation	relation
));

/*
 * RelationSetLockForWrite --
 *	Sets relation level write lock.
 */
extern
void
RelationSetLockForWrite ARGS((
	Relation	relation
));

/*
 * RelationUnsetLockForRead --
 *	Unsets relation level read lock.
 */
extern
void
RelationUnsetLockForRead ARGS((
	Relation	relation
));

/*
 * RelationUnsetLockForWrite --
 *	Unsets relation level write lock.
 */
extern
void
RelationUnsetLockForWrite ARGS((
	Relation	relation
));

/*
 * RelationSetLockForTupleRead --
 *	Sets tuple level read lock.
 */
extern
void
RelationSetLockForTupleRead ARGS((
	Relation	relation
	ItemPointer	itemPointer
));

/*
 * RelationSetLockForReadPage --
 *	Sets read lock on a page.
 */
extern
void
RelationSetLockForReadPage ARGS((
	Relation	relation,
	PagePartition	partition,
	ItemPointer	itemPointer
));

/*
 * RelationSetLockForWritePage --
 *	Sets write lock on a page.
 */
extern
void
RelationSetLockForWritePage ARGS((
	Relation	relation,
	PagePartition	partition,
	ItemPointer	itemPointer
));

/*
 * RelationUnsetLockForReadPage --
 *	Frees read lock on a page.
 */
extern
void
RelationUnsetLockForReadPage ARGS((
	Relation	relation,
	PagePartition	partition,
	ItemPointer	itemPointer
));

/*
 * RelationUnsetLockForWritePage --
 *	Frees write lock on a page.
 */
extern
void
RelationUnsetLockForWritePage ARGS((
	Relation	relation,
	PagePartition	partition,
	ItemPointer	itemPointer
));

#endif	/* !defined(LMgrIncluded) */
