1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-21 00:42:43 +03:00

Remove -k unix socketpath option from client side, allow hostname with

leading slash to behave as a unix socket path.
This commit is contained in:
Bruce Momjian
2000-11-13 23:37:54 +00:00
parent d63a762f79
commit ebd61ac03f
32 changed files with 82 additions and 304 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.145 2000/11/13 15:18:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.146 2000/11/13 23:37:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -331,6 +331,25 @@ PQconnectStart(const char *conninfo)
*/
PQconninfoFree(connOptions);
/* ----------
* Allow unix socket specification in the host name
* ----------
*/
if (conn->pghost && conn->pghost[0] == '/')
{
if (conn->pgunixsocket)
free(conn->pgunixsocket);
conn->pgunixsocket = conn->pghost;
conn->pghost = NULL;
}
if (conn->pghostaddr && conn->pghostaddr[0] == '/')
{
if (conn->pgunixsocket)
free(conn->pgunixsocket);
conn->pgunixsocket = conn->pghostaddr;
conn->pghostaddr = NULL;
}
/* ----------
* Connect to the database
* ----------
@@ -443,13 +462,25 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
else
conn->pgport = strdup(pgport);
#if FIX_ME
/* we need to modify the function to accept a unix socket path */
if (pgunixsocket)
conn->pgunixsocket = strdup(pgunixsocket);
else if ((tmp = getenv("PGUNIXSOCKET")) != NULL)
conn->pgunixsocket = strdup(tmp);
#endif
/* ----------
* We don't allow unix socket path as a function parameter.
* This allows unix socket specification in the host name.
* ----------
*/
if (conn->pghost && conn->pghost[0] == '/')
{
if (conn->pgunixsocket)
free(conn->pgunixsocket);
conn->pgunixsocket = conn->pghost;
conn->pghost = NULL;
}
if (conn->pghostaddr && conn->pghostaddr[0] == '/')
{
if (conn->pgunixsocket)
free(conn->pgunixsocket);
conn->pgunixsocket = conn->pghostaddr;
conn->pghostaddr = NULL;
}
if (pgtty == NULL)
{
@@ -778,7 +809,7 @@ connectDBStart(PGconn *conn)
{
printfPQExpBuffer(&conn->errorMessage,
"connectDBStart() -- "
"invalid host address: %s\n", conn->pghostaddr);
"invalid host address: %s\n", conn->pghostaddr);
goto connect_errReturn;
}

View File

@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.28 2000/11/13 15:18:15 momjian Exp $
* $Id: libpq-int.h,v 1.29 2000/11/13 23:37:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -203,8 +203,8 @@ struct pg_conn
* numbers-and-dots notation. Takes
* precedence over above. */
char *pgport; /* the server's communication port */
char *pgunixsocket; /* the Unix-domain socket that the server is listening on;
* if NULL, uses a default constructed from pgport */
char *pgunixsocket; /* the Unix-domain socket that the server is listening on;
* if NULL, uses a default constructed from pgport */
char *pgtty; /* tty on which the backend messages is
* displayed (NOT ACTUALLY USED???) */
char *pgoptions; /* options to start the backend with */