aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2003-06-10 09:07:15 +0000
committerTatsuo Ishii <ishii@postgresql.org>2003-06-10 09:07:15 +0000
commit412893b4168819955e9bf428036cd95b0832d657 (patch)
tree09ea740a1853ed1c51b7955af0e748dd281daf00
parentcdfb3d99811d4b1c99c2e0c29ff8cba5043f0c91 (diff)
downloadpostgresql-412893b4168819955e9bf428036cd95b0832d657.tar.gz
postgresql-412893b4168819955e9bf428036cd95b0832d657.zip
Fix uninitialized memory bug
Add support for PGHOST, PGPORT, PGUSER environment variables
-rw-r--r--contrib/pgbench/README.pgbench4
-rw-r--r--contrib/pgbench/README.pgbench_jis4
-rw-r--r--contrib/pgbench/pgbench.c19
3 files changed, 23 insertions, 4 deletions
diff --git a/contrib/pgbench/README.pgbench b/contrib/pgbench/README.pgbench
index a1c04f23d8b..855e6abc429 100644
--- a/contrib/pgbench/README.pgbench
+++ b/contrib/pgbench/README.pgbench
@@ -164,6 +164,10 @@ Basically it is same as BSD license. See pgbench.c for more details.
o History
+2003/06/10
+ * fix uninitialized memory bug
+ * add support for PGHOST, PGPORT, PGUSER environment variables
+
2002/07/20
* patch contributed by Neil Conway.
* code/document clean up and add -l option.
diff --git a/contrib/pgbench/README.pgbench_jis b/contrib/pgbench/README.pgbench_jis
index cdf3f39fe89..d7e261deca1 100644
--- a/contrib/pgbench/README.pgbench_jis
+++ b/contrib/pgbench/README.pgbench_jis
@@ -184,6 +184,10 @@ pgbench $B$O@P0f(B $BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O(B pgbench.c
$B"#2~DjMzNr(B
+2003/06/10
+ * $B%a%b%j$,=i4|2=$5$l$F$$$J$$%P%0$r=$@5(B
+ * $B4D6-JQ?t(BPGHOST, PGPORT, PGUSER$B$rG'<1$9$k$h$&$K$7$?!%(B
+
2002/07/20
* Nei Conway$B$5$s$N%Q%C%A$rE,MQ!%(B
* -l $B%*%W%7%g%s$NDI2C!%(B
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index b41b8641b3c..fc497c48624 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.23 2003/05/14 03:25:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.24 2003/06/10 09:07:15 ishii Exp $
*
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
* written by Tatsuo Ishii
@@ -694,6 +694,14 @@ main(int argc, char **argv)
PGconn *con;
PGresult *res;
+ char *env;
+
+ if ((env = getenv("PGHOST")) != NULL && *env != '\0')
+ pghost = env;
+ if ((env = getenv("PGPORT")) != NULL && *env != '\0')
+ pgport = env;
+ else if ((env = getenv("PGUSER")) != NULL && *env != '\0')
+ login = env;
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNSl")) != -1)
{
@@ -788,8 +796,11 @@ main(int argc, char **argv)
dbName = argv[optind];
else
{
- dbName = getenv("USER");
- if (dbName == NULL)
+ if ((env = getenv("PGDATABASE")) != NULL && *env != '\0')
+ dbName = env;
+ else if (login != NULL && *login != '\0')
+ dbName = login;
+ else
dbName = "";
}
@@ -802,7 +813,7 @@ main(int argc, char **argv)
remains = nclients;
state = (CState *) malloc(sizeof(*state) * nclients);
- memset(state, 0, sizeof(*state));
+ memset(state, 0, sizeof(*state) * nclients);
if (use_log)
{