patch-pgbench-global

text/plain

Filename: patch-pgbench-global
Type: text/plain
Part: 1
Message: Re: Avoiding SIGPIPE (was Re: OSDL DBT-2 w/ PostgreSQL
? contrib/pgbench/pgbench
Index: contrib/pgbench/README.pgbench
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/pgbench/README.pgbench,v
retrieving revision 1.9
diff -c -r1.9 README.pgbench
*** contrib/pgbench/README.pgbench	10 Jun 2003 09:07:15 -0000	1.9
--- contrib/pgbench/README.pgbench	3 Nov 2003 19:53:13 -0000
***************
*** 112,117 ****
--- 112,121 ----
  		might be a security hole since ps command will
  		show the password. Use this for TESTING PURPOSE ONLY.
  
+ 	-a
+ 		Disable SIGPIPE delivery globally instead of within each
+ 		libpq operation.
+ 
  	-n
  		No vacuuming and cleaning the history table prior to the
  		test is performed.
Index: contrib/pgbench/pgbench.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/contrib/pgbench/pgbench.c,v
retrieving revision 1.27
diff -c -r1.27 pgbench.c
*** contrib/pgbench/pgbench.c	27 Sep 2003 19:15:34 -0000	1.27
--- contrib/pgbench/pgbench.c	3 Nov 2003 19:53:15 -0000
***************
*** 28,33 ****
--- 28,34 ----
  #else
  #include <sys/time.h>
  #include <unistd.h>
+ #include <signal.h>
  
  #ifdef HAVE_GETOPT_H
  #include <getopt.h>
***************
*** 105,112 ****
  static void
  usage()
  {
! 	fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-C][-v][-S][-N][-l][-U login][-P password][-d][dbname]\n");
! 	fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n");
  }
  
  /* random number generator */
--- 106,113 ----
  static void
  usage()
  {
! 	fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-n][-C][-v][-S][-N][-l][-a][-U login][-P password][-d][dbname]\n");
! 	fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname][-a]\n");
  }
  
  /* random number generator */
***************
*** 703,712 ****
  	else if ((env = getenv("PGUSER")) != NULL && *env != '\0')
  		login = env;
  
! 	while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNSl")) != -1)
  	{
  		switch (c)
  		{
  			case 'i':
  				is_init_mode++;
  				break;
--- 704,719 ----
  	else if ((env = getenv("PGUSER")) != NULL && *env != '\0')
  		login = env;
  
! 	while ((c = getopt(argc, argv, "aih:nvp:dc:t:s:U:P:CNSl")) != -1)
  	{
  		switch (c)
  		{
+ 			case 'a':
+ #ifndef WIN32
+ 				signal(SIGPIPE, SIG_IGN);
+ #endif
+ 				PQsetsighandling(0);
+ 				break;
  			case 'i':
  				is_init_mode++;
  				break;