Skip to content

Commit 412893b

Browse files
committed
Fix uninitialized memory bug
Add support for PGHOST, PGPORT, PGUSER environment variables
1 parent cdfb3d9 commit 412893b

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

contrib/pgbench/README.pgbench

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ Basically it is same as BSD license. See pgbench.c for more details.
164164

165165
o History
166166

167+
2003/06/10
168+
* fix uninitialized memory bug
169+
* add support for PGHOST, PGPORT, PGUSER environment variables
170+
167171
2002/07/20
168172
* patch contributed by Neil Conway.
169173
* code/document clean up and add -l option.

contrib/pgbench/README.pgbench_jis

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
184184

185185
$B"#2~DjMzNr(B
186186

187+
2003/06/10
188+
* $B%a%b%j$,=i4|2=$5$l$F$$$J$$%P%0$r=$@5(B
189+
* $B4D6-JQ?t(BPGHOST, PGPORT, PGUSER$B$rG'<1$9$k$h$&$K$7$?!%(B
190+
187191
2002/07/20
188192
* Nei Conway$B$5$s$N%Q%C%A$rE,MQ!%(B
189193
* -l $B%*%W%7%g%s$NDI2C!%(B

contrib/pgbench/pgbench.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.23 2003/05/14 03:25:56 tgl Exp $
2+
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.24 2003/06/10 09:07:15 ishii Exp $
33
*
44
* pgbench: a simple TPC-B like benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -694,6 +694,14 @@ main(int argc, char **argv)
694694

695695
PGconn *con;
696696
PGresult *res;
697+
char *env;
698+
699+
if ((env = getenv("PGHOST")) != NULL && *env != '\0')
700+
pghost = env;
701+
if ((env = getenv("PGPORT")) != NULL && *env != '\0')
702+
pgport = env;
703+
else if ((env = getenv("PGUSER")) != NULL && *env != '\0')
704+
login = env;
697705

698706
while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNSl")) != -1)
699707
{
@@ -788,8 +796,11 @@ main(int argc, char **argv)
788796
dbName = argv[optind];
789797
else
790798
{
791-
dbName = getenv("USER");
792-
if (dbName == NULL)
799+
if ((env = getenv("PGDATABASE")) != NULL && *env != '\0')
800+
dbName = env;
801+
else if (login != NULL && *login != '\0')
802+
dbName = login;
803+
else
793804
dbName = "";
794805
}
795806

@@ -802,7 +813,7 @@ main(int argc, char **argv)
802813
remains = nclients;
803814

804815
state = (CState *) malloc(sizeof(*state) * nclients);
805-
memset(state, 0, sizeof(*state));
816+
memset(state, 0, sizeof(*state) * nclients);
806817

807818
if (use_log)
808819
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy