php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52529 PDO+Mysqlnd MYSQL_ATTR_COMPRESS undefined
Submitted: 2010-08-04 03:02 UTC Modified: 2010-10-20 09:24 UTC
From: ben at blazely dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3SVN-2010-08-04 (snap) OS: Ubuntu 10.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ben at blazely dot com
New email:
PHP Version: OS:

 

 [2010-08-04 03:02 UTC] ben at blazely dot com
Description:
------------
Client compression support was added to mysqlnd in php 5.3.3. PDO_mysql should now be able to use it.

However the constant MYSQL_ATTR_COMPRESS is undefined in the PDO class when compiling using the following (bare minimum) config:

./configure --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd

Due to how recent this addition is, I can find no further information on php.net/google/anywhere...

There are also some confusing (and useless?) switches in configure for mysqlnd compression that seem counter-intuitive.

--disable-mysqlnd-compression-support
                            Enable support for the MySQL compressed protocol in mysqlnd
--with-zlib-dir[=DIR]       mysqlnd: Set the path to libz install prefix

When configure runs, it says that it has disabled mysqlnd compression support, however phpinfo() (post compile) shows that compression is available and that pdo_mysql is using mysqlnd. 

--

mysql

MySQL Support => enabled
Active Persistent Links => 0
Active Links => 0
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 

--

mysqlnd

mysqlnd => enabled
Version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $
Compression => supported
SSL => supported
Command buffer size => 4096
Read buffer size => 32768
Read timeout => 31536000
Collecting statistics => Yes
Collecting memory statistics => No

--

PDO

PDO support => enabled
PDO drivers => sqlite, sqlite2, mysql

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => mysqlnd 5.0.7-dev - 091210 - $Revision: 300533 $



Test script:
---------------
<?php
define("DATABASE_TYPE",	       'mysql');
define("DATABASE_USERNAME",    'dbuser');
define("DATABASE_PORT",	       '3306');
define("DATABASE_HOST",	       'db.server');
define("DATABASE_PASSWORD",    'dbpass');
define("DATABASE_DBNAME",      'dbname');

  try {
    	$o_dbh = new PDO(
    	    DATABASE_TYPE.":host=".DATABASE_HOST.";port=".DATABASE_PORT.";dbname=".DATABASE_DBNAME, 
			DATABASE_USERNAME, 
			DATABASE_PASSWORD,
			Array(
                PDO::MYSQL_ATTR_COMPRESS => true
            )
		);
  } catch (PDOException $o_e) {
     print $o_e->getMessage();
  }

Expected result:
----------------
No output, DB connection established, client compression enabled.

Actual result:
--------------
Error as follows:
Fatal error: Undefined class constant 'MYSQL_ATTR_COMPRESS' in test.php on line 15

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-04 11:14 UTC] kalle@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: mysql
 [2010-08-04 11:14 UTC] kalle@php.net
Its currently known as indicated in the sources that compression is unavailable in mysqlnd

Assigned to the mysql team
 [2010-08-04 16:23 UTC] ben at blazely dot com
I was aware that pdo_mysql did not support compression, however I thought that it was added in 5.3.2? I'm using 5.3.3. 

Was this not the case? If not then the documentation below may need to be changed as I found it a little misleading.

From: http://www.php.net/manual/en/mysqlnd.overview.php

Compressed Protocol Support

As of PHP 5.3.2 MySQL Native Driver supports the compressed client server protocol. MySQL Native Driver did not support this in 5.3.0 and 5.3.1. Extensions such as ext/mysql, ext/mysqli, PDO_MYSQL, that are configured to use MySQL Native Driver, can also take advantage of this feature.
 [2010-08-05 14:08 UTC] johannes@php.net
-Status: Assigned +Status: Open -Package: PDO related +Package: Documentation problem -Assigned To: mysql +Assigned To:
 [2010-08-05 14:08 UTC] johannes@php.net
PDO_mysql never supported compression, compression support only was added to mysqlnd so it has all libmysql features.

In general we don't overly encourage using compression as usually the bottleneck is more on the CPU than network.
 [2010-10-20 09:24 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=304538
Log: Fixed bug #52529 (PDO+Mysqlnd MYSQL_ATTR_COMPRESS undefined)
Documented missing constants for PDO_MYSQL
 * PDO::MYSQL_ATTR_COMPRESS
 * PDO::MYSQL_ATTR_FOUND_ROWS
 * PDO::MYSQL_ATTR_IGNORE_SPACE

And some small clarifications about which ones are available using mysqlnd.
 [2010-10-20 09:24 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-20 09:24 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=d5acc598529eee4dd592f3aa52a1ae8b793e1d5b
Log: Fixed bug #52529 (PDO+Mysqlnd MYSQL_ATTR_COMPRESS undefined) Documented missing constants for PDO_MYSQL  * PDO::MYSQL_ATTR_COMPRESS  * PDO::MYSQL_ATTR_FOUND_ROWS  * PDO::MYSQL_ATTR_IGNORE_SPACE
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC