Re: [PATCH] pgbench: Bug fix for the -d option
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: miyake_kouta <miyake_kouta@oss.nttdata.com>,
Michael Paquier <michael@paquier.xyz>
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2021-03-05T04:30:11Z
Lists: pgsql-hackers
On 2021/03/05 11:26, miyake_kouta wrote:
> 2021-03-04 21:11, Michael Paquier wrote:
>> Like any other src/bin/ facilities, let's instead
>> remove all the getenv() calls at the beginning of pgbench.c and let's
>> libpq handle those environment variables if the parameters are NULL
>> (aka in the case of no values given directly in the options). This
>> requires to move the debug log after doConnect(), which is no big deal
>> anyway as a failure results in an exit(1) immediately with a log
>> telling where the connection failed.
if ((env = getenv("PGDATABASE")) != NULL && *env != '\0')
dbName = env;
- else if (login != NULL && *login != '\0')
- dbName = login;
+ else if ((env = getenv("PGUSER")) != NULL && *env != '\0')
+ dbName = env;
else
- dbName = "";
+ dbName = get_user_name_or_exit(progname);
If dbName is set by libpq, the above also is not necessary?
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Commits
-
pgbench: Simplify some port, host, user and dbname assignments
- f1516ad7b3a9 14.0 landed