*** dbdimp.c.orig	Mon Nov  1 08:08:17 2004
--- dbdimp.c	Sun Oct 31 14:02:48 2004
***************
*** 249,275 ****
  	int status;
  
  	if (dbis->debug >= 1) { PerlIO_printf(DBILOGFP, "dbd_db_pg_notifies\n"); }
! 	
! 	status = PQconsumeInput(imp_dbh->conn);
! 	if (status == 0) { 
! 		pg_error(dbh, PQstatus(imp_dbh->conn), PQerrorMessage(imp_dbh->conn));
! 		return 0;
! 	}
! 	
  	notify = PQnotifies(imp_dbh->conn);
! 	
! 	if (!notify) return &sv_undef; 
! 	
  	ret=newAV();
  	
  	av_push(ret, newSVpv(notify->relname,0) );
  	av_push(ret, newSViv(notify->be_pid) );
  	
! 	/* Should free notify memory with PQfreemem() */
  	
  	retsv = newRV(sv_2mortal((SV*)ret));
  	
! 	return retsv;
  }
  
  int
--- 249,282 ----
  	int status;
  
  	if (dbis->debug >= 1) { PerlIO_printf(DBILOGFP, "dbd_db_pg_notifies\n"); }
! 
! 	/*
! 	 *  First get any pending notifications that have already been retrieved
! 	 *  from the server.
! 	 */
  	notify = PQnotifies(imp_dbh->conn);
! 	if (!notify)
! 	{
! 		/*
! 		 *  If we not not have any more events queued on the client side, 
! 		 *  see if there are more to read from the server.
! 		 */
! 		PQconsumeInput(imp_dbh->conn);
! 		notify = PQnotifies(imp_dbh->conn);
! 		if (!notify) return &sv_undef; 
! 	}
! 
  	ret=newAV();
  	
  	av_push(ret, newSVpv(notify->relname,0) );
  	av_push(ret, newSViv(notify->be_pid) );
  	
! 	/* free notify memory with PQfreemem() */
! 	PQfreemem(notify);
  	
  	retsv = newRV(sv_2mortal((SV*)ret));
  	
! 	return sv_2mortal(retsv);
  }
  
  int
