Edit report at https://bugs.php.net/bug.php?id=53483&edit=1

 ID:                 53483
 Comment by:         jared dot williams1 at ntlworld dot com
 Reported by:        squarious at gmail dot com
 Summary:            using mysqli_stmt::send_long_data() makes execute()
                     fail
 Status:             Not a bug
 Type:               Bug
 Package:            MySQLi related
 Operating System:   linux
 PHP Version:        5.3.3
 Assigned To:        mysql
 Block user comment: N
 Private report:     N

 New Comment:

With 

PHP 5.6.0-dev (cli) (built: Feb  6 2013 19:53:24) 
MySQL 5.6.10

mysqli using mysqlnd. 

The test code in the comment fails.

OK: Executed prepared statement with blob less than max_allowed_packet.
PHP Warning:  Error while sending STMT_SEND_LONG_DATA packet. PID=21455 in 
/home/jared/Development/junk/foo.php on line 43
Error sending long packet. MySQL server has gone away


Previous Comments:
------------------------------------------------------------------------
[2011-01-07 15:35:02] and...@php.net

Seems it was a MySQL Server bug which was fixed in 5.5.8 GA and 5.1.5x

------------------------------------------------------------------------
[2011-01-06 14:28:07] u...@php.net

Andrey, 

smells like a server bug fixed in the latest 5.0, 5.1. 5.5 series. Below is 
mysqlnd @ 64bit @ MySQL 5.1.45. 

Ulf


nixnutz@linux-fuxh:~/php/php-src/branches/PHP_5_3_cta> sapi/cli/php foo.php
array(1) {
  ["client_info"]=>
  string(48) "mysqlnd 5.0.7-dev - 091210 - $Revision: 306939 $"
}
array(1) {
  ["server_info"]=>
  string(12) "5.1.45-debug"
}
OK: Executed prepared statement with blob less than max_allowed_packet.
Error executing prepared statement. Got a packet bigger than 
'max_allowed_packet' bytes

------------------------------------------------------------------------
[2011-01-06 14:20:01] u...@php.net

Please always add complete test. Never link external sites.

<?php
// Reproduce bug that with send_long_data, execute() fails

// Agjust your settings before execute
$conn = new mysqli(
        'localhost',    // << Server
        'root',                 // << Username
        'root',                 // << Password
        'test'          // << Schema
);

if (!$conn->query('CREATE TABLE IF NOT EXISTS `test_bug_blob` (`id` integer 
auto_increment, `data` BLOB, PRIMARY KEY(`id`));'))
        die("Error creating table.\n");

if (!($result = $conn->query('SELECT @@max_allowed_packet')))
        die("Error reading max allowed packet size.\n");
$max_allowed_packet = $result->fetch_array();
$max_allowed_packet = $max_allowed_packet[0];

if (!($stmt = $conn->prepare('INSERT INTO `test_bug_blob` (`data`) VALUES 
(?)')))
        die("Cannot prepare statement for INSERT. {$conn->error}\n");

// Sent blob smaller than max allowed_packet
$data = str_repeat('0123456789', $max_allowed_packet/20);
if (!$stmt->bind_param('s', $data))
        die("Error binding parameters. {$stmt->error}\n");
if (!$stmt->execute())
        die("Error executing prepared statement. {$stmt->error}\n");
echo "OK: Executed prepared statement with blob less than 
max_allowed_packet.\n";

// Sent blob bigger than max allowed_packet
$big_data = str_repeat('0123456789', $max_allowed_packet/9);
$null = null;
if (!$stmt->bind_param('b', $null))
        die("Error binding parameters. {$stmt->error}\n");
foreach(str_split($big_data, $max_allowed_packet) as $packet )
        if (!$stmt->send_long_data(0, $packet))
                die("Error sending long packet. {$stmt->error}\n");
if (!$stmt->execute())
        die("Error executing prepared statement. {$stmt->error}\n");
echo "OK: Executed prepared statement with blob bigger than max_allowed_packet, 
sent at chunks.\n";

------------------------------------------------------------------------
[2010-12-20 17:56:32] jbreton at kronostechnologies dot com

I upgraded mysql to 5.1.54 using debian experimental packages and the problem 
is 
gone.

Hopefully it won't break my ubuntu setup, which was a brand new 10.10 using 
official packages.

------------------------------------------------------------------------
[2010-12-20 17:14:09] jbreton at kronostechnologes dot com

You haven't tried mysql5.1.49 which was specified in squarious' description.

I just tried with php 5.3.4 stable and mysql5.1.49 without success.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=53483


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=53483&edit=1

Reply via email to