aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-connect.c5
-rw-r--r--src/test/regress/pg_regress.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 1c5a2b43e99..cf554d389fa 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1115,6 +1115,11 @@ connectOptions2(PGconn *conn)
{
if (ch->host)
free(ch->host);
+
+ /*
+ * This bit selects the default host location. If you change
+ * this, see also pg_regress.
+ */
#ifdef HAVE_UNIX_SOCKETS
if (DEFAULT_PGSOCKET_DIR[0])
{
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index db8427dd9b5..982801e029d 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -746,10 +746,16 @@ initialize_environment(void)
*/
pghost = getenv("PGHOST");
pgport = getenv("PGPORT");
-#ifndef HAVE_UNIX_SOCKETS
if (!pghost)
- pghost = "localhost";
+ {
+ /* Keep this bit in sync with libpq's default host location: */
+#ifdef HAVE_UNIX_SOCKETS
+ if (DEFAULT_PGSOCKET_DIR[0])
+ /* do nothing, we'll print "Unix socket" below */ ;
+ else
#endif
+ pghost = "localhost"; /* DefaultHost in fe-connect.c */
+ }
if (pghost && pgport)
printf(_("(using postmaster on %s, port %s)\n"), pghost, pgport);