Bug #11993 Updated: mysql_close closes incorrect db handler
| From: | atiware at metasuccess dot net | Date: | Thu, 13 Dec 2001 16:13:44 +0000 |
| Subject: | Bug #11993 Updated: mysql_close closes incorrect db handler | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-73577@lists.php.net to get a copy of this message | ||
ID: 11993
User updated by: atiware@metasuccess.net
Reported By: atiware@metasuccess.net
Old Status: Closed
Status: Open
Bug Type: MySQL related
Operating System: Debian 2.19
Old PHP Version: 4.0.6
PHP Version: 4.1.0
New Comment:
sorry, i can not try with php4.1.0RC3. I tried out with the latest php4.1.0, and no changes, the
problem still exists.
ati
Previous Comments:
------------------------------------------------------------------------
[2001-12-13 06:26:24] sander@php.net
No feedback. Closing.
------------------------------------------------------------------------
[2001-11-20 19:55:37] mfischer@php.net
Can you try if the problem still persists with latest RC
http://www.php.net/~zeev/php-4.1.0RC3.tar.gz
Feedback.
------------------------------------------------------------------------
[2001-10-24 00:59:24] sniper@php.net
missing status
------------------------------------------------------------------------
[2001-07-11 13:58:35] atiware@metasuccess.net
hi zak,
thanks for your answer.
in my opinion, php must have some matrix, where you stores the number of connect and close calls
with the connection id. this will probably solve the problem.
ps: i use these multiple connections in oop environment, where a global connection id, is not the
best idea. or?
ati
------------------------------------------------------------------------
[2001-07-11 06:58:00] zak@php.net
Here is a refinement on this bug:
Multiple duplicate calls to mysql_connect are supposed to return the same link ID. Each call after
the first call will only return the link ID of the first (if everything goes as planned, the
connection is still good, etc...).
i.e.
var_dump (mysql_connect() === mysql_connect());
Given this behavior, how should mysql_close() behave?
I would expect that calling mysql_close ($id) would close the connection that both $id and $id2
refer to.
Behavior is not this - instead it is quite odd...
Multiple calls to mysql_close are required to close multiple duplicate calls to mysql_connect.
i.e.
var_dump ($db = mysql_connect ());
var_dump ($db = mysql_connect ());
var_dump (mysql_close ($db));
// Maybe this closes the default connection?
var_dump (mysql_close ($db));
However, if more than two calls to mysql_connect are made, followed by a corresponding number of
calls to mysql_close, the mysql_close calls start to fail.
i.e.
$max = 10;
for ($x=0; $x<$max; ++$x) {
var_dump ($db = mysql_connect());
}
for ($x=0; $x<$max; ++$x) {
var_dump (mysql_close ($db));
}
Now, throw change the call to mysql_close($db) to mysql_close() - everything seems to work as
expected.
However as soon as you add a call to mysql_query after the call to mysql_close, the link will
*never* die - no matter how many times you close it.
Finally, put a call to mysql_close ($db) between the two loops. The next call to mysql_close() will
fail with an error, while subsequent calls will succeed - once again, the link will never die.
Things get even stranger when this behavior is encountered within recursive function calls -
however, I guess that this is a side effect of the behavior described above.
It looks like there is some complex/odd interactions happening with the code that closes mysql links
and the code that sets and uses the default link -- however, this is quite far over my head!
Anyone else have any ideas? :)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=11993
Edit this bug report at http://bugs.php.net/?id=11993&edit=1