php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60849 Too many open links not reported correctly
Submitted: 2012-01-23 12:25 UTC Modified: 2012-05-02 13:59 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: haavard dot pedersen at gmail dot com Assigned:
Status: Open Package: MySQLi related
PHP Version: 5.3.9 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: haavard dot pedersen at gmail dot com
New email:
PHP Version: OS:

 

 [2012-01-23 12:25 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-02 13:59 UTC] uw@php.net
-Type: Bug +Type: Feature/Change Request
 [2012-05-02 13:59 UTC] uw@php.net
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().
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jun 01 06:01:26 2020 UTC