Skip to content
Snippets Groups Projects
Commit 602b0d0c authored by Marc G. Fournier's avatar Marc G. Fournier
Browse files

From: 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.
parent 80159ee2
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.53 1997/12/05 01:13:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.54 1998/01/13 04:24:10 scrappy Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -150,7 +150,7 @@ PQconnectdb(const char *conninfo) ...@@ -150,7 +150,7 @@ PQconnectdb(const char *conninfo)
PGconn *conn; PGconn *conn;
PQconninfoOption *option; PQconninfoOption *option;
char errorMessage[ERROR_MSG_LENGTH]; char errorMessage[ERROR_MSG_LENGTH];
char* tmp;
/* ---------- /* ----------
* Allocate memory for the conn structure * Allocate memory for the conn structure
* ---------- * ----------
...@@ -176,37 +176,6 @@ PQconnectdb(const char *conninfo) ...@@ -176,37 +176,6 @@ PQconnectdb(const char *conninfo)
return conn; return conn;
} }
/* ----------
* 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 * Setup the conn structure
* ---------- * ----------
...@@ -218,14 +187,22 @@ PQconnectdb(const char *conninfo) ...@@ -218,14 +187,22 @@ PQconnectdb(const char *conninfo)
conn->port = NULL; conn->port = NULL;
conn->notifyList = DLNewList(); conn->notifyList = DLNewList();
conn->pghost = strdup(conninfo_getval("host")); tmp = conninfo_getval("host");
conn->pgport = strdup(conninfo_getval("port")); conn->pghost = tmp ? strdup(tmp) : NULL;
conn->pgtty = strdup(conninfo_getval("tty")); tmp = conninfo_getval("port");
conn->pgoptions = strdup(conninfo_getval("options")); conn->pgport = tmp ? strdup(tmp) : NULL;
conn->pguser = strdup(conninfo_getval("user")); tmp = conninfo_getval("tty");
conn->pgpass = strdup(conninfo_getval("password")); conn->pgtty = tmp ? strdup(tmp) : NULL;
conn->pgauth = strdup(conninfo_getval("authtype")); tmp = conninfo_getval("options");
conn->dbName = strdup(conninfo_getval("dbname")); 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 * Free the connection info - all is in conn now
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment