Bug #74021 [Com]: fetch_array broken data. Data more then MEDIUMBLOB
| From: | andrew dot nester dot dev at gmail dot com | Date: | Wed, 01 Feb 2017 10:48:26 +0000 |
| Subject: | Bug #74021 [Com]: fetch_array broken data. Data more then MEDIUMBLOB | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207088@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74021&edit=1
ID: 74021
Comment by: andrew dot nester dot dev at gmail dot com
Reported by: mavgust at radaris dot com
Summary: fetch_array broken data. Data more then MEDIUMBLOB
Status: Open
Type: Bug
Package: MySQLi related
Operating System: Linux(Centos)
PHP Version: 7.1.1
Block user comment: N
Private report: N
New Comment:
Just added PR on GitHub with fix for this issue.
Previous Comments:
------------------------------------------------------------------------
[2017-02-01 08:43:46] mavgust at radaris dot com
max_allowed_packet | 67108864
I try
$res = $m->query("SELECT RPAD('1',9000000,'1') as
a,RPAD('1',9000000,'1') as b")
$r = $res->fetch_array()
md5($r['a']) = 42ca0fd16ab6b6d4b9d47dc0a4a8b12a
md5($r['b']) = 6344f4429e683a9d37bef06feecbfe87
BUT REQUEST $m->query("SELECT RPAD('1',9000000,'1') as
a,RPAD('1',9000000,'1') as b,'test' as c")
Return ERROR mysqli_result::fetch_array(): Malformed server packet. Field length pointing 44 bytes
after end of packet
I downgrade php package from php.x86_64 0:7.1.1-2.el7.remi to php.x86_64 0:7.1.0-1.el7.remi and
all work fine
------------------------------------------------------------------------
[2017-02-01 07:46:34] andrew dot nester dot dev at gmail dot com
I was unable to reproduce this on latest PHP version.
what is you MySQL configuration, for example, max_allowed_packet?
------------------------------------------------------------------------
[2017-01-31 11:00:22] mavgust at radaris dot com
Description:
------------
IF size of all reading fields from mysql table >MEDIUMBLOB (16777215), last field broken
In php version 7.1.0 all right
Test script:
---------------
$table = 'test';
$m = mysqli_connect("lacalhost", "user", "pwd", "db");
$m->query("CREATE TABLE
".$table." ( id tinyint(4) NOT
NULL,
first mediumblob NOT NULL,
second mediumblob NOT NULL,
third mediumblob NOT NULL, PRIMARY KEY (id))
ENGINE=MyISAM");
$sm = $m->prepare("INSERT INTO ".$table." (id,first, second, third) VALUES
(?,?,?,?)");
$sm->bind_param("isss",$id,$d,$d,$d);
$id = 1;
$d = str_pad("1", 6000000, "1");
$sm->execute();
$sm->close();
$res = $m->query("select first,second,third from ".$table." where id=1");
$r=$res->fetch_array();
echo "\n\nFirst: ".md5($r['first']). "\nSecond:
".md5($r['second']). "\nThird: ".md5($r['third']);
$res = $m->query("select third,first,second from ".$table." where id=1");
$r=$res->fetch_array();
echo "\n\nFirst: ".md5($r['first']). "\nSecond:
".md5($r['second']). "\nThird: ".md5($r['third']);
$res = $m->query("select second,third,first from ".$table." where id=1");
$r=$res->fetch_array();
echo "\n\nFirst: ".md5($r['first']). "\nSecond:
".md5($r['second']). "\nThird: ".md5($r['third']);
Expected result:
----------------
First: 0ee40b4246130ee135b58c07382e69f6
Second: 0ee40b4246130ee135b58c07382e69f6
Third: 0ee40b4246130ee135b58c07382e69f6
Actual result:
--------------
First: 0ee40b4246130ee135b58c07382e69f6
Second: 0ee40b4246130ee135b58c07382e69f6
Third: c7090cb3ccbc696b3c6cc1e6c4c2fb29
First: 0ee40b4246130ee135b58c07382e69f6
Second: c7090cb3ccbc696b3c6cc1e6c4c2fb29
Third: 0ee40b4246130ee135b58c07382e69f6
First: c7090cb3ccbc696b3c6cc1e6c4c2fb29
Second: 0ee40b4246130ee135b58c07382e69f6
Third: 0ee40b4246130ee135b58c07382e69f6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74021&edit=1