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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: miyake_kouta <miyake_kouta(at)oss(dot)nttdata(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] pgbench: Bug fix for the -d option
Date: 2021-03-05 07:33:12
Message-ID: YEHeuHv1mz+z7Lr+@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 05, 2021 at 01:30:11PM +0900, Fujii Masao wrote:
> 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?

If you remove this part, pgbench loses some log information if
PQconnectdbParams() returns NULL, like on OOM if the database name is
NULL. Perhaps that's not worth caring about here for a single log
failure, but that's the reason is why I left this part around.

Now, simplifying the code is one goal of this patch, so I would not
mind shaving a bit more of it :)
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-03-05 07:38:17 Re: Which PG version does CVE-2021-20229 affected?
Previous Message bchen90 2021-03-05 07:32:43 Which PG version does CVE-2021-20229 affected?