DefaultHost

Поиск
Список
Период
Сортировка
Искать

DefaultHost

От:
Edmund Mergl <E.Mergl@bawue.de>
Дата:
Hi all,

in the current snapshot there is no default for PGHOST 
in src/interfaces/libpq/fe-connect.c. 
In 6.2 this was 'localhost', which is a reasonable default.

If there is no real reason for not having a default for
the host-option, please provide 'localhost' as default.


thanks
Edmund
-- 
Edmund Mergl       mailto:E.Mergl@bawue.de
Im Haldenhau 9     http://www.bawue.de/~mergl
D 70565 Stuttgart  fon: +49 711 747503
Germany            gsm: +49 171 2645325

Re: [HACKERS] DefaultHost

От:
Peter T Mount <psqlhack@maidast.demon.co.uk>
Дата:
On Sat, 10 Jan 1998, Edmund Mergl wrote:

> Hi all,
> 
> in the current snapshot there is no default for PGHOST 
> in src/interfaces/libpq/fe-connect.c. 
> In 6.2 this was 'localhost', which is a reasonable default.
> 
> If there is no real reason for not having a default for
> the host-option, please provide 'localhost' as default.

I think this was changed to allow UNIX Sockets to be the default if no
hostname is provided.

-- 
Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk

Re: [HACKERS] DefaultHost

От:
Goran Thyni <goran@bildbasen.se>
Дата:

   in the current snapshot there is no default for PGHOST 
   in src/interfaces/libpq/fe-connect.c. 
   In 6.2 this was 'localhost', which is a reasonable default.

   If there is no real reason for not having a default for
   the host-option, please provide 'localhost' as default.

No host means connect with unix domain socket.
If host (PGHOST) is set connection is made with tcp socket.

This is related to the problem I mentioned before with
DBD::Pg and libpq.

	regards,
-- 
---------------------------------------------
Göran Thyni, sysadm, JMS Bildbasen, Kiruna

Re: [HACKERS] DefaultHost

От:
Edmund Mergl <E.Mergl@bawue.de>
Дата:
Goran Thyni wrote:
> 
>    in the current snapshot there is no default for PGHOST
>    in src/interfaces/libpq/fe-connect.c.
>    In 6.2 this was 'localhost', which is a reasonable default.
> 
>    If there is no real reason for not having a default for
>    the host-option, please provide 'localhost' as default.
> 
> No host means connect with unix domain socket.
> If host (PGHOST) is set connection is made with tcp socket.
> 
> This is related to the problem I mentioned before with
> DBD::Pg and libpq.
> 
>         regards,
> --
> ---------------------------------------------
> Göran Thyni, sysadm, JMS Bildbasen, Kiruna


ok, but there is still no reasonable default. The only way
I got things working is starting the postmaster with -i
and setting the environment-variable PGHOST to 'localhost'.

It should be possible to connect to the backend on the 
localhost without having to define the host in the environment 
or as argument in PQconnectdb(). 

Edmund
-- 
Edmund Mergl       mailto:E.Mergl@bawue.de
Im Haldenhau 9     http://www.bawue.de/~mergl
D 70565 Stuttgart  fon: +49 711 747503
Germany            gsm: +49 171 2645325

Re: [HACKERS] DefaultHost

От:
Goran Thyni <goran@bildbasen.se>
Дата:

   > No host means connect with unix domain socket.
   > If host (PGHOST) is set connection is made with tcp socket.
   > 
   > This is related to the problem I mentioned before with
   > DBD::Pg and libpq.

   ok, but there is still no reasonable default. The only way
   I got things working is starting the postmaster with -i
   and setting the environment-variable PGHOST to 'localhost'.

   It should be possible to connect to the backend on the 
   localhost without having to define the host in the environment 
   or as argument in PQconnectdb(). 

The problem is in PQconnectdb() in libpq.
I will supply a patch as soon as I have time to make a clean one
against current sources.

  regards,

-- 
---------------------------------------------
Göran Thyni, sysadm, JMS Bildbasen, Kiruna

Re: [HACKERS] DefaultHost

От:
Goran Thyni <goran@bildbasen.se>
Дата:

OK, here comes a patch, DBD::Pg (and possibly other 3rd party clients)
can connect to unix sockets.
Patch is against current source tree.

Background:
libpq set some policy for client, which it should not
IMHO. It prevent some 3rd party clients to connect with
unix domain sockets etc.

     regards,
-- 
---------------------------------------------
Göran Thyni, sysadm, JMS Bildbasen, Kiruna

------------------------- snip ---------------------------------

diff -cr pg-sup/pgsql/src/interfaces/libpq/fe-connect.c pgsql-hack/src/interfaces/libpq/fe-connect.c
*** pg-sup/pgsql/src/interfaces/libpq/fe-connect.c	Fri Dec  5 17:33:44 1997
--- pgsql-hack/src/interfaces/libpq/fe-connect.c	Sat Jan 10 16:09:37 1998
***************
*** 150,156 ****
  	PGconn	   *conn;
  	PQconninfoOption *option;
  	char		errorMessage[ERROR_MSG_LENGTH];
! 
  	/* ----------
  	 * Allocate memory for the conn structure
  	 * ----------
--- 150,156 ----
  	PGconn	   *conn;
  	PQconninfoOption *option;
  	char		errorMessage[ERROR_MSG_LENGTH];
! 	char* tmp;
  	/* ----------
  	 * Allocate memory for the conn structure
  	 * ----------
***************
*** 177,213 ****
  	}
  
  	/* ----------
- 	 * Check that we have all connection parameters
- 	 * ----------
- 	 */
- 	for (option = PQconninfoOptions; option->keyword != NULL; option++)
- 	{
- 		if (option->val != NULL)
- 			continue;			/* Value was in conninfo */
- 
- 		/* ----------
- 		 * No value was found for this option. Return an error.
- 		 * ----------
- 		 */
- 		conn->status = CONNECTION_BAD;
- 		sprintf(conn->errorMessage,
- 				"ERROR: PQconnectdb(): Cannot determine a value for option '%s'.\n",
- 				option->keyword);
- 		strcat(conn->errorMessage,
- 			   "Option not specified in conninfo string");
- 		if (option->environ)
- 		{
- 			strcat(conn->errorMessage,
- 				   ", environment variable ");
- 			strcat(conn->errorMessage, option->environ);
- 			strcat(conn->errorMessage, "\nnot set");
- 		}
- 		strcat(conn->errorMessage, " and no compiled in default value.\n");
- 		conninfo_free();
- 		return conn;
- 	}
- 
- 	/* ----------
  	 * Setup the conn structure
  	 * ----------
  	 */
--- 177,182 ----
***************
*** 218,231 ****
  	conn->port = NULL;
  	conn->notifyList = DLNewList();
  
! 	conn->pghost = strdup(conninfo_getval("host"));
! 	conn->pgport = strdup(conninfo_getval("port"));
! 	conn->pgtty = strdup(conninfo_getval("tty"));
! 	conn->pgoptions = strdup(conninfo_getval("options"));
! 	conn->pguser = strdup(conninfo_getval("user"));
! 	conn->pgpass = strdup(conninfo_getval("password"));
! 	conn->pgauth = strdup(conninfo_getval("authtype"));
! 	conn->dbName = strdup(conninfo_getval("dbname"));
  
  	/* ----------
  	 * Free the connection info - all is in conn now
--- 187,208 ----
  	conn->port = NULL;
  	conn->notifyList = DLNewList();
  
! 	tmp = conninfo_getval("host");
! 	conn->pghost = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("port");
! 	conn->pgport = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("tty");
! 	conn->pgtty  = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("options");
! 	conn->pgoptions = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("user");
! 	conn->pguser = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("password");
! 	conn->pgpass = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("authtype");
! 	conn->pgauth = tmp ? strdup(tmp) : NULL;
! 	tmp = conninfo_getval("dbname");
! 	conn->dbName = tmp ? strdup(tmp) : NULL;
  
  	/* ----------
  	 * Free the connection info - all is in conn now

Re: [HACKERS] DefaultHost

От:
The Hermit Hacker <scrappy@hub.org>
Дата:
On Sat, 10 Jan 1998, Edmund Mergl wrote:

> Hi all,
> 
> in the current snapshot there is no default for PGHOST 
> in src/interfaces/libpq/fe-connect.c. 
> In 6.2 this was 'localhost', which is a reasonable default.

	Default operation now is 'Unix Domain Sockets'...PGHOST isn't a viable
default.  The only time that PGHOST is a viable default is if -i is issued to
postmaster when started up...


Marc G. Fournier                                
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 

Re: [HACKERS] DefaultHost

От:
Edmund Mergl <E.Mergl@bawue.de>
Дата:
The Hermit Hacker wrote:
> 
> On Sat, 10 Jan 1998, Edmund Mergl wrote:
> 
> > Hi all,
> >
> > in the current snapshot there is no default for PGHOST
> > in src/interfaces/libpq/fe-connect.c.
> > In 6.2 this was 'localhost', which is a reasonable default.
> 
>         Default operation now is 'Unix Domain Sockets'...PGHOST isn't a viable
> default.  The only time that PGHOST is a viable default is if -i is issued to
> postmaster when started up...
> 
> Marc G. Fournier
> Systems Administrator @ hub.org
> primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org



sorry, but I still didn't get that. What do I have to do in order
to be able to connect to the backend running on the localhost
without setting PGHOST and without specifying the host in 
PQconnectdb() ?

Edmund
-- 
Edmund Mergl       mailto:E.Mergl@bawue.de
Im Haldenhau 9     http://www.bawue.de/~mergl
D 70565 Stuttgart  fon: +49 711 747503
Germany            gsm: +49 171 2645325
FAQ