Index: src/backend/storage/lmgr/proc.c
===================================================================
RCS file: /home/stark/src/REPOSITORY/pgsql/src/backend/storage/lmgr/proc.c,v
retrieving revision 1.191
diff -c -r1.191 proc.c
*** src/backend/storage/lmgr/proc.c	16 Jul 2007 21:09:50 -0000	1.191
--- src/backend/storage/lmgr/proc.c	27 Aug 2007 12:45:05 -0000
***************
*** 882,936 ****
  		 * If awoken after the deadlock check interrupt has run, and
  		 * log_lock_waits is on, then report about the wait.
  		 */
! 		if (log_lock_waits)
  		{
! 			switch (deadlock_state)
! 			{
! 				case DS_NOT_YET_CHECKED:
! 					/* Lock granted, or spurious wakeup as described above */
! 					break; 
! 				case DS_NO_DEADLOCK:
! 				case DS_SOFT_DEADLOCK:
! 				{
! 					StringInfoData buf;
! 					const char *modename;
! 					long		secs;
! 					int			usecs;
! 					long		msecs;
! 
! 					initStringInfo(&buf);
! 					DescribeLockTag(&buf, &locallock->tag.lock);
! 					modename = GetLockmodeName(locallock->tag.lock.locktag_lockmethodid,
! 											   lockmode);
! 					TimestampDifference(timeout_start_time,
! 										GetCurrentTimestamp(),
! 										&secs, &usecs);
! 					msecs = secs * 1000 + usecs / 1000;
! 					usecs = usecs % 1000;
! 
! 					if (deadlock_state == DS_SOFT_DEADLOCK)
! 						ereport(LOG,
! 								(errmsg("deadlock for %s on %s avoided by rearranging queue order after %ld.%03d ms",
! 										modename, buf.data,
! 										msecs, usecs)));
! 					else if (MyProc->waitStatus == STATUS_WAITING)
! 						ereport(LOG,
! 								(errmsg("process %d still waiting for %s on %s after %ld.%03d ms",
! 										MyProcPid, modename, buf.data,
! 										msecs, usecs)));
! 					else if (MyProc->waitStatus == STATUS_OK)
! 						ereport(LOG,
! 								(errmsg("process %d acquired %s on %s after %ld.%03d ms",
! 										MyProcPid, modename, buf.data,
! 										msecs, usecs)));
! 					/* ERROR will be reported later, so no message here */
! 					pfree(buf.data);
! 					break;
! 				}
! 				case DS_HARD_DEADLOCK:
! 					/* ERROR will be reported later, so no message here */
! 					break; 
! 			}
  		}
  	} while (MyProc->waitStatus == STATUS_WAITING);
  
--- 882,930 ----
  		 * If awoken after the deadlock check interrupt has run, and
  		 * log_lock_waits is on, then report about the wait.
  		 */
! 		if (log_lock_waits && deadlock_state != DS_NOT_YET_CHECKED)
  		{
! 			StringInfoData buf;
! 			const char *modename;
! 			long		secs;
! 			int			usecs;
! 			long		msecs;
! 			
! 			initStringInfo(&buf);
! 			DescribeLockTag(&buf, &locallock->tag.lock);
! 			modename = GetLockmodeName(locallock->tag.lock.locktag_lockmethodid,
! 									   lockmode);
! 			TimestampDifference(timeout_start_time,
! 								GetCurrentTimestamp(),
! 								&secs, &usecs);
! 			msecs = secs * 1000 + usecs / 1000;
! 			usecs = usecs % 1000;
! 
! 			if (deadlock_state == DS_SOFT_DEADLOCK)
! 				ereport(LOG,
! 						(errmsg("process %d avoided deadlock waiting for %s on %s by rearranging queue order after %ld.%03d ms",
! 								MyProcPid, modename, buf.data,
! 								msecs, usecs)));
! 			else if (deadlock_state == DS_HARD_DEADLOCK)
! 				/* this is a bit redundant with the error which will be
! 				 * reported subsequently however it adds the time elapsed and
! 				 * it will print even if the error is caught by an exception
! 				 * handler. */
! 				ereport(LOG,
! 						(errmsg("process %d detected deadlock waiting for %s on %s after %ld.%03d ms",
! 								MyProcPid, modename, buf.data,
! 								msecs, usecs)));
! 			else if (MyProc->waitStatus == STATUS_WAITING)
! 				ereport(LOG,
! 						(errmsg("process %d still waiting for %s on %s after %ld.%03d ms",
! 								MyProcPid, modename, buf.data,
! 								msecs, usecs)));
! 			else if (MyProc->waitStatus == STATUS_OK)
! 				ereport(LOG,
! 						(errmsg("process %d acquired %s on %s after %ld.%03d ms",
! 								MyProcPid, modename, buf.data,
! 								msecs, usecs)));
! 			pfree(buf.data);
  		}
  	} while (MyProc->waitStatus == STATUS_WAITING);
  
