Bug #38015 [Com]: Can not set PDO_MYSQL_ATTR_MAX_BUFFER_SIZE
| From: | reach dot supermike at gmail dot com | Date: | Sun, 28 Dec 2014 07:04:19 +0000 |
| Subject: | Bug #38015 [Com]: Can not set PDO_MYSQL_ATTR_MAX_BUFFER_SIZE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189237@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=38015&edit=1
ID: 38015
Comment by: reach dot supermike at gmail dot com
Reported by: sunaoka+bugs dot php dot net at gmail dot com
Summary: Can not set PDO_MYSQL_ATTR_MAX_BUFFER_SIZE
Status: Closed
Type: Bug
Package: PDO related
Operating System: Solaris
PHP Version: 5.1.4
Block user comment: N
Private report: N
New Comment:
On Ubuntu 14.04 LTS default with PHP 5.5.9, if you run the following code, you'll find it
doesn't ship with PDO::MYSQL_ATTR_MAX_BUFFER_SIZE:
$reflector = new ReflectionClass('PDO');
var_dump($reflector->getConstants());
At least for the MySQL items of that result, I only get:
MYSQL_ATTR_USE_BUFFERED_QUERY
MYSQL_ATTR_LOCAL_INFILE
MYSQL_ATTR_INIT_COMMAND
MYSQL_ATTR_COMPRESS
MYSQL_ATTR_DIRECT_QUERY
MYSQL_ATTR_FOUND_ROWS
MYSQL_ATTR_IGNORE_SPACE
MYSQL_ATTR_SSL_KEY
MYSQL_ATTR_SSL_CERT
MYSQL_ATTR_SSL_CA
MYSQL_ATTR_SSL_CAPATH
MYSQL_ATTR_SSL_CIPHER
MYSQL_ATTR_SERVER_PUBLIC_KEY
In fact, looking for anything dealing with SIZE, I turn up nothing.
However, I found this interesting bit of information on the web:
"PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer)
Maximum buffer size. Defaults to 1 MiB. This constant is not supported when compiled against
mysqlnd."
SOURCE: http://docs.hhvm.com/manual/en/ref.pdo-mysql.php
Hard to believe I had to visit the Hack website to find that out. Sure enough, Ubuntu 14.04 ships
with php5-mysqlnd instead of php5-mysql. So, I ran the following commands:
apt-get remove php5-mysqlnd
apt-get install php5-mysql
php5enmod mysql
service mysql stop
service mysql start
service apache2 stop
service apache2 start
Now when I run the code, the MYSQL_ATTR_MAX_BUFFER_SIZE is there. Also, I can set it with
setAttribute() and am not forced to set it in the connection as the 4th parameter.
For more information on mysqlnd versus mysql, please see this article:
https://wiki.php.net/doc/todo/mysqlnd_vs_libmysql
Previous Comments:
------------------------------------------------------------------------
[2006-07-26 02:08:47] sunaoka+bugs dot php dot net at gmail dot com
Thank you. It work as follows.
$pdo = new PDO ("connection_settings", "user", "pass", array
(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50));
------------------------------------------------------------------------
[2006-07-26 01:23:08] m dot leuffen at gmx dot de
Hi there,
it seems that the buffer size can be set only during instanciation of the PDO.
Try this:
$pdo = new PDO ("connection_settings", "user", "pass", array
(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>1024*1024*50));
This should fix the problem.
(If not this may be a MySQL configuration issue. Check the max_allowed_packet_size setting in your
mysql configuration - and make sure that my.cnf is on the right location)
Bye,
Matthias
------------------------------------------------------------------------
[2006-07-13 06:14:40] sunaoka+bugs dot php dot net at gmail dot com
Thank you for your comment.
I understood why the result wasn't 'int(10485760)'.
Then, why is there PDO_MYSQL_ATTR_MAX_BUFFER_SIZE?
After all, I cannot acquire data more than 1M byte.
The error occurs though I tried according to the manual as follows.
http://www.php.net/manual/en/ref.pdo.php#pdo.lobs
Reproduce code:
---------------
$db = $db = new PDO('mysql:host=localhost;dbname=test', 'user',
'pass');
$stmt = $db->prepare('SELECT FileData FROM FileInfo WHERE Id = ?');
$stmt->execute(array(1));
$stmt->bindColumn(1, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);
header('Content-Type: image/jpeg');
fpassthru($lob);
Expected result:
----------------
Warning: fpassthru(): supplied argument is not a valid stream resourcein ...
How can I load 1M data or more?
------------------------------------------------------------------------
[2006-07-07 12:08:55] sunaoka+bugs dot php dot net at gmail dot com
Thank you for your comment.
I understood why the result wasn't 'int(10485760)'.
Then, why is there PDO_MYSQL_ATTR_MAX_BUFFER_SIZE?
After all, I cannot acquire data more than 1M byte.
The error occurs though I tried according to the manual as follows.
http://www.php.net/manual/en/ref.pdo.php#pdo.lobs
fpassthru($lob);
Warning: fpassthru(): supplied argument is not a valid stream resource in ...
How can I load 1M data or more?
------------------------------------------------------------------------
[2006-07-07 08:33:05] tony2001@php.net
>But, I do not understand why the result doesn't become `int(10485760)'.
Why should it become equal to the size of the buffer?
Buffer is used to read the data by pieces and you can change size of of these pieces.
This is why it's called "PDO_MYSQL_ATTR_MAX_BUFFER_SIZE" and not
"PDO_MYSQL_ATTR_MAX_DATA_SIZE".
------------------------------------------------------------------------
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=38015
--
Edit this bug report at https://bugs.php.net/bug.php?id=38015&edit=1