Bug #3510 MYSQL_CLIENT _COMPRESS Flag
Submitted: 19 Apr 2004 20:29 Modified: 28 Apr 2004 18:27
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.18 OS:Linux (Linux RedHat)
Assigned to: Georg Richter CPU Architecture:Any

[19 Apr 2004 20:29] [ name withheld ]
Description:
Tested with PHP 4.3.4 and MySQL 4.0.18

Using MYSQL_CLIENT_COMPRESS flag with PHP function to connect is not working, no compressed protocol is used and data transfered in same way with or without flag. 

How to repeat:
mytest.php :
---------------------- 
$mycmsconn=mysql_connect("$dbip","$dblogin","$dbpass",false,MYSQL_CLIENT_COMPRESS);
$mycmsdataquery="SELECT * FROM foo";
$mycmsdataresult = mysql_query($mycmsdataquery,$mycmsconn); $mycmsdatarow = mysql_fetch_array($mycmsdataresult);
-----------------------

I test versus my firewall : 

29 2486 3685K ACCEPT tcp -- any any anywhere anywhere state ESTABLISHED tcp spt:mysql 29 1249 65053 ACCEPT tcp -- any any anywhere anywhere state NEW,ESTABLISHED tcp dpt:mysql 

then i restart my firewall and do :

mytest.php :
------------------------ $mycmsconn=mysql_connect("$dbip","$dblogin","$dbpass",false,MYSQL_CLIENT_COMPRESS);
$mycmsdataquery="SELECT * FROM foo";
$mycmsdataresult = mysql_query($mycmsdataquery,$mycmsconn);
$mycmsdatarow = mysql_fetch_array($mycmsdataresult);
------------------------ 

/etc/init.d/firewall.sh status | grep mysql 

29 2486 3684K ACCEPT tcp -- any any anywhere anywhere state ESTABLISHED tcp spt:mysql 29 1249 65053 ACCEPT tcp -- any any anywhere anywhere state NEW,ESTABLISHED tcp dpt:mysql 

(needless to say that the database server is on a remote host....)

(Info copied from Sebastian, as he got same problem as me and tested with a firewall)
[28 Apr 2004 14:58] Georg Richter
Please make sure that both your server and your client support compressed 
protocol. 
 
PHP and the bundled libmysql-3.23 doesn't support it by default. 
You have to configure PHP with zlib support. Also it's recommendable to use 
4.0.18 client library instead of 3.23.49 which is bundled with PHP.
[28 Apr 2004 17:04] [ name withheld ]
From php info: using client api 4.0.18, and zlib enabled

mysql
MySQL Support enabled 
Active Persistent Links  0  
Active Links  0  
Client API version  4.0.18  
MYSQL_MODULE_TYPE  external  
MYSQL_SOCKET  /var/lib/mysql/mysql.sock  
MYSQL_INCLUDE  -I/usr/include/mysql  
MYSQL_LIBS  -L/usr/lib -lmysqlclient  

zlib
ZLib Support  enabled  
Compiled Version  1.1.4  
Linked Version  1.1.4  

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

I noticed mysql server (4.0.18) don't show HAVE_COMPRESS variable with show variables;
Don't know how to compile mysql to get that variable available, so that's probably because MYSQL_CLIENT _COMPRESS Flag don't work.
[28 Apr 2004 18:27] Sergei Golubchik
No, "have_compress" variable has nothing to do with it.
It was introduced in 4.1, that's why you don't see it.
The absense of this variable cannot be the reason for non-compressed protocol, because you issue 'SHOW VARIABLES' *after* establishing a connection, so it does not matter what the query shows - whether compression will be used or not is decided during the initial handshake.

Are you sure a server was built with zlib support ? Can you connect with a different client to get a compressed protocol ?