Index: src/interfaces/libpq/fe-connect.c =================================================================== RCS file: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v retrieving revision 1.339 diff -c -r1.339 fe-connect.c *** src/interfaces/libpq/fe-connect.c 21 Nov 2006 16:28:00 -0000 1.339 --- src/interfaces/libpq/fe-connect.c 12 Dec 2006 22:49:28 -0000 *************** *** 567,572 **** --- 567,573 ---- const char *pwd) { PGconn *conn; + bool have_conninfo = false; /* * Allocate memory for the conn structure *************** *** 575,585 **** if (conn == NULL) return NULL; /* * Parse an empty conninfo string in order to set up the same defaults ! * that PQconnectdb() would use. */ ! if (!connectOptions1(conn, "")) return conn; /* --- 576,609 ---- if (conn == NULL) return NULL; + /* + * Have we got something that might be a conninfo string? + * If so, try that first. + */ + if (dbName && strchr(dbName,'=')) + { + if(connectOptions1(conn,dbName)) + { + /* it was a conninfo string */ + have_conninfo = true; + } + else + { + /* put things back the way they were so we can try again */ + freePGconn(conn); + conn = makeEmptyPGconn(); + if (conn == NULL) + return NULL; + + } + } + /* * Parse an empty conninfo string in order to set up the same defaults ! * that PQconnectdb() would use. Skip this if we already found a ! * conninfo string. */ ! if (!have_conninfo && !connectOptions1(conn, "")) return conn; /* *************** *** 613,619 **** conn->pgtty = strdup(pgtty); } ! if (dbName && dbName[0] != '\0') { if (conn->dbName) free(conn->dbName); --- 637,643 ---- conn->pgtty = strdup(pgtty); } ! if (!have_conninfo && dbName && dbName[0] != '\0') { if (conn->dbName) free(conn->dbName);