Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix pg_regress to print the correct postmaster address on Windows.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Mar 2022 18:23:58 +0000 (13:23 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Mar 2022 18:23:58 +0000 (13:23 -0500)
pg_regress reported "Unix socket" as the default location whenever
HAVE_UNIX_SOCKETS is defined.  However, that's not been accurate
on Windows since 8f3ec75de.  Update this logic to match what libpq
actually does now.

This is just cosmetic, but still it's potentially misleading.
Back-patch to v13 where 8f3ec75de came in.

Discussion: https://postgr.es/m/3894060.1646415641@sss.pgh.pa.us

src/interfaces/libpq/fe-connect.c
src/test/regress/pg_regress.c

index 88f54e89b388520d49f3a601bbef54f402fed81b..b80ac2e724c341d21ccb410a1b25bbdad0171676 100644 (file)
@@ -1100,6 +1100,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])
            {
index 242c8b066e327f1717f90084a310c1f99b7f4c27..931872ba45acfc91dae1d5f8861920837367772b 100644 (file)
@@ -895,10 +895,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);