(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 0
Message: Re: [HACKERS] MVCC works in serialized mode!
Index: src/backend/parser/scan.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v
retrieving revision 1.31
diff -c -r1.31 scan.c
*** scan.c	1998/10/13 17:26:50	1.31
--- scan.c	1998/12/18 19:30:54
***************
*** 1,7 ****
  /* A lexical scanner generated by flex */
  
  /* Scanner skeleton version:
!  * $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v 1.31 1998/10/13 17:26:50 scrappy Exp $
   */
  
  #define FLEX_SCANNER
--- 1,7 ----
  /* A lexical scanner generated by flex */
  
  /* Scanner skeleton version:
!  * /master/usr.bin/lex/skel.c,v 1.3 1997/09/25 00:10:23 jch Exp
   */
  
  #define FLEX_SCANNER
***************
*** 556,562 ****
   *
   *
   * IDENTIFICATION
!  *	  $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.c,v 1.31 1998/10/13 17:26:50 scrappy Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 556,562 ----
   *
   *
   * IDENTIFICATION
!  *	  $Header: /usr/local/cvsroot/pgsql/src/backend/parser/scan.l,v 1.44 1998/10/08 18:29:51 momjian Exp $
   *
   *-------------------------------------------------------------------------
   */
Index: src/backend/storage/lmgr/proc.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v
retrieving revision 1.43
diff -c -r1.43 proc.c
*** proc.c	1998/09/01 04:32:02	1.43
--- proc.c	1998/12/18 19:30:59
***************
*** 77,83 ****
  #include "storage/proc.h"
  #include "utils/trace.h"
  
! static void HandleDeadLock(int sig);
  static PROC *ProcWakeup(PROC *proc, int errType);
  
  #define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
--- 77,83 ----
  #include "storage/proc.h"
  #include "utils/trace.h"
  
! static void HandleDeadLock(void);
  static PROC *ProcWakeup(PROC *proc, int errType);
  
  #define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
***************
*** 154,161 ****
  	 * Routine called if deadlock timer goes off. See ProcSleep()
  	 * ------------------
  	 */
- 	pqsignal(SIGALRM, HandleDeadLock);
- 
  	SpinAcquire(ProcStructLock);
  
  	/* attach to the free list */
--- 154,159 ----
***************
*** 449,457 ****
  		  TransactionId xid)	/* needed by user locks, see below */
  {
  	int			i;
  	PROC	   *proc;
! 	struct itimerval timeval,
! 				dummy;
  
  	/*
  	 * If the first entries in the waitQueue have a greater priority than
--- 447,455 ----
  		  TransactionId xid)	/* needed by user locks, see below */
  {
  	int			i;
+ 	bool		deadlock_checked = false;
  	PROC	   *proc;
! 	struct timeval timeval;
  
  	/*
  	 * If the first entries in the waitQueue have a greater priority than
***************
*** 523,539 ****
  	 * to 0.
  	 * --------------
  	 */
! 	MemSet(&timeval, 0, sizeof(struct itimerval));
! 	timeval.it_value.tv_sec = \
  		(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
  
  	do
  	{
  		MyProc->errType = NO_ERROR;		/* reset flag after deadlock check */
  
! 		if (setitimer(ITIMER_REAL, &timeval, &dummy))
  			elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  
  		/* --------------
  		 * if someone wakes us between SpinRelease and IpcSemaphoreLock,
  		 * IpcSemaphoreLock will not block.  The wakeup is "saved" by
--- 521,546 ----
  	 * to 0.
  	 * --------------
  	 */
! 	MemSet(&timeval, 0, sizeof(struct timeval));
! 	timeval.tv_sec = \
  		(DeadlockCheckTimer ? DeadlockCheckTimer : DEADLOCK_CHECK_TIMER);
  
  	do
  	{
+ 		int expire;
+ 		
  		MyProc->errType = NO_ERROR;		/* reset flag after deadlock check */
  
! 		if ((expire = select(0, NULL, NULL, NULL,
! 			(deadlock_checked == false) ? &timeval : NULL)) == -1)
  			elog(FATAL, "ProcSleep: Unable to set timer for process wakeup");
  
+ 		if (expire == 0 /* timeout reached */ && deadlock_checked == false)
+ 		{
+ 			HandleDeadLock();
+ 			deadlock_checked = true;
+ 		}
+ 		
  		/* --------------
  		 * if someone wakes us between SpinRelease and IpcSemaphoreLock,
  		 * IpcSemaphoreLock will not block.  The wakeup is "saved" by
***************
*** 545,558 ****
  	} while (MyProc->errType == STATUS_NOT_FOUND);		/* sleep after deadlock
  														 * check */
  
- 	/* ---------------
- 	 * We were awoken before a timeout - now disable the timer
- 	 * ---------------
- 	 */
- 	timeval.it_value.tv_sec = 0;
- 	if (setitimer(ITIMER_REAL, &timeval, &dummy))
- 		elog(FATAL, "ProcSleep: Unable to diable timer for process wakeup");
- 
  	/* ----------------
  	 * We were assumed to be in a critical section when we went
  	 * to sleep.
--- 552,557 ----
***************
*** 695,701 ****
   * --------------------
   */
  static void
! HandleDeadLock(int sig)
  {
  	LOCK	   *mywaitlock;
  
--- 694,700 ----
   * --------------------
   */
  static void
! HandleDeadLock()
  {
  	LOCK	   *mywaitlock;
  
Index: src/pl/plpgsql/src/gram.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.c,v
retrieving revision 1.1
diff -c -r1.1 gram.c
*** gram.c	1998/10/28 17:07:17	1.1
--- gram.c	1998/12/18 19:31:12
***************
*** 65,71 ****
   *			  procedural language
   *
   * IDENTIFICATION
!  *    $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.c,v 1.1 1998/10/28 17:07:17 momjian Exp $
   *
   *    This software is copyrighted by Jan Wieck - Hamburg.
   *
--- 65,71 ----
   *			  procedural language
   *
   * IDENTIFICATION
!  *    $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.1 1998/08/24 19:14:47 momjian Exp $
   *
   *    This software is copyrighted by Jan Wieck - Hamburg.
   *
Index: src/pl/plpgsql/src/scan.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.c,v
retrieving revision 1.1
diff -c -r1.1 scan.c
*** scan.c	1998/10/28 17:07:17	1.1
--- scan.c	1998/12/18 19:31:21
***************
*** 635,641 ****
   *			  procedural language
   *
   * IDENTIFICATION
!  *    $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.c,v 1.1 1998/10/28 17:07:17 momjian Exp $
   *
   *    This software is copyrighted by Jan Wieck - Hamburg.
   *
--- 635,641 ----
   *			  procedural language
   *
   * IDENTIFICATION
!  *    $Header: /usr/local/cvsroot/pgsql/src/pl/plpgsql/src/scan.l,v 1.1 1998/08/24 19:14:49 momjian Exp $
   *
   *    This software is copyrighted by Jan Wieck - Hamburg.
   *