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.
This commit is contained in:
Ian Barwick
2017-06-28 22:16:10 +09:00
parent b7d1e7a091
commit 18a56b266b
2 changed files with 6 additions and 12 deletions

View File

@@ -1610,7 +1610,7 @@ which contains connection details for the local database.
Creates a witness server as a separate PostgreSQL instance. This instance
can be on a separate server or a server running an existing node. The
witness server contain a copy of the repmgr metadata tables but will not
witness server contains a copy of the repmgr metadata tables but will not
be set up as a standby; instead it will update its metadata copy each
time a failover occurs.

View File

@@ -283,7 +283,11 @@ main(int argc, char **argv)
/*
* Pre-set any defaults , which can be overwritten if matching
* command line parameters are provided
* command line parameters are provided.
*
* Note: PQconndefaults() does not provide a default value for
* "dbname", but if none is provided will default to "username"
* when the connection is made.
*/
for (c = 0; c < source_conninfo.size && source_conninfo.keywords[c]; c++)
@@ -316,7 +320,6 @@ main(int argc, char **argv)
}
/* set default user for -R/--remote-user */
{
struct passwd *pw = NULL;
@@ -330,15 +333,6 @@ main(int argc, char **argv)
strncpy(runtime_options.username, pw->pw_name, MAXLEN);
}
/*
* 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);
}
while ((c = getopt_long(argc, argv, "?Vd:h:p:U:S:D:f:R:w:k:FWIvb:rcL:tm:C:l:P", long_options,
&optindex)) != -1)
{