[PATCH] pgbench: Bug fix for the -d option

miyake_kouta <miyake_kouta@oss.nttdata.com>

From: miyake_kouta <miyake_kouta@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Date: 2021-02-26T04:18:20Z
Lists: pgsql-hackers

Attachments

Hi.

I found a bug in pgbench's -d option and created a patch.

The bug is the following:
pgbench's option -d can display debug log about connection, which is 
like "pghost: foo pgport: 5432 nclients: 1 nxacts: 10 dbName: bar".
This configuration is supplied by other options or environment variables 
like PGUSER or PGPORT.
When there is no PGDATABASE, pgbench will use PGUSER as the dbName.
However, when there is PGPORT environment variable, this debug logger 
doesn't refer PGUSER even if there is PGUSER.
In other words, even if you are setting both PGPORT and PGUSER, 
pgbench's option -d will display like this: "pghost: foo pgport: 5432 
nclients: 1 nxact: 10 dbName: ".
I think this is a bug that dbName is displayed as if it's not specified.
Note that this bug is only related to this debug logger. The main unit 
of pgbench can establish a connection by complementing dbName with 
PGUSER despite this bug.

So I made a patch (only one line changed).
As shown in this patch file, I just changed the else if statement to an 
if statement.
I'm suggesting this bug fix because I think it's a bug, but if there's 
any other intent to this else if statement, could you let me know?

Regards
---
Kota Miyake

Commits

  1. pgbench: Simplify some port, host, user and dbname assignments