1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

[ 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
This commit is contained in:
Bruce Momjian
2002-08-17 13:04:19 +00:00
parent f0ed4311b6
commit 82119a696e
11 changed files with 248 additions and 20 deletions

View File

@@ -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
/*

View File

@@ -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:
{

View File

@@ -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 \