make pgxc_ctl connect to 'postgres' database when pinging a node
authorTomas Vondra <[email protected]>
Thu, 12 Jan 2017 09:47:38 +0000 (10:47 +0100)
committerTomas Vondra <[email protected]>
Thu, 12 Jan 2017 09:47:38 +0000 (10:47 +0100)
pingNode() was not specifying database in the connection string,
so the OS username was used implicitly. When such database did
not exist (e.g. when initializing new nodes, under OS account
different from 'postgres'), this resulted in FATAL failures
in the server log:

    FATAL:  database "user" does not exist

Adding 'database=postgres' to the connection string fixes the
issue. It might be useful to allow using custom database names,
but 'postgres' is pretty much guaranteed to exist.

Bug report by me, patch by Pavan Deolasee.

contrib/pgxc_ctl/utils.c

index 96c487f20cf60b5b7734fab1d3bc2ad3dcc73121..501e7f83ea91b90e427b207030753c50e3829249 100644 (file)
@@ -312,6 +312,9 @@ int pingNode(char *host, char *port)
                snprintf(editBuf, MAXPATH, "port = %d ", atoi(port));
                strncat(conninfo, editBuf, MAXLINE);
        }
+
+       strncat(conninfo, "dbname = postgres ", MAXLINE);
+
        if (conninfo[0])
        {
                status = PQping(conninfo);