]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #43493 (pdo_pgsql does not send username on connect when
authorIlia Alshanetsky <iliaa@php.net>
Tue, 4 Dec 2007 13:05:03 +0000 (13:05 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 4 Dec 2007 13:05:03 +0000 (13:05 +0000)
password is not available)

NEWS
ext/pdo_pgsql/pgsql_driver.c

diff --git a/NEWS b/NEWS
index af67cbd75dd73fab95f61535da07b238f9053957..15b37ad6741665ecef75f7c2803a69b4fda0d631 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2008, PHP 5.2.6
 - Fixed weired behavior in CGI parameter parsing. (Dmitry, Hannes Magnusson)
 
+- Fixed bug #43493 (pdo_pgsql does not send username on connect when password
+  is not available). (Ilia)
 - Fixed bug #43482 (array_pad() does not warn on very small pad numbers).
   (Ilia)
 - Fixed bug #43457 (Prepared statement with incorrect parms doesn't throw 
index c134a2eb1dd03419f3ff214d6b1ce982692d870c..922daccc752df72229b89767c23182c1a419c491 100644 (file)
@@ -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);