1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* lock.h
|
2000-12-22 01:51:54 +01:00
|
|
|
* POSTGRES low-level lock mechanism
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2004-12-31 23:04:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2005-08-21 01:26:37 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.90 2005/08/20 23:26:33 tgl Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef LOCK_H_
|
|
|
|
#define LOCK_H_
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "storage/itemptr.h"
|
2001-09-29 06:02:27 +02:00
|
|
|
#include "storage/lwlock.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "storage/shmem.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
|
2000-12-22 01:51:54 +01:00
|
|
|
/* originally in procq.h */
|
|
|
|
typedef struct PROC_QUEUE
|
|
|
|
{
|
2002-06-11 15:40:53 +02:00
|
|
|
SHM_QUEUE links; /* head of list of PGPROC objects */
|
2001-01-22 23:30:06 +01:00
|
|
|
int size; /* number of entries in list */
|
2000-12-22 01:51:54 +01:00
|
|
|
} PROC_QUEUE;
|
|
|
|
|
2004-08-26 19:22:28 +02:00
|
|
|
/* struct PGPROC is declared in proc.h, but must forward-reference it */
|
2002-06-11 15:40:53 +02:00
|
|
|
typedef struct PGPROC PGPROC;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2004-08-26 19:22:28 +02:00
|
|
|
/* GUC variables */
|
2001-06-28 01:31:40 +02:00
|
|
|
extern int max_locks_per_xact;
|
|
|
|
|
2000-05-31 02:28:42 +02:00
|
|
|
#ifdef LOCK_DEBUG
|
2001-03-22 05:01:46 +01:00
|
|
|
extern int Trace_lock_oidmin;
|
2000-05-31 02:28:42 +02:00
|
|
|
extern bool Trace_locks;
|
|
|
|
extern bool Trace_userlocks;
|
2001-03-22 05:01:46 +01:00
|
|
|
extern int Trace_lock_table;
|
2000-05-31 02:28:42 +02:00
|
|
|
extern bool Debug_deadlocks;
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* LOCK_DEBUG */
|
2000-05-31 02:28:42 +02:00
|
|
|
|
|
|
|
|
2004-08-26 19:22:28 +02:00
|
|
|
/*
|
|
|
|
* LOCKMODE is an integer (1..N) indicating a lock type. LOCKMASK is a bit
|
|
|
|
* mask indicating a set of held or requested lock types (the bit 1<<mode
|
|
|
|
* corresponds to a particular lock mode).
|
|
|
|
*/
|
2000-12-22 01:51:54 +01:00
|
|
|
typedef int LOCKMASK;
|
1998-06-30 04:33:34 +02:00
|
|
|
typedef int LOCKMODE;
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2001-01-22 23:30:06 +01:00
|
|
|
/* MAX_LOCKMODES cannot be larger than the # of bits in LOCKMASK */
|
2001-07-10 00:18:34 +02:00
|
|
|
#define MAX_LOCKMODES 10
|
1996-08-28 03:59:28 +02:00
|
|
|
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
#define LOCKBIT_ON(lockmode) (1 << (lockmode))
|
|
|
|
#define LOCKBIT_OFF(lockmode) (~(1 << (lockmode)))
|
|
|
|
|
2004-08-26 19:22:28 +02:00
|
|
|
/*
|
|
|
|
* There is normally only one lock method, the default one.
|
|
|
|
* If user locks are enabled, an additional lock method is present.
|
2005-04-30 00:28:24 +02:00
|
|
|
* Lock methods are identified by LOCKMETHODID. (Despite the declaration as
|
|
|
|
* uint16, we are constrained to 256 lockmethods by the layout of LOCKTAG.)
|
2004-08-26 19:22:28 +02:00
|
|
|
*/
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
typedef uint16 LOCKMETHODID;
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2001-09-29 06:02:27 +02:00
|
|
|
/* MAX_LOCK_METHODS is the number of distinct lock control tables allowed */
|
1998-09-01 06:40:42 +02:00
|
|
|
#define MAX_LOCK_METHODS 3
|
1996-08-28 03:59:28 +02:00
|
|
|
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
#define INVALID_LOCKMETHOD 0
|
1998-08-25 23:20:32 +02:00
|
|
|
#define DEFAULT_LOCKMETHOD 1
|
|
|
|
#define USER_LOCKMETHOD 2
|
1996-08-28 03:59:28 +02:00
|
|
|
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
#define LockMethodIsValid(lockmethodid) ((lockmethodid) != INVALID_LOCKMETHOD)
|
|
|
|
|
2004-08-29 07:07:03 +02:00
|
|
|
extern int NumLockMethods;
|
2004-08-27 19:07:42 +02:00
|
|
|
|
|
|
|
|
2001-06-22 02:04:59 +02:00
|
|
|
/*
|
2004-08-26 19:22:28 +02:00
|
|
|
* This is the control structure for a lock table. It lives in shared
|
2004-08-29 07:07:03 +02:00
|
|
|
* memory. Currently, none of these fields change after startup. In addition
|
2004-08-27 19:07:42 +02:00
|
|
|
* to the LockMethodData, a lock table has a shared "lockHash" table holding
|
|
|
|
* per-locked-object lock information, and a shared "proclockHash" table
|
|
|
|
* holding per-lock-holder/waiter lock information.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2004-08-27 19:07:42 +02:00
|
|
|
* masterLock -- LWLock used to synchronize access to the table
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
1998-06-30 04:33:34 +02:00
|
|
|
* numLockModes -- number of lock types (READ,WRITE,etc) that
|
1997-09-07 07:04:48 +02:00
|
|
|
* are defined on this lock table
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* conflictTab -- this is an array of bitmasks showing lock
|
1997-09-07 07:04:48 +02:00
|
|
|
* type conflicts. conflictTab[i] is a mask with the j-th bit
|
|
|
|
* turned on if lock types i and j conflict.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
typedef struct LockMethodData
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2004-08-29 07:07:03 +02:00
|
|
|
LWLockId masterLock;
|
|
|
|
int numLockModes;
|
|
|
|
LOCKMASK conflictTab[MAX_LOCKMODES];
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
} LockMethodData;
|
2004-08-27 19:07:42 +02:00
|
|
|
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
typedef LockMethodData *LockMethod;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1998-08-25 23:20:32 +02:00
|
|
|
|
2000-12-22 01:51:54 +01:00
|
|
|
/*
|
|
|
|
* LOCKTAG is the key information needed to look up a LOCK item in the
|
2001-03-22 05:01:46 +01:00
|
|
|
* lock hashtable. A LOCKTAG value uniquely identifies a lockable object.
|
2005-04-30 00:28:24 +02:00
|
|
|
*
|
|
|
|
* The LockTagType enum defines the different kinds of objects we can lock.
|
|
|
|
* We can handle up to 256 different LockTagTypes.
|
2000-12-22 01:51:54 +01:00
|
|
|
*/
|
2005-04-30 00:28:24 +02:00
|
|
|
typedef enum LockTagType
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2005-04-30 00:28:24 +02:00
|
|
|
LOCKTAG_RELATION, /* whole relation */
|
|
|
|
/* ID info for a relation is DB OID + REL OID; DB OID = 0 if shared */
|
|
|
|
LOCKTAG_RELATION_EXTEND, /* the right to extend a relation */
|
|
|
|
/* same ID info as RELATION */
|
|
|
|
LOCKTAG_PAGE, /* one page of a relation */
|
|
|
|
/* ID info for a page is RELATION info + BlockNumber */
|
|
|
|
LOCKTAG_TUPLE, /* one physical tuple */
|
|
|
|
/* ID info for a tuple is PAGE info + OffsetNumber */
|
|
|
|
LOCKTAG_TRANSACTION, /* transaction (for waiting for xact done) */
|
|
|
|
/* ID info for a transaction is its TransactionId */
|
|
|
|
LOCKTAG_OBJECT, /* non-relation database object */
|
|
|
|
/* ID info for an object is DB OID + CLASS OID + OBJECT OID + SUBID */
|
2000-12-22 01:51:54 +01:00
|
|
|
/*
|
2005-04-30 00:28:24 +02:00
|
|
|
* Note: object ID has same representation as in pg_depend and
|
|
|
|
* pg_description, but notice that we are constraining SUBID to 16 bits.
|
|
|
|
* Also, we use DB OID = 0 for shared objects such as tablespaces.
|
2000-12-22 01:51:54 +01:00
|
|
|
*/
|
2005-04-30 00:28:24 +02:00
|
|
|
LOCKTAG_USERLOCK /* reserved for contrib/userlock */
|
|
|
|
/* ID info for a userlock is defined by user_locks.c */
|
|
|
|
} LockTagType;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2005-04-30 00:28:24 +02:00
|
|
|
/*
|
|
|
|
* The LOCKTAG struct is defined with malice aforethought to fit into 16
|
|
|
|
* bytes with no padding. Note that this would need adjustment if we were
|
|
|
|
* to widen Oid, BlockNumber, or TransactionId to more than 32 bits.
|
|
|
|
*
|
|
|
|
* We include lockmethodid in the locktag so that a single hash table in
|
|
|
|
* shared memory can store locks of different lockmethods. For largely
|
|
|
|
* historical reasons, it's passed to the lock.c routines as a separate
|
|
|
|
* argument and then stored into the locktag.
|
|
|
|
*/
|
|
|
|
typedef struct LOCKTAG
|
|
|
|
{
|
|
|
|
uint32 locktag_field1; /* a 32-bit ID field */
|
|
|
|
uint32 locktag_field2; /* a 32-bit ID field */
|
|
|
|
uint32 locktag_field3; /* a 32-bit ID field */
|
|
|
|
uint16 locktag_field4; /* a 16-bit ID field */
|
|
|
|
uint8 locktag_type; /* see enum LockTagType */
|
|
|
|
uint8 locktag_lockmethodid; /* lockmethod indicator */
|
2000-12-22 01:51:54 +01:00
|
|
|
} LOCKTAG;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2005-04-30 00:28:24 +02:00
|
|
|
/*
|
|
|
|
* These macros define how we map logical IDs of lockable objects into
|
|
|
|
* the physical fields of LOCKTAG. Use these to set up LOCKTAG values,
|
|
|
|
* rather than accessing the fields directly. Note multiple eval of target!
|
|
|
|
*/
|
|
|
|
#define SET_LOCKTAG_RELATION(locktag,dboid,reloid) \
|
|
|
|
((locktag).locktag_field1 = (dboid), \
|
|
|
|
(locktag).locktag_field2 = (reloid), \
|
|
|
|
(locktag).locktag_field3 = 0, \
|
|
|
|
(locktag).locktag_field4 = 0, \
|
|
|
|
(locktag).locktag_type = LOCKTAG_RELATION)
|
|
|
|
|
|
|
|
#define SET_LOCKTAG_RELATION_EXTEND(locktag,dboid,reloid) \
|
|
|
|
((locktag).locktag_field1 = (dboid), \
|
|
|
|
(locktag).locktag_field2 = (reloid), \
|
|
|
|
(locktag).locktag_field3 = 0, \
|
|
|
|
(locktag).locktag_field4 = 0, \
|
|
|
|
(locktag).locktag_type = LOCKTAG_RELATION_EXTEND)
|
|
|
|
|
|
|
|
#define SET_LOCKTAG_PAGE(locktag,dboid,reloid,blocknum) \
|
|
|
|
((locktag).locktag_field1 = (dboid), \
|
|
|
|
(locktag).locktag_field2 = (reloid), \
|
|
|
|
(locktag).locktag_field3 = (blocknum), \
|
|
|
|
(locktag).locktag_field4 = 0, \
|
|
|
|
(locktag).locktag_type = LOCKTAG_PAGE)
|
|
|
|
|
|
|
|
#define SET_LOCKTAG_TUPLE(locktag,dboid,reloid,blocknum,offnum) \
|
|
|
|
((locktag).locktag_field1 = (dboid), \
|
|
|
|
(locktag).locktag_field2 = (reloid), \
|
|
|
|
(locktag).locktag_field3 = (blocknum), \
|
|
|
|
(locktag).locktag_field4 = (offnum), \
|
|
|
|
(locktag).locktag_type = LOCKTAG_TUPLE)
|
|
|
|
|
|
|
|
#define SET_LOCKTAG_TRANSACTION(locktag,xid) \
|
|
|
|
((locktag).locktag_field1 = (xid), \
|
|
|
|
(locktag).locktag_field2 = 0, \
|
|
|
|
(locktag).locktag_field3 = 0, \
|
|
|
|
(locktag).locktag_field4 = 0, \
|
|
|
|
(locktag).locktag_type = LOCKTAG_TRANSACTION)
|
|
|
|
|
|
|
|
#define SET_LOCKTAG_OBJECT(locktag,dboid,classoid,objoid,objsubid) \
|
|
|
|
((locktag).locktag_field1 = (dboid), \
|
|
|
|
(locktag).locktag_field2 = (classoid), \
|
|
|
|
(locktag).locktag_field3 = (objoid), \
|
|
|
|
(locktag).locktag_field4 = (objsubid), \
|
|
|
|
(locktag).locktag_type = LOCKTAG_OBJECT)
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
2000-12-22 01:51:54 +01:00
|
|
|
* Per-locked-object lock information:
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* tag -- uniquely identifies the object being locked
|
2001-01-16 07:11:34 +01:00
|
|
|
* grantMask -- bitmask for all lock types currently granted on this object.
|
|
|
|
* waitMask -- bitmask for all lock types currently awaited on this object.
|
2004-08-27 19:07:42 +02:00
|
|
|
* procLocks -- list of PROCLOCK objects for this lock.
|
2001-01-16 07:11:34 +01:00
|
|
|
* waitProcs -- queue of processes waiting for this lock.
|
|
|
|
* requested -- count of each lock type currently requested on the lock
|
|
|
|
* (includes requests already granted!!).
|
|
|
|
* nRequested -- total requested locks of all types.
|
|
|
|
* granted -- count of each lock type currently granted on the lock.
|
|
|
|
* nGranted -- total granted locks of all types.
|
2005-06-15 00:15:33 +02:00
|
|
|
*
|
|
|
|
* Note: these counts count 1 for each backend. Internally to a backend,
|
|
|
|
* there may be multiple grabs on a particular lock, but this is not reflected
|
|
|
|
* into shared memory.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1998-06-30 04:33:34 +02:00
|
|
|
typedef struct LOCK
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
|
|
|
/* hash key */
|
2001-01-16 07:11:34 +01:00
|
|
|
LOCKTAG tag; /* unique identifier of lockable object */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/* data */
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
LOCKMASK grantMask; /* bitmask for lock types already granted */
|
|
|
|
LOCKMASK waitMask; /* bitmask for lock types awaited */
|
2004-08-27 19:07:42 +02:00
|
|
|
SHM_QUEUE procLocks; /* list of PROCLOCK objects assoc. with
|
2002-09-04 22:31:48 +02:00
|
|
|
* lock */
|
2002-06-11 15:40:53 +02:00
|
|
|
PROC_QUEUE waitProcs; /* list of PGPROC objects waiting on lock */
|
2001-03-22 05:01:46 +01:00
|
|
|
int requested[MAX_LOCKMODES]; /* counts of requested
|
|
|
|
* locks */
|
2001-01-16 07:11:34 +01:00
|
|
|
int nRequested; /* total of requested[] array */
|
2001-03-22 05:01:46 +01:00
|
|
|
int granted[MAX_LOCKMODES]; /* counts of granted locks */
|
2001-01-16 07:11:34 +01:00
|
|
|
int nGranted; /* total of granted[] array */
|
1997-09-08 23:56:23 +02:00
|
|
|
} LOCK;
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2005-04-30 00:28:24 +02:00
|
|
|
#define LOCK_LOCKMETHOD(lock) ((LOCKMETHODID) (lock).tag.locktag_lockmethodid)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-12-22 01:51:54 +01:00
|
|
|
|
|
|
|
/*
|
2005-06-15 00:15:33 +02:00
|
|
|
* We may have several different backends holding or awaiting locks
|
2004-08-26 19:22:28 +02:00
|
|
|
* on the same lockable object. We need to store some per-holder/waiter
|
|
|
|
* information for each such holder (or would-be holder). This is kept in
|
|
|
|
* a PROCLOCK struct.
|
2000-12-22 01:51:54 +01:00
|
|
|
*
|
2002-07-19 02:17:40 +02:00
|
|
|
* PROCLOCKTAG is the key information needed to look up a PROCLOCK item in the
|
2004-08-26 19:22:28 +02:00
|
|
|
* proclock hashtable. A PROCLOCKTAG value uniquely identifies the combination
|
|
|
|
* of a lockable object and a holder/waiter for that object.
|
2000-12-22 01:51:54 +01:00
|
|
|
*
|
2005-06-15 00:15:33 +02:00
|
|
|
* Internally to a backend, it is possible for the same lock to be held
|
|
|
|
* for different purposes: the backend tracks transaction locks separately
|
|
|
|
* from session locks. However, this is not reflected in the shared-memory
|
|
|
|
* state: we only track which backend(s) hold the lock. This is OK since a
|
|
|
|
* backend can never block itself.
|
2001-01-16 07:11:34 +01:00
|
|
|
*
|
2004-08-27 19:07:42 +02:00
|
|
|
* The holdMask field shows the already-granted locks represented by this
|
|
|
|
* proclock. Note that there will be a proclock object, possibly with
|
|
|
|
* zero holdMask, for any lock that the process is currently waiting on.
|
|
|
|
* Otherwise, proclock objects whose holdMasks are zero are recycled
|
2001-01-16 07:11:34 +01:00
|
|
|
* as soon as convenient.
|
2001-01-22 23:30:06 +01:00
|
|
|
*
|
2005-06-15 00:15:33 +02:00
|
|
|
* releaseMask is workspace for LockReleaseAll(): it shows the locks due
|
|
|
|
* to be released during the current call. This must only be examined or
|
|
|
|
* set by the backend owning the PROCLOCK.
|
|
|
|
*
|
2004-07-01 02:52:04 +02:00
|
|
|
* Each PROCLOCK object is linked into lists for both the associated LOCK
|
|
|
|
* object and the owning PGPROC object. Note that the PROCLOCK is entered
|
|
|
|
* into these lists as soon as it is created, even if no lock has yet been
|
|
|
|
* granted. A PGPROC that is waiting for a lock to be granted will also be
|
|
|
|
* linked into the lock's waitProcs queue.
|
2000-12-22 01:51:54 +01:00
|
|
|
*/
|
2002-07-19 02:17:40 +02:00
|
|
|
typedef struct PROCLOCKTAG
|
2000-12-22 01:51:54 +01:00
|
|
|
{
|
|
|
|
SHMEM_OFFSET lock; /* link to per-lockable-object information */
|
2002-06-11 15:40:53 +02:00
|
|
|
SHMEM_OFFSET proc; /* link to PGPROC of owning backend */
|
2002-07-19 02:17:40 +02:00
|
|
|
} PROCLOCKTAG;
|
2000-12-22 01:51:54 +01:00
|
|
|
|
2002-07-19 02:17:40 +02:00
|
|
|
typedef struct PROCLOCK
|
2000-12-22 01:51:54 +01:00
|
|
|
{
|
|
|
|
/* tag */
|
2003-02-18 03:13:24 +01:00
|
|
|
PROCLOCKTAG tag; /* unique identifier of proclock object */
|
2000-12-22 01:51:54 +01:00
|
|
|
|
|
|
|
/* data */
|
2004-08-27 19:07:42 +02:00
|
|
|
LOCKMASK holdMask; /* bitmask for lock types currently held */
|
2005-06-15 00:15:33 +02:00
|
|
|
LOCKMASK releaseMask; /* bitmask for lock types to be released */
|
|
|
|
SHM_QUEUE lockLink; /* list link in LOCK's list of proclocks */
|
|
|
|
SHM_QUEUE procLink; /* list link in PGPROC's list of proclocks */
|
2002-07-19 02:17:40 +02:00
|
|
|
} PROCLOCK;
|
2000-12-22 01:51:54 +01:00
|
|
|
|
2003-02-18 03:13:24 +01:00
|
|
|
#define PROCLOCK_LOCKMETHOD(proclock) \
|
2005-04-30 00:28:24 +02:00
|
|
|
LOCK_LOCKMETHOD(*((LOCK *) MAKE_PTR((proclock).tag.lock)))
|
2000-12-22 01:51:54 +01:00
|
|
|
|
2004-08-27 19:07:42 +02:00
|
|
|
/*
|
|
|
|
* Each backend also maintains a local hash table with information about each
|
2004-08-29 07:07:03 +02:00
|
|
|
* lock it is currently interested in. In particular the local table counts
|
2004-08-27 19:07:42 +02:00
|
|
|
* the number of times that lock has been acquired. This allows multiple
|
|
|
|
* requests for the same lock to be executed without additional accesses to
|
|
|
|
* shared memory. We also track the number of lock acquisitions per
|
|
|
|
* ResourceOwner, so that we can release just those locks belonging to a
|
|
|
|
* particular ResourceOwner.
|
|
|
|
*/
|
|
|
|
typedef struct LOCALLOCKTAG
|
|
|
|
{
|
|
|
|
LOCKTAG lock; /* identifies the lockable object */
|
|
|
|
LOCKMODE mode; /* lock mode for this table entry */
|
|
|
|
} LOCALLOCKTAG;
|
|
|
|
|
|
|
|
typedef struct LOCALLOCKOWNER
|
|
|
|
{
|
|
|
|
/*
|
2005-06-15 00:15:33 +02:00
|
|
|
* Note: if owner is NULL then the lock is held on behalf of the session;
|
|
|
|
* otherwise it is held on behalf of my current transaction.
|
|
|
|
*
|
|
|
|
* Must use a forward struct reference to avoid circularity.
|
2004-08-27 19:07:42 +02:00
|
|
|
*/
|
|
|
|
struct ResourceOwnerData *owner;
|
|
|
|
int nLocks; /* # of times held by this owner */
|
|
|
|
} LOCALLOCKOWNER;
|
|
|
|
|
|
|
|
typedef struct LOCALLOCK
|
|
|
|
{
|
|
|
|
/* tag */
|
|
|
|
LOCALLOCKTAG tag; /* unique identifier of locallock entry */
|
|
|
|
|
|
|
|
/* data */
|
|
|
|
LOCK *lock; /* associated LOCK object in shared mem */
|
|
|
|
PROCLOCK *proclock; /* associated PROCLOCK object in shmem */
|
2005-06-15 00:15:33 +02:00
|
|
|
bool isTempObject; /* true if lock is on a temporary object */
|
2004-08-27 19:07:42 +02:00
|
|
|
int nLocks; /* total number of times lock is held */
|
|
|
|
int numLockOwners; /* # of relevant ResourceOwners */
|
|
|
|
int maxLockOwners; /* allocated size of array */
|
2004-08-29 07:07:03 +02:00
|
|
|
LOCALLOCKOWNER *lockOwners; /* dynamically resizable array */
|
2004-08-27 19:07:42 +02:00
|
|
|
} LOCALLOCK;
|
|
|
|
|
2005-04-30 00:28:24 +02:00
|
|
|
#define LOCALLOCK_LOCKMETHOD(llock) ((llock).tag.lock.locktag_lockmethodid)
|
2004-08-27 19:07:42 +02:00
|
|
|
|
|
|
|
|
2002-08-17 15:04:19 +02:00
|
|
|
/*
|
2002-08-31 19:14:28 +02:00
|
|
|
* This struct holds information passed from lmgr internals to the lock
|
2002-09-04 22:31:48 +02:00
|
|
|
* listing user-level functions (lockfuncs.c). For each PROCLOCK in the
|
2002-08-31 19:14:28 +02:00
|
|
|
* system, the SHMEM_OFFSET, PROCLOCK itself, and associated PGPROC and
|
|
|
|
* LOCK objects are stored. (Note there will often be multiple copies
|
|
|
|
* of the same PGPROC or LOCK.) We do not store the SHMEM_OFFSET of the
|
|
|
|
* PGPROC or LOCK separately, since they're in the PROCLOCK's tag fields.
|
2002-08-17 15:04:19 +02:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2002-09-04 22:31:48 +02:00
|
|
|
int nelements; /* The length of each of the arrays */
|
2003-02-18 03:13:24 +01:00
|
|
|
SHMEM_OFFSET *proclockaddrs;
|
|
|
|
PROCLOCK *proclocks;
|
2002-09-04 22:31:48 +02:00
|
|
|
PGPROC *procs;
|
|
|
|
LOCK *locks;
|
2002-08-17 15:04:19 +02:00
|
|
|
} LockData;
|
2000-12-22 01:51:54 +01:00
|
|
|
|
2004-05-28 07:13:32 +02:00
|
|
|
|
2005-05-30 00:45:02 +02:00
|
|
|
/* Result codes for LockAcquire() */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LOCKACQUIRE_NOT_AVAIL, /* lock not available, and dontWait=true */
|
|
|
|
LOCKACQUIRE_OK, /* lock successfully acquired */
|
|
|
|
LOCKACQUIRE_ALREADY_HELD /* incremented count for lock already held */
|
|
|
|
} LockAcquireResult;
|
|
|
|
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
|
|
|
* function prototypes
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern void InitLocks(void);
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
extern LockMethod GetLocksMethodTable(LOCK *lock);
|
2004-05-28 07:13:32 +02:00
|
|
|
extern LOCKMETHODID LockMethodTableInit(const char *tabName,
|
2004-08-29 07:07:03 +02:00
|
|
|
const LOCKMASK *conflictsP,
|
2005-06-18 00:32:51 +02:00
|
|
|
int numModes);
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
extern LOCKMETHODID LockMethodTableRename(LOCKMETHODID lockmethodid);
|
2005-06-15 00:15:33 +02:00
|
|
|
extern LockAcquireResult LockAcquire(LOCKMETHODID lockmethodid,
|
|
|
|
LOCKTAG *locktag,
|
|
|
|
bool isTempObject,
|
|
|
|
LOCKMODE lockmode,
|
|
|
|
bool sessionLock,
|
|
|
|
bool dontWait);
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
extern bool LockRelease(LOCKMETHODID lockmethodid, LOCKTAG *locktag,
|
2005-06-15 00:15:33 +02:00
|
|
|
LOCKMODE lockmode, bool sessionLock);
|
|
|
|
extern void LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks);
|
2004-08-27 19:07:42 +02:00
|
|
|
extern void LockReleaseCurrentOwner(void);
|
|
|
|
extern void LockReassignCurrentOwner(void);
|
2005-06-18 00:32:51 +02:00
|
|
|
extern void AtPrepare_Locks(void);
|
|
|
|
extern void PostPrepare_Locks(TransactionId xid);
|
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.
. Use type LOCKMASK where an int is not a counter.
. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.
. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because
LOCKMETHOD is not a pointer.
. Define and use macro LockMethodIsValid.
. Rename LOCKMETHOD to LOCKMETHODID.
. Remove global variable LongTermTableId in lmgr.c, because it is
never used.
. Make LockTableId static in lmgr.c, because it is used nowhere else.
Why not remove it and use DEFAULT_LOCKMETHOD?
. Rename the lock method control structure from LOCKMETHODTABLE to
LockMethodData. Introduce a pointer type named LockMethod.
. Remove elog(FATAL) after InitLockTable() call in
CreateSharedMemoryAndSemaphores(), because if something goes wrong,
there is elog(FATAL) in LockMethodTableInit(), and if this doesn't
help, an elog(ERROR) in InitLockTable() is promoted to FATAL.
. Make InitLockTable() void, because its only caller does not use its
return value any more.
. Rename variables in lock.c to avoid statements like
LockMethodTable[NumLockMethods] = lockMethodTable;
lockMethodTable = LockMethodTable[lockmethod];
. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.
. Remove static variables BITS_OFF and BITS_ON from lock.c, because
I agree to this doubt:
* XXX is a fetch from a static array really faster than a shift?
. Define and use macros LOCKBIT_ON/OFF.
Manfred Koizar
2003-12-01 22:59:25 +01:00
|
|
|
extern int LockCheckConflicts(LockMethod lockMethodTable,
|
2001-03-22 05:01:46 +01:00
|
|
|
LOCKMODE lockmode,
|
2005-06-15 00:15:33 +02:00
|
|
|
LOCK *lock, PROCLOCK *proclock, PGPROC *proc);
|
2003-02-18 03:13:24 +01:00
|
|
|
extern void GrantLock(LOCK *lock, PROCLOCK *proclock, LOCKMODE lockmode);
|
2004-08-27 19:07:42 +02:00
|
|
|
extern void GrantAwaitedLock(void);
|
2002-06-11 15:40:53 +02:00
|
|
|
extern void RemoveFromWaitQueue(PGPROC *proc);
|
2005-08-21 01:26:37 +02:00
|
|
|
extern Size LockShmemSize(void);
|
2002-06-11 15:40:53 +02:00
|
|
|
extern bool DeadLockCheck(PGPROC *proc);
|
2003-01-16 22:01:45 +01:00
|
|
|
extern void DeadLockReport(void);
|
|
|
|
extern void RememberSimpleDeadLock(PGPROC *proc1,
|
2003-08-04 02:43:34 +02:00
|
|
|
LOCKMODE lockmode,
|
|
|
|
LOCK *lock,
|
|
|
|
PGPROC *proc2);
|
2001-01-25 04:31:16 +01:00
|
|
|
extern void InitDeadLockChecking(void);
|
2002-08-31 19:14:28 +02:00
|
|
|
extern LockData *GetLockStatusData(void);
|
|
|
|
extern const char *GetLockmodeName(LOCKMODE mode);
|
1998-02-26 05:46:47 +01:00
|
|
|
|
2005-06-18 00:32:51 +02:00
|
|
|
extern void lock_twophase_recover(TransactionId xid, uint16 info,
|
|
|
|
void *recdata, uint32 len);
|
|
|
|
extern void lock_twophase_postcommit(TransactionId xid, uint16 info,
|
|
|
|
void *recdata, uint32 len);
|
|
|
|
extern void lock_twophase_postabort(TransactionId xid, uint16 info,
|
|
|
|
void *recdata, uint32 len);
|
|
|
|
|
2000-05-31 02:28:42 +02:00
|
|
|
#ifdef LOCK_DEBUG
|
2005-06-18 00:32:51 +02:00
|
|
|
extern void DumpLocks(PGPROC *proc);
|
1998-08-25 23:20:32 +02:00
|
|
|
extern void DumpAllLocks(void);
|
1997-02-12 06:25:13 +01:00
|
|
|
#endif
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* LOCK_H */
|