perl5-dbi / DBD-mysql

MySQL driver for the Perl5 Database Interface (DBI)
https://metacpan.org/module/DBD::mysql
Other
63 stars 71 forks source link

MYSQL_OPT_COMPRESSION_ALGORITHMS is only supported by mysql 8.0.22 an higher #376

Closed thockar closed 11 months ago

thockar commented 11 months ago

the dependency to MySQL 8.0 is broken in 5.0.2, because 'MYSQL_OPT_COMPRESSION_ALGORITHMS' was added in mysql 8.0.22 - so lower versions of clientlibraries will cause DBD::myql compilation to fail

so either change the doc and the Makefile.PL to check for higher 8.0.x versions OR make the use of 'MYSQL_OPT_COMPRESSION_ALGORITHMS' depending on the client library version

dveeden commented 11 months ago

https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html has this: image

So looks like this was added in 8.0.18 instead.

dveeden commented 11 months ago

This was introduced in https://github.com/perl5-dbi/DBD-mysql/pull/372

dveeden commented 11 months ago

I would recommend to use the latest minor version of 8.0 to ensure you have all security fixes from MySQL.

@thockar any specific reason to use an older version? What OS do you use?

thockar commented 11 months ago

I compile the mysql 8 client library using gcc on windows (for strawberry perl). I modified the source of 8.0.15 (8.0.0 should be fine for DBD::mysql 5.002 reading the doc) to get it compatible to gcc - but this leads in to linker errors for missing symbol 'MYSQL_OPT_COMRESSION_ALGORITHMS' compiling the perl driver 5.002 with the libmysqlclient-21.a 8.0.15. For now I got it working with 8.0.15 by implementing MYSQL_OPT_COMRESSION_ALGORITHMS as dropin (call to) for MYSQL_OPT_COMRESS. This is not a nice solution and it can't be used in a production environment. I'll try to get the 8.2.x clientlib compiled, which will make the latest symbols (and code) available:

MYSQL_OPT_TLS_CIPHERSUITES, MYSQL_OPT_COMPRESSION_ALGORITHMS, MYSQL_OPT_ZSTD_COMPRESSION_LEVEL, MYSQL_OPT_LOAD_DATA_LOCAL_DIR, MYSQL_OPT_USER_PASSWORD, MYSQL_OPT_SSL_SESSION_DATA, MYSQL_OPT_TLS_SNI_SERVERNAME

How ever, if someone uses 8.0.17 (or lower) at any platform, he/she will run in to the same problem without getting any hint why and without making any mistake.

Implementing any of the future mysql functions in to DBD::mysql will lead in to similar problems. A possible solution would be to parse 'enum mysql_option' in the mysql.h, set some compiler flags (-D....) like HAVE_MYSQL_OPT_TLS_CIPHERSUITES HAVE_MYSQL_OPT_COMPRESSION_ALGORITHMS ... and let the driver code (base compatible to 8.0.0) depend on these flags.

dveeden commented 11 months ago

Thanks for the info. Could you see if https://github.com/perl5-dbi/DBD-mysql/pull/377 fixes this for you?

thockar commented 11 months ago

Yes, this fixes the issue (I already tried it similar). Thank you.

if MYSQL_VERSION_ID >= 80018

This will lead in to the same hard to maintain code for the 5.xxx version - like the 4.xxx code before. IMO depending on available symbols is more clear - but it's your code !