Bug #110879 Compression doesn't work with C extension API
Submitted: 1 May 2023 19:01 Modified: 12 May 2023 14:24
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.33 OS:Any
Assigned to: CPU Architecture:Any
Tags: cext, compression, Contribution

[1 May 2023 19:01] Daniël van Eeden
Description:
https://dev.mysql.com/doc/connector-python/en/connector-python-api-cext-connect.html says that `compress` is a valid argument.

However both traffic inspection as status variables show that compression isn't used.

```
$ /tmp/connpy_cext_compressed.py
('Compression', 'OFF')
('Compression_algorithm', '')
('Compression_level', '0')
```

How to repeat:
```
#!/bin/python3
import _mysql_connector

con = _mysql_connector.MySQL()
con.connect(
    host="127.0.0.1",
    user="root",
    password="root",
    compress=True,
)

con.query("SHOW STATUS LIKE 'Compression%'")
while row := con.fetch_row():
    print(row)
con.free_result()

con.close()
```

Suggested fix:
Make sure compression works, both zlib and zstd if possible.
[2 May 2023 11:32] MySQL Verification Team
Hello Daniël,

Thank you for the bug report and contribution.

Regards,
Ashwini Patil
[2 May 2023 15:42] OCA Admin
Contribution submitted via Github - cext: Support compression 
(*) Contribution by Daniël van Eeden (Github dveeden, mysql-connector-python/pull/90#issuecomment-1530824546): I confirm the code being submitted is offered under the terms of the OCA,  and that I am authorized to contribute it.

Contribution: git_patch_1334208529.txt (text/plain), 964 bytes.

[12 May 2023 9:50] Nuno Mariz
Posted by developer:
 
Thank you for your contribution.
[12 May 2023 14:24] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.1.0 release, and here's the proposed changelog entry from the documentation team:

Setting "compress=True" did not enable compression when using the C
extension implementation. 

Thanks to Daniël van Eeden for the contribution.

Thank you for the bug report.