php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71023 mysqlnd statistic wrap
Submitted: 2015-12-04 05:41 UTC Modified: -
Votes:5
Avg. Score:3.8 ± 1.0
Reproduced:4 of 5 (80.0%)
Same Version:1 (25.0%)
Same OS:0 (0.0%)
From: damian dot poole at netregistry dot com dot au Assigned:
Status: Open Package: MySQL related
PHP Version: 7.0.0 OS: Debian x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 42 = ?
Subscribe to this entry?

 
 [2015-12-04 05:41 UTC] damian dot poole at netregistry dot com dot au
Description:
------------
Some of the connection statistics for the MySQL native driver (namely active_connections/ active persistent connections) can decrement past zero causing the statistic to wrap around to the max value of the type.

The attached patch fixes it for us as it stops the macros which increment/decrement from wrapping around.

Test script:
---------------
<?php
$mysqli = mysqli_init();
$mysqli->real_connect('1.2.3.4'); //non existant server
$stats = mysqli_get_client_stats();
var_dump($stats['active_connections']);

Expected result:
----------------
Warning: mysqli::real_connect(): (HY000/2002): Connection refused in /websites/ph/php70.damo.id.au/mysql.php on line 3
string(2) "0"

--- next run ---
Warning: mysqli::real_connect(): (HY000/2002): Connection refused in /websites/ph/php70.damo.id.au/mysql.php on line 3
string(2) "0"

Actual result:
--------------
Warning: mysqli::real_connect(): (HY000/2002): Connection refused in /websites/ph/php70.damo.id.au/mysql.php on line 3
string(20) "18446744073709551615"

--- next run ---
Warning: mysqli::real_connect(): (HY000/2002): Connection refused in /websites/ph/php70.damo.id.au/mysql.php on line 3
string(20) "18446744073709551614"

Patches

dpoole-nowrap-for-mysqlnd-uint64-decrement-or-increment (last revision 2015-12-04 05:46 UTC by damian dot poole at netregistry dot com dot au)
dpoole-nowrap-for-mysqlnd-uint64 (last revision 2015-12-04 05:41 UTC by damian dot poole at netregistry dot com dot au)

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 21 14:01:27 2019 UTC