]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix uninitialized memory bug
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 10 Jun 2003 09:07:15 +0000 (09:07 +0000)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 10 Jun 2003 09:07:15 +0000 (09:07 +0000)
Add support for PGHOST, PGPORT, PGUSER environment variables

contrib/pgbench/README.pgbench
contrib/pgbench/README.pgbench_jis
contrib/pgbench/pgbench.c

index a1c04f23d8b0c09484ecd12f50040101b2d5ebca..855e6abc429dfaeaa896693c537cdb5d79cd96ac 100644 (file)
@@ -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.
index cdf3f39fe898c52b1925450b8e3eeacaa028e3ee..d7e261deca1b9b52840888b7cee36fc57c3e44e1 100644 (file)
@@ -184,6 +184,10 @@ pgbench \e$B$O@P0f\e(B \e$BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O\e(B pgbench.c
 
 \e$B"#2~DjMzNr\e(B
 
+2003/06/10
+       * \e$B%a%b%j$,=i4|2=$5$l$F$$$J$$%P%0$r=$@5\e(B
+       * \e$B4D6-JQ?t\e(BPGHOST, PGPORT, PGUSER\e$B$rG'<1$9$k$h$&$K$7$?!%\e(B
+
 2002/07/20
        * Nei Conway\e$B$5$s$N%Q%C%A$rE,MQ!%\e(B
        * -l \e$B%*%W%7%g%s$NDI2C!%\e(B
index b41b8641b3cd80d2fa134b40303f7d57bb6d29e1..fc497c48624d5745cb550757902e1a36915daa38 100644 (file)
@@ -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)
        {