*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.18 1998/01/07 21:05:32 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.19 1998/01/23 06:01:03 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
#include "access/xact.h"
#include "access/transam.h"
-static int
-WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock,
+static int WaitOnLock(LOCKTAB *ltable, LockTableId tableId, LOCK *lock,
LOCKT lockt);
/*#define LOCK_MGR_DEBUG*/
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.25 1998/01/07 21:05:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
*
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.25 1998/01/07 21:05:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.26 1998/01/23 06:01:05 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
*/
UnlockLockTable();
- elog(NOTICE, "Timeout -- possible deadlock");
+ elog(NOTICE, "Timeout interval reached -- possible deadlock.");
+ elog(NOTICE, "See the lock(l) manual page for a possible cause.");
return;
}
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.8 1997/09/08 21:54:32 momjian Exp $
+ * $Id: proc.h,v 1.9 1998/01/23 06:01:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* make static in storage/lmgr/proc.c -- jolly */
extern void ProcQueueInit(PROC_QUEUE *queue);
-extern int
-ProcSleep(PROC_QUEUE *queue, SPINLOCK spinlock, int token,
+extern int ProcSleep(PROC_QUEUE *queue, SPINLOCK spinlock, int token,
int prio, LOCK *lock);
extern int ProcLockWakeup(PROC_QUEUE *queue, char *ltable, char *lock);
extern void ProcAddLock(SHM_QUEUE *elem);
--- /dev/null
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/src/man/Attic/lock.l,v 1.1 1998/01/23 06:01:36 momjian Exp $
+.TH FETCH SQL 01/23/93 PostgreSQL PostgreSQL
+.SH NAME
+lock - exclusive lock a table
+.SH SYNOPSIS
+.nf
+\fBlock\fR classname
+.fi
+.SH DESCRIPTION
+.BR lock
+exclusive locks a table inside a transaction. The classic use for this
+is the case where you want to \fBselect\fP some data, then update it
+inside a transaction. If you don't exclusive lock the table before the
+\fBselect\fP, some other user may also read the selected data, and try
+and do their own \fBupdate\fP, causing a deadlock while you both wait
+for the other to release the \fBselect\fP-induced shared lock so you can
+get an exclusive lock to do the \fBupdate.\fP
+.SH EXAMPLES
+.nf
+--
+-- Proper locking to prevent deadlock
+--
+begin work;
+lock mytable;
+select * from mytable;
+update mytable set (x = 100);
+end work;
+.SH "SEE ALSO"
+begin(l),
+end(l),
+select(l).