Bug #72856 [NEW]: incompatible use of odbc and mysql, if connecting with odbc to localhost

From: Date: Tue, 16 Aug 2016 15:36:34 +0000
Subject: Bug #72856 [NEW]: incompatible use of odbc and mysql, if connecting with odbc to localhost
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203316@lists.php.net to get a copy of this message
From: bugphp at wirelessmundi dot com Operating system: debian 8 PHP version: 5.6.24 Package: CGI/CLI related Bug Type: Bug Bug description:incompatible use of odbc and mysql, if connecting with odbc to localhost Description: ------------ at some random calls i can't connect to mysql and no error is report back. this issue is present with nginx + php-fpm + mysql with multiple sites running on the same server. After digging, i found that this error is cause by a odbc call from one of the sites. when the odbc call is done one some php-fpm child and other site tries to connect using mysqli_connect on this same php-fpm child it simple fails and no error is thrown. the return link is false. if its relevant, the odbc connection is configure over unixodbc directly to /var/run/mysqld/mysqld.sock. i could reproduce the error using simple php script with cli, attached the script to reproduce it. I've try to connect to 127.0.0.1 instead of the socket, but i got the same results. Test script: --------------- <?php // when connecting to odbc will make fail all the mysql connections using_odbc(); sleep(5); using_mysqli_obj(); using_mysqli(); function using_mysqli() { echo "*** MySQLi \n"; $link = mysqli_connect("localhost", "root", "m1sq7passwd", "tel_app", "3306", "/var/run/mysqld/mysqld.sock"); if (!$link) { echo "Error connecting to MYSQL [".mysqli_connect_errno()."] ".mysqli_connect_error()."\n"; } else { $result = @mysqli_query($link, "select count(*) as total from client_limit;"); if (!is_object($result)) { echo "no results found, error: ".mysqli_error($link)."\n"; } else { $tmp = mysqli_fetch_array($result, MYSQLI_ASSOC); mysqli_free_result($result); print_r($tmp); } if (!mysqli_close($link)) { echo "Fail to disconnect db link \n"; } unset($link); } echo "***\n"; } function using_mysqli_obj() { echo "*** MySQLi OBJ\n"; $mysqli = new mysqli('localhost', 'root', 'm1sq7passwd', 'tel_app'); if ($mysqli->connect_error) { echo ('Connect Error (' . $mysqli->connect_errno . ') '.$mysqli->connect_error); } else { $result = $mysqli->query("select count(*) as total from client_limit;", MYSQLI_USE_RESULT); if (!is_object($result)) { echo "no results found, error: ".$mysqli->error."\n"; } else { $tmp = $result->fetch_object(); print_r($tmp); $result->close(); } $mysqli->close(); } echo "*** \n "; } function using_odbc() { echo "*** ODBC \n"; $conn = odbc_connect("localhost_tel_cdr", false, false); if (!$conn) { echo "fail to connect using odbc ".odbc_errormsg(); } else { $res = odbc_exec($conn, "select count(*) as total_cdr from cdr where (start_stamp >= '1470751734' ) and (start_stamp <= '1471356534' );"); if (!$res) { echo "Fail to execute sql ".odbc_errormsg(); } else { $row = odbc_fetch_array($res); print_r($row); odbc_free_result($res); } odbc_close($conn); } echo "***"; } ?> Expected result: ---------------- *** ODBC Array ( [total_cdr] => 98 ) *** MySQLi OBJ stdClass Object ( [total] => 216 ) *** *** MySQLi Array ( [total] => 216 ) *** Actual result: -------------- *** ODBC Array ( [total_cdr] => 98 ) ****** MySQLi OBJ Warning: mysqli::query(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 47 Warning: using_mysqli_obj(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 49 no results found, error: Warning: mysqli::close(): Couldn't fetch mysqli in /root/mysql_phpbug.php on line 56 *** *** MySQLi Error connecting to MYSQL [0] *** -- Edit bug report at https://bugs.php.net/bug.php?id=72856&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72856&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72856&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72856&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72856&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72856&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72856&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72856&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72856&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72856&r=support Expected behavior: https://bugs.php.net/fix.php?id=72856&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72856&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72856&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72856&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72856&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72856&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72856&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72856&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72856&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72856&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72856&r=mysqlcfg

« previous php.bugs (#203316) next »