mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-04 00:02:52 -05:00 
			
		
		
		
	Avoid PQisBusy/PQconsumeInput busy loop in case of PQisBusy returning
false. per Tom Lane's suggestion. See: Subject: Suggested change to pgbench From: Tom Lane <tgl@sss.pgh.pa.us> To: Tatsuo Ishii <t-ishii@sra.co.jp> Cc: pgsql-patches@postgreSQL.org Date: Sun, 06 Oct 2002 12:37:27 -0400 for more details.
This commit is contained in:
		
							parent
							
								
									e4c2967edb
								
							
						
					
					
						commit
						9a2e9c6804
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.19 2002/09/04 20:31:08 momjian Exp $
 | 
					 * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.20 2002/10/07 05:10:02 ishii Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * pgbench: a simple TPC-B like benchmark program for PostgreSQL
 | 
					 * pgbench: a simple TPC-B like benchmark program for PostgreSQL
 | 
				
			||||||
 * written by Tatsuo Ishii
 | 
					 * written by Tatsuo Ishii
 | 
				
			||||||
@ -184,17 +184,16 @@ doOne(CState * state, int n, int debug, int ttype)
 | 
				
			|||||||
	{							/* are we receiver? */
 | 
						{							/* are we receiver? */
 | 
				
			||||||
		if (debug)
 | 
							if (debug)
 | 
				
			||||||
			fprintf(stderr, "client %d receiving\n", n);
 | 
								fprintf(stderr, "client %d receiving\n", n);
 | 
				
			||||||
		while (PQisBusy(st->con) == TRUE)
 | 
							if (!PQconsumeInput(st->con))
 | 
				
			||||||
		{
 | 
							{						/* there's something wrong */
 | 
				
			||||||
			if (!PQconsumeInput(st->con))
 | 
								fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
 | 
				
			||||||
			{					/* there's something wrong */
 | 
								remains--;			/* I've aborted */
 | 
				
			||||||
				fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
 | 
								PQfinish(st->con);
 | 
				
			||||||
				remains--;		/* I've aborted */
 | 
								st->con = NULL;
 | 
				
			||||||
				PQfinish(st->con);
 | 
								return;
 | 
				
			||||||
				st->con = NULL;
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (PQisBusy(st->con))
 | 
				
			||||||
 | 
								return;				/* don't have the whole result yet */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (st->state)
 | 
							switch (st->state)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@ -367,17 +366,16 @@ doSelectOnly(CState * state, int n, int debug)
 | 
				
			|||||||
	{							/* are we receiver? */
 | 
						{							/* are we receiver? */
 | 
				
			||||||
		if (debug)
 | 
							if (debug)
 | 
				
			||||||
			fprintf(stderr, "client %d receiving\n", n);
 | 
								fprintf(stderr, "client %d receiving\n", n);
 | 
				
			||||||
		while (PQisBusy(st->con) == TRUE)
 | 
							if (!PQconsumeInput(st->con))
 | 
				
			||||||
		{
 | 
							{						/* there's something wrong */
 | 
				
			||||||
			if (!PQconsumeInput(st->con))
 | 
								fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
 | 
				
			||||||
			{					/* there's something wrong */
 | 
								remains--;			/* I've aborted */
 | 
				
			||||||
				fprintf(stderr, "Client %d aborted in state %d. Probably the backend died while processing.\n", n, st->state);
 | 
								PQfinish(st->con);
 | 
				
			||||||
				remains--;		/* I've aborted */
 | 
								st->con = NULL;
 | 
				
			||||||
				PQfinish(st->con);
 | 
								return;
 | 
				
			||||||
				st->con = NULL;
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (PQisBusy(st->con))
 | 
				
			||||||
 | 
								return;				/* don't have the whole result yet */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (st->state)
 | 
							switch (st->state)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user