diff options
| author | Bruce Momjian | 2002-08-17 13:04:19 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2002-08-17 13:04:19 +0000 |
| commit | 82119a696e247e6d3f583c6bb89435099e062e71 (patch) | |
| tree | de7bbf69ea65a1bd99769c77889f3ff7d6e25bf4 /src/backend | |
| parent | f0ed4311b6f44dac079ae720b370413e948f30d5 (diff) | |
[ Newest version of patch applied.]
This patch is an updated version of the lock listing patch. I've made
the following changes:
- write documentation
- wrap the SRF in a view called 'pg_locks': all user-level
access should be done through this view
- re-diff against latest CVS
One thing I chose not to do is adapt the SRF to use the anonymous
composite type code from Joe Conway. I'll probably do that eventually,
but I'm not really convinced it's a significantly cleaner way to
bootstrap SRF builtins than the method this patch uses (of course, it
has other uses...)
Neil Conway
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/storage/lmgr/lock.c | 62 | ||||
| -rw-r--r-- | src/backend/tcop/utility.c | 5 | ||||
| -rw-r--r-- | src/backend/utils/adt/Makefile | 4 |
3 files changed, 65 insertions, 6 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index d6858da7e33..154c49b3e92 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.111 2002/08/01 05:18:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.112 2002/08/17 13:04:14 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -1359,6 +1359,66 @@ LockShmemSize(int maxBackends) return size; } +/* + * GetLockStatusData - Return a summary of the lock manager's internal + * status, for use in a user-level statistical reporting function. + * + * This function should be passed a pointer to a LockData struct. It fills + * the structure with the appropriate information and returns. The goal + * is to hold the LockMgrLock for as short a time as possible; thus, the + * function simply makes a copy of the necessary data and releases the + * lock, allowing the caller to contemplate and format the data for + * as long as it pleases. + */ +void +GetLockStatusData(LockData *data) +{ + HTAB *holderTable; + PROCLOCK *holder; + HASH_SEQ_STATUS seqstat; + int i = 0; + + data->currIdx = 0; + + LWLockAcquire(LockMgrLock, LW_EXCLUSIVE); + + holderTable = LockMethodTable[DEFAULT_LOCKMETHOD]->holderHash; + + data->nelements = holderTable->hctl->nentries; + + data->procs = (PGPROC *) palloc(sizeof(PGPROC) * data->nelements); + data->locks = (LOCK *) palloc(sizeof(LOCK) * data->nelements); + data->holders = (PROCLOCK *) palloc(sizeof(PROCLOCK) * data->nelements); + + hash_seq_init(&seqstat, holderTable); + + while ( (holder = hash_seq_search(&seqstat)) ) + { + PGPROC *proc; + LOCK *lock; + + /* Only do a shallow copy */ + proc = (PGPROC *) MAKE_PTR(holder->tag.proc); + lock = (LOCK *) MAKE_PTR(holder->tag.lock); + + memcpy(&(data->procs[i]), proc, sizeof(PGPROC)); + memcpy(&(data->locks[i]), lock, sizeof(LOCK)); + memcpy(&(data->holders[i]), holder, sizeof(PROCLOCK)); + + i++; + } + + Assert(i == data->nelements); + + LWLockRelease(LockMgrLock); +} + +char * +GetLockmodeName(LOCKMODE mode) +{ + Assert(mode <= MAX_LOCKMODES); + return lock_mode_names[mode]; +} #ifdef LOCK_DEBUG /* diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index ded117dbac8..1ae0a89fd6b 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.171 2002/08/17 12:15:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.172 2002/08/17 13:04:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -239,8 +239,7 @@ ProcessUtility(Node *parsetree, break; /* - * ******************************** portal manipulation ******************************** - * + * ************************* portal manipulation *************************** */ case T_ClosePortalStmt: { diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile index f219c5bde08..3cbd1a8fa58 100644 --- a/src/backend/utils/adt/Makefile +++ b/src/backend/utils/adt/Makefile @@ -1,7 +1,7 @@ # # Makefile for utils/adt # -# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.51 2001/10/04 04:13:40 ishii Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.52 2002/08/17 13:04:15 momjian Exp $ # subdir = src/backend/utils/adt @@ -17,7 +17,7 @@ endif OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o \ date.o datetime.o datum.o float.o format_type.o \ - geo_ops.o geo_selfuncs.o int.o int8.o like.o \ + geo_ops.o geo_selfuncs.o int.o int8.o like.o lockfuncs.o \ misc.o nabstime.o name.o not_in.o numeric.o numutils.o \ oid.o oracle_compat.o \ regexp.o regproc.o ruleutils.o selfuncs.o sets.o \ |
