>
> You really should be returning a value at the point since the function
> signature defines a return type. If not the function should be void,
> which it cannot be in this context since it is used for boolean tests
> elsewhere. The returns in question are all part of error blocks and
> should return false.
>

OK I got your point, I missed the part managing with CState, which is tested
after doCustom.
Another version of the patch is attached with this email.

 I must be doing something wrong when I am running this script. It is
> still throwing errors. Would you mind showing me the pgbench command you
> used to run it?
>
> Of course, here it is the list of commands I use:
pgbench -i dbname (in case your database is called dbname)
pgbench -c 10 -t 10 -f transaction_file_name.data dbname (customer and
transaction numbers can also bet set as you want).

Regards,

-- 
Michael Paquier

NTT OSSC
--- postgresql-8.4.0.orig/contrib/pgbench/pgbench.c	2009-09-17 09:07:24.000000000 +0900
+++ postgresql-8.4.0/contrib/pgbench/pgbench.c	2009-09-18 13:24:33.000000000 +0900
@@ -120,6 +120,7 @@ typedef struct
 } Variable;
 
 #define MAX_FILES		128		/* max number of SQL script files allowed */
+#define SHELL_COMMAND_SIZE	256		/* maximum size allowed for shell command */
 
 /*
  * structures used in custom query mode
@@ -984,7 +985,47 @@ top:
 
 			st->listen = 1;
 		}
+		else if (pg_strcasecmp(argv[0], "shell") == 0)
+		{
+			int	j,
+				retval,
+				retvalglob;
+			char	commandLoc[SHELL_COMMAND_SIZE];
+
+			retval = snprintf(commandLoc,SHELL_COMMAND_SIZE-1,"%s",argv[1]);
+			if (retval < 0
+				|| retval > SHELL_COMMAND_SIZE-1)
+			{
+				fprintf(stderr, "Error launching shell command: too many characters\n");
+				st->ecnt++;
+				return;
+			}
+			retvalglob = retval;
 
+			for (j = 2; j < argc; j++)
+			{
+				char *commandLoc2 = strdup(commandLoc);
+				retval = snprintf(commandLoc,SHELL_COMMAND_SIZE-1,"%s %s", commandLoc2, argv[j]);
+				retvalglob += retval;
+				if (retval < 0
+					|| retvalglob > SHELL_COMMAND_SIZE-1)
+				{
+					fprintf(stderr, "Error launching shell command: too many characters\n");
+					free(commandLoc2);
+					st->ecnt++;
+					return;
+				}
+				free(commandLoc2);
+			}
+			retval = system(commandLoc);
+			if (retval < 0)
+			{
+				fprintf(stderr, "Error launching shell command: command not launched");
+				st->ecnt++;
+				return;
+			}
+			st->listen = 1;
+		}
 		goto top;
 	}
 }
@@ -1280,6 +1321,14 @@ process_commands(char *buf)
 				fprintf(stderr, "%s: extra argument \"%s\" ignored\n",
 						my_commands->argv[0], my_commands->argv[j]);
 		}
+		else if (pg_strcasecmp(my_commands->argv[0], "shell") == 0)
+		{
+			if (my_commands->argc < 1)
+			{
+				fprintf(stderr, "%s: missing command\n", my_commands->argv[0]);
+				return NULL;
+			}
+		}
 		else
 		{
 			fprintf(stderr, "Invalid command %s\n", my_commands->argv[0]);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to