Bug #53483 [Opn]: using mysqli_stmt::send_long_data() makes execute() fail
| From: | uw@php.net | Date: | Thu, 06 Jan 2011 13:20:02 +0000 |
| Subject: | Bug #53483 [Opn]: using mysqli_stmt::send_long_data() makes execute() fail | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157665@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53483&edit=1
ID: 53483
Updated by: uw@php.net
Reported by: squarious at gmail dot com
Summary: using mysqli_stmt::send_long_data() makes execute()
fail
Status: Open
Type: Bug
Package: MySQLi related
Operating System: linux
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
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";
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2010-12-20 17:14:07] 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.
------------------------------------------------------------------------
[2010-12-20 16:51:45] andrey@php.net
I can't reproduce the problem :(
------------------------------------------------------------------------
[2010-12-20 16:50:58] andrey@php.net
libmysql + MySQL 5.1.55
andrey@poohie:~/PHP_5_3$ ./php a.php
OK: Executed prepared statement with blob less than max_allowed_packet.
OK: Executed prepared statement with blob bigger than
max_allowed_packet, sent at chunks.
mysqlnd + MySQL 5.1.55
andrey@poohie:~/PHP_5_3$ ./php a.php
OK: Executed prepared statement with blob less than max_allowed_packet.
OK: Executed prepared statement with blob bigger than
max_allowed_packet, sent at chunks.
------------------------------------------------------------------------
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
http://bugs.php.net/bug.php?id=53483
--
Edit this bug report at http://bugs.php.net/bug.php?id=53483&edit=1