ID:               43493
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jurka at ejurka dot com
-Status:           Open
+Status:           Closed
 Bug Type:         PDO related
 Operating System: Debian Unstable
 PHP Version:      5.2.5
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.





Previous Comments:
------------------------------------------------------------------------

[2007-12-04 10:06:52] jurka at ejurka dot com

Description:
------------
When creating a PDO object using the pgsql driver, the supplied
username is dropped if the password is null.



Reproduce code:
---------------
$pdo = new PDO('pgsql:host=localhost;port=5777;dbname=mydb',
'myuser');


This will not use the "myuser" username supplied.  Looking at the code
in ext/pdo_pgsql/pgsql_driver.c circa line 695 it says:

        /* 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) {
                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 {
                spprintf(&conn_str, 0, "%s password=%s
connect_timeout=%ld", dbh->data_source, dbh->password,
connect_timeout);
        }

It's trying to cover all the cases of username and password set or not,
but the first condition is wrong.  It should be 

        if (!dbh->username && !dbh->password) {




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43493&edit=1

Reply via email to