Thread: default psql to localhost on platforms without unix domain sockets

default psql to localhost on platforms without unix domain sockets

From
Andrew Dunstan
Date:

Bruce Momjian wrote:

>Andrew Dunstan wrote:
>
>>Also, what is the default connection mode of psql? It should probably be
>>equivalent to "-h localhost", shouldn't it?
>>
>>
>
>Now that is something I had not thought of.  Seems we can assume a Win32
>psql can never use unix domain sockets, so defaulting that to localhost
>is a good solution too.
>

The trivial patch below does this (I think). I still don't have an
available Windows box for testing, so someone who does please verify.

thanks

andrew

Index: src/bin/psql/startup.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/startup.c,v
retrieving revision 1.85
diff -c -r1.85 startup.c
*** src/bin/psql/startup.c 19 Feb 2004 19:40:09 -0000 1.85
--- src/bin/psql/startup.c 15 Mar 2004 10:37:50 -0000
***************
*** 153,158 ****
--- 153,162 ----
pset.getPassword = false;
#endif

+ #ifndef HAVE_UNIX_SOCKETS
+ options.host = "localhost";
+ #endif
+
parse_psql_options(argc, argv, &options);

if (!pset.popt.topt.fieldSep)





Re: default psql to localhost on platforms without unix domain

From
Bruce Momjian
Date:
Patch applied, with comment added.  Thanks.

---------------------------------------------------------------------------


Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >>Also, what is the default connection mode of psql? It should probably be
> >>equivalent to "-h localhost", shouldn't it?
> >>
> >>
> >
> >Now that is something I had not thought of.  Seems we can assume a Win32
> >psql can never use unix domain sockets, so defaulting that to localhost
> >is a good solution too.
> >
>
> The trivial patch below does this (I think). I still don't have an
> available Windows box for testing, so someone who does please verify.
>
> thanks
>
> andrew
>
> Index: src/bin/psql/startup.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/startup.c,v
> retrieving revision 1.85
> diff -c -r1.85 startup.c
> *** src/bin/psql/startup.c 19 Feb 2004 19:40:09 -0000 1.85
> --- src/bin/psql/startup.c 15 Mar 2004 10:37:50 -0000
> ***************
> *** 153,158 ****
> --- 153,162 ----
> pset.getPassword = false;
> #endif
>
> + #ifndef HAVE_UNIX_SOCKETS
> + options.host = "localhost";
> + #endif
> +
> parse_psql_options(argc, argv, &options);
>
> if (!pset.popt.topt.fieldSep)
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: default psql to localhost on platforms without unix domain

From
Bruce Momjian
Date:
Should we have used 127.0.0.1 rather than 'localhost' here?

---------------------------------------------------------------------------

Andrew Dunstan wrote:
>
>
> Bruce Momjian wrote:
>
> >Andrew Dunstan wrote:
> >
> >>Also, what is the default connection mode of psql? It should probably be
> >>equivalent to "-h localhost", shouldn't it?
> >>
> >>
> >
> >Now that is something I had not thought of.  Seems we can assume a Win32
> >psql can never use unix domain sockets, so defaulting that to localhost
> >is a good solution too.
> >
>
> The trivial patch below does this (I think). I still don't have an
> available Windows box for testing, so someone who does please verify.
>
> thanks
>
> andrew
>
> Index: src/bin/psql/startup.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/startup.c,v
> retrieving revision 1.85
> diff -c -r1.85 startup.c
> *** src/bin/psql/startup.c 19 Feb 2004 19:40:09 -0000 1.85
> --- src/bin/psql/startup.c 15 Mar 2004 10:37:50 -0000
> ***************
> *** 153,158 ****
> --- 153,162 ----
> pset.getPassword = false;
> #endif
>
> + #ifndef HAVE_UNIX_SOCKETS
> + options.host = "localhost";
> + #endif
> +
> parse_psql_options(argc, argv, &options);
>
> if (!pset.popt.topt.fieldSep)
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: default psql to localhost on platforms without unix domain

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Should we have used 127.0.0.1 rather than 'localhost' here?

No.  Think IPv6.

            regards, tom lane

Re: default psql to localhost on platforms without unix domain

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Should we have used 127.0.0.1 rather than 'localhost' here?
>
> No.  Think IPv6.

OK, just asking in case.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073