Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #35868 : wrong handling of mysql connections hashing
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 5th May 04:32
php-bugs
External User
 
Posts: 1
Default #35868 : wrong handling of mysql connections hashing


From: giovanni at giacobbi dot net
Operating system: platform independent
PHP version: 4.4.1
PHP Bug Type: MySQL related
Bug description: wrong handling of mysql connections hashing

Description:
------------
The code for reproducing is self-explanatory. Anyway, the problem appears
when handling multiple connections to the same database with the same
login and passwords.

I'm testing a script that handles connections to multiple MySQL databases,
and for testing purposes I need to operate with two separated local
database. However, the connection is only distinguished by the database
name, while you use only host, user, and password for hashing the single
connection.

This results in a collision when opening the second connection, and makes
it impossible to recover the previous one using mysql_connect()'s existing
link functionality, even if the connection itself is still open.


Reproduce code:
---------------
<?php
/* create primary connection */
$r1 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname1", $r1) or die(mysql_error());
var_dump($r1);
/* create auxiliary connection */
$r2 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname2", $r2) or die(mysql_error());
var_dump($r2);
/* get rid of auxiliary connection when done */
mysql_close($r2);

/* fetch back the previous connection as default! */
$r3 = mysql_connect("localhost", "root", "******");
var_dump($r3);

exit();


Expected result:
----------------
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(4) of type (mysql link)


Actual result:
--------------
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(6) of type (mysql link)


--
Edit bug report at http://bugs.php.net/?id=35868&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35868&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35868&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35868&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35868&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35868&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35868&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35868&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35868&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35868&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35868&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35868&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35868&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35868&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35868&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35868&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35868&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35868&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35868&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35868&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35868&r=mysqlcfg
  Reply With Quote


  sponsored links


2 5th May 04:32
External User
 
Posts: 1
Default #35868 : wrong handling of mysql connections hashing


ID: 35868
Updated by: sniper@php.net
Reported By: giovanni at giacobbi dot net
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: *
PHP Version: 4.4.1
New Comment:

Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


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

[2006-01-01 22:34:38] giovanni at giacobbi dot net

Description:
------------
The code for reproducing is self-explanatory. Anyway, the problem
appears when handling multiple connections to the same database with
the same login and passwords.

I'm testing a script that handles connections to multiple MySQL
databases, and for testing purposes I need to operate with two
separated local database. However, the connection is only distinguished
by the database name, while you use only host, user, and password for
hashing the single connection.

This results in a collision when opening the second connection, and
makes it impossible to recover the previous one using mysql_connect()'s
existing link functionality, even if the connection itself is still
open.


Reproduce code:
---------------
<?php
/* create primary connection */
$r1 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname1", $r1) or die(mysql_error());
var_dump($r1);
/* create auxiliary connection */
$r2 = mysql_connect("localhost", "root", "*****", TRUE);
mysql_select_db("dbname2", $r2) or die(mysql_error());
var_dump($r2);
/* get rid of auxiliary connection when done */
mysql_close($r2);

/* fetch back the previous connection as default! */
$r3 = mysql_connect("localhost", "root", "******");
var_dump($r3);

exit();


Expected result:
----------------
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(4) of type (mysql link)


Actual result:
--------------
resource(4) of type (mysql link)
resource(5) of type (mysql link)
resource(6) of type (mysql link)

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


--
Edit this bug report at http://bugs.php.net/?id=35868&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666