From 56c610c97a0f86144dd805f6480be36bee4568cc Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 4 Dec 2007 13:03:26 +0000 Subject: [PATCH] Fixed bug #43493 (pdo_pgsql does not send username on connect when password is not available) --- ext/pdo_pgsql/pgsql_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index 688399c126..eeb2d9f5da 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -692,14 +692,14 @@ static int pdo_pgsql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ } /* support both full connection string & connection string + login and/or password */ - if (!dbh->username || !dbh->password) { - spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout); - } else if (dbh->username && dbh->password) { + if (dbh->username && dbh->password) { spprintf(&conn_str, 0, "%s user=%s password=%s connect_timeout=%ld", dbh->data_source, dbh->username, dbh->password, connect_timeout); } else if (dbh->username) { spprintf(&conn_str, 0, "%s user=%s connect_timeout=%ld", dbh->data_source, dbh->username, connect_timeout); - } else { + } else if (dbh->password) { spprintf(&conn_str, 0, "%s password=%s connect_timeout=%ld", dbh->data_source, dbh->password, connect_timeout); + } else { + spprintf(&conn_str, 0, "%s connect_timeout=%ld", (char *) dbh->data_source, connect_timeout); } H->server = PQconnectdb(conn_str); -- 2.50.1