php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70384 mysqli_real_query(): Unknown type 245 sent by the server
Submitted: 2015-08-28 18:13 UTC Modified: 2015-12-10 09:49 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: marc at infomarc dot info Assigned: mysql (profile)
Status: Closed Package: MySQLi related
PHP Version: 7.0.0RC1 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marc at infomarc dot info
New email:
PHP Version: OS:

 

 [2015-08-28 18:13 UTC] marc at infomarc dot info
Description:
------------
I report this for 7.0.0RC1 but am able to reproduce also on PHP 5.6.7. MySQL Server is 5.7.8-rc. Test table created with 

CREATE TABLE `marctable` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `jsoncol` json DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1


Test script:
---------------
<?php

$link = mysqli_init();

$connect_result = mysqli_real_connect($link, '127.0.0.1', 'userxxx', 'passxxx', 'marcdb');

echo "connect_result: " . $connect_result . "\n";

$query_result = mysqli_real_query($link, "select * from marctable");

echo "query result: " . $query_result . "\n";

echo "mysqli_error: " . mysqli_error($link) . "\n";


Expected result:
----------------
connect_result: 1
query result: 1
mysqli_error: 

Actual result:
--------------
connect_result: 1
PHP Warning:  mysqli_real_query(): Unknown type 245 sent by the server. Please send a report to the developers in bugjson.php on line 9

Warning: mysqli_real_query(): Unknown type 245 sent by the server. Please send a report to the developers in bugjson.php on line 9
zend_mm_heap corrupted


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-28 19:22 UTC] morgan dot tocker at oracle dot com
There is a temporary workaround available here.  The test case can be modified to cast the JSON type to a CHAR, which is fine from PHP's perspective:

select id, CAST(jsoncol as CHAR)  from marctable
 [2015-08-28 19:43 UTC] johannes@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
 [2015-09-29 14:02 UTC] andrey@php.net
-Status: Assigned +Status: Closed
 [2015-09-29 14:02 UTC] andrey@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Fixed in PHP-5.6, PHP-7.0 and master (PHP-7.1)

Thank You for your report
 [2015-09-29 21:30 UTC] marc at infomarc dot info
Hi Andrey,
I believe you also need to register MYSQLI_TYPE_JSON in ext/mysqli/mysqli.c.

Marc Delisle
 [2015-09-30 07:06 UTC] andrey@php.net
Hi Marc,
I forgot that. A fix got just pushed to 5.6, 7.0 and 7.1

Thanks!
 [2015-10-05 14:24 UTC] lucian dot depold at gmail dot com
Problem does not seem to be resolved in 5.6.14 for windows. Newer snapshots are somehow not available.
 [2015-12-09 01:47 UTC] jterry at joeterry dot com
It looks like the issue is resolved when using the approach given by the OP, however, it's still reproducible in 5.6.16 with the following:

$query = mysqli_query($db, $sql); // table contains a JSON field

if (false !== $query) {
    while ($row = mysqli_fetch_array($query) {
        // do something
    }
}
 [2015-12-10 09:49 UTC] andrey@php.net
JTerry,
can you provide a minimal test case that fails, together with information about PHP version (I suppose 5.6.16), whether libmysql or mysqlnd is used by mysqli (phpinfo() will tell this).

Best,
Andrey
 [2015-12-10 16:00 UTC] jterry at joeterry dot com
Hi Andrey - happy to:

Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips PHP/5.6.14
mysqlnd 5.0.11-dev

For the test case, see my previous comment; when that code snippet is executed I see the 245 error. The only note I'd add is that the SQL has a valid JSON column data type in the return, and that your suggestion of CAST(jsoncol AS CHAR) does work around the issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 11:01:29 2024 UTC