From c793b1b7d2e01f7e7d17e164a749b677a7597587 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 28 Jun 2017 22:21:43 +0900 Subject: [PATCH] repmgr: fix generation of default "dbname" If not explicitly provided, "dbname" was being set early to the default "username" value, which was leading to different behaviour to libpq applications, where "dbname" defaults to "username" at connection time. --- repmgr-client.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/repmgr-client.c b/repmgr-client.c index 9dca006f..0f44836a 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -90,6 +90,10 @@ main(int argc, char **argv) * * Only some actions will need these, but we need to do this before * the command line is parsed. + * + * Note: PQconndefaults() does not provide a default value for + * "dbname", but if none is provided will default to "username" + * when the connection is made. */ initialize_conninfo_params(&source_conninfo, true); @@ -123,15 +127,6 @@ main(int argc, char **argv) } } - /* - * Though libpq will default to the username as dbname, PQconndefaults() - * doesn't return this - */ - if (runtime_options.dbname[0] == '\0') - { - strncpy(runtime_options.dbname, runtime_options.username, MAXLEN); - } - /* set default user for -R/--remote-user */ {