Edit report at https://bugs.php.net/bug.php?id=60849&edit=1

 ID:                 60849
 Updated by:         u...@php.net
 Reported by:        haavard dot pedersen at gmail dot com
 Summary:            Too many open links not reported correctly
 Status:             Open
-Type:               Bug
+Type:               Feature/Change Request
 Package:            MySQLi related
 Operating System:   Linux
 PHP Version:        5.3.9
 Block user comment: N
 Private report:     N

 New Comment:

This is a bit on the API design/feature request side.

mysqli.max_connections is a PHP setting. It is something enforced by the API. 
Because it does not come from the server side, the server logic does not set an 
error. There is no error on the line. Thus, the wrapped C API call, 
mysql_connect_errno() does not return one.

Error: 1040 SQLSTATE: 08004 (ER_CON_COUNT_ERROR), Message: Too many connections 
 must not be used to hint that mysqli.max_links has been exceeded. 1040 is a 
server error code.  One needs a client error code, if at all. For example, 
Error: 2000 (CR_UNKNOWN_ERROR) Message: Unknown MySQL error could be used 
together with message pointing to the mysqli configuration.

I say "if at all" because one also has to ask about the semantics of 
mysqli_connect_errno().


Previous Comments:
------------------------------------------------------------------------
[2012-01-23 12:25:15] haavard dot pedersen at gmail dot com

Description:
------------
The "Too many links" error condition does not provide any error code. The only 
way 
you can get a description of the error is via the warning output. Run test 
script 
with mysqli.max_connections = 1 to see the problem. This even breaks the 
documentations example for mysqli_real_connect().

Test script:
---------------
$link1 = mysqli_init();
$m_rc1 = mysqli_real_connect($link1, 'localhost', 'dbuser', 'dbpassword', 
'testdb', 8889);

echo "--- Opening second link ---\n";
$link2 = mysqli_init();
echo "mysqli_init() result : ".var_export($link2, TRUE)."\n";

echo "--- Opening second connection ---\n";
$m_rc2 = mysqli_real_connect($link2, 'localhost', 'dbuser', 'dbpassword', 
'testdb', 8889);
echo "mysqli_real_connect() result : ".var_export($m_rc2, TRUE)."\n";
echo "Error number: ".var_export(mysqli_connect_errno($link2), TRUE)."\n";


Expected result:
----------------
An error number returned on the last line.

Actual result:
--------------
Error number is 0, possibly indicating success.


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



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

Reply via email to