StrawberryPerl / build-extlibs

16 stars 11 forks source link

Bundle newer libmysqlclient #1

Open mbeijen opened 8 years ago

mbeijen commented 8 years ago

Hi there! I'm a maintainer of DBD::mysql. The libmysqlclient version shipped with StrawberryPerl is quite old (based on MySQL 5.1).

It would be awesome if StrawberryPerl could bundle a newer version of the mysql client libraries. I saw your notes in the repository trying to compiling.

MySQL states compiling with MinGW is not supported, and you need to use Visual Studio. http://forums.mysql.com/read.php?117,650075,650095#msg-650095

Would it be possible to use Visual Studio-built libraries and compile DBD::mysql around that using MinGW?

kmx commented 8 years ago

Hi Michiel, yes the main trouble with mysql client is the fact that it does not compile well with mingw-w64.

I used to use kind of 3rd party binaries (mostly official builds) of libmysql.dll and just generate .def + .a files via gendef + dlltool. However this approach stopped to work at some point after 5.1.? (that's why I have stuck with so old version).

Now (=today) I have tried to take the official libmysql.dll from mysql-connector-c v6.1.6 and generate .def + .a as described above, plus I have also created "fake" mysql_config.bat.

These packs are available at:

The latest DBD::mysql nearly builds, I only had to apply this patch

diff -ru DBD-mysql-4.037/dbdimp.h DBD-mysql-4.037-patched/dbdimp.h
--- DBD-mysql-4.037/dbdimp.h    2016-10-03 08:52:35.000000000 +0200
+++ DBD-mysql-4.037-patched/dbdimp.h    2016-10-11 21:17:11.609759000 +0200
@@ -27,7 +27,7 @@
 /* For now, we hardcode this, but in the future,
  * we can detect capabilities of the MySQL libraries
  * we're talking to */
-#if defined(__WIN__)
+#if defined(WIN32)
 #define MYSQL_ASYNC 0
 #else
 #define MYSQL_ASYNC 1
diff -ru DBD-mysql-4.037/mysql.xs DBD-mysql-4.037-patched/mysql.xs
--- DBD-mysql-4.037/mysql.xs    2016-10-03 08:52:35.000000000 +0200
+++ DBD-mysql-4.037-patched/mysql.xs    2016-10-11 21:23:47.699238900 +0200
@@ -904,15 +904,6 @@
        case SQL_IDENTIFIER_QUOTE_CHAR:
            retsv = newSVpv("`", 1);
            break;
-       case SQL_MAXIMUM_STATEMENT_LENGTH:
-#if !defined(net_buffer_length)
-        /* From MySQL 5.7.9 net_buffer_length is no longer a macro
-           that can be used. Instead we use mysql_get_option to retrieve the
-           value into a local varaible. */
-        mysql_get_option(NULL, MYSQL_OPT_NET_BUFFER_LENGTH, &net_buffer_length);
-#endif
-           retsv = newSViv(net_buffer_length);
-           break;
        case SQL_MAXIMUM_TABLES_IN_SELECT:
            /* newSViv((sizeof(int) > 32) ? sizeof(int)-1 : 31 ); in general? */
            retsv= newSViv((sizeof(int) == 64 ) ? 63 : 31 );

Unfortunately I do not have any mysql server for testing, so if you have one + some spare time please try the binaries from URLs above.

Regards kmx

mbeijen commented 8 years ago

Awesome! And very unfortunate that it requires this 'black magic' to get new libraries for perl on Windows.

The first part of the patch is already in master: https://github.com/perl5-dbi/DBD-mysql/commit/1f8c3fc52cdb9a554c0554d1ed708441dc428953

Do you have an idea as of to why you need the second part, the patch to mysql.xs? I will most definitely try your libraries this week, and will post feedback.

kmx commented 8 years ago

Without the second part I get the following error:

mysql.o: In function `XS_DBD__mysql__GetInfo_dbd_mysql_get_info':
C:\tmp64\data\.cpanm\work\1476212817.11712\DBD-mysql-4.037/mysql.xs:914:
undefined reference to `mysql_get_parameters'

I have no idea what is mysql_get_parameters good for but the fact is that it is not exported from libmysql.dll thus it cannot be linked.

mbeijen commented 8 years ago

Thanks! I found a notice in the release notes for the 5.7 API: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-9.html#mysqld-5-7-9-capi:

The (undocumented) mysql_get_parameters() function has been removed. Applications that attempt to use it will get link errors and should be modified to use mysql_options() and mysql_get_option() instead.

But the code the error points to does use mysql_get_option(). Where does the error about the reference to mysql_get_parameters come from?

kmx commented 8 years ago

It comes from using net_buffer_length which is defined in mysql.h as:

#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) 

Both mysql_options and mysql_get_option are exported from libmysql.dll so switching to these should be fine.

kmx commented 8 years ago

Please also have a look at bin\mysql_config.bat which something I did in the past to match the detection in Makefile.PL so that simple cpanm DBD::mysql works.

mbeijen commented 8 years ago

Will do. I like the mysql_config.bat a lot, it makes installing DBD::mysql on Strawberry 'Just Work', thanks for that!

kmx commented 8 years ago

Hello Michiel, I plan to release the next strawberry perl (5.24.1 + 5.22.3) approx. during the next weekend (Oct 22).

If you can prepare a working version of DBD::mysql which works with the binaries mentioned above I will upgrade mysql client DLLs bundled with the next (Oct 22) strawberry perl release.

mbeijen commented 8 years ago

That'll work! Thanks. I ran tests against MySQL Server and they all pass.

Op zondag 16 oktober 2016 heeft kmx notifications@github.com het volgende geschreven:

Hello Michiel, I plan to release the next strawberry perl (5.24.1 + 5.22.3) approx. during the next weekend (Oct 22).

If you can prepare a working version of DBD::mysql which works with the binaries mentioned above I will upgrade mysql client DLLs bundled with the next (Oct 22) strawberry perl release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/StrawberryPerl/build-extlibs/issues/1#issuecomment-254059189, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoQMGo6H0WnJEk9DNHSLc7gX6bdd3R6ks5q0ljEgaJpZM4J1fqx .

kmx commented 8 years ago

I have prepared even newer binaries based on mysql 5.7.16

Please test them with a patch for DBD-mysql that I have sent as the PR mentioned above.

If it works please make a new DBD-mysql release.

dveeden commented 1 year ago

@kmx Would it be possible to update the MySQL libs to MySQL 8.0.x ? MySQL 5.7 has reached EOL and DBD::mysql now needs 8.0 or newer.

genio commented 1 year ago

@dveeden We can certainly look at packaging newer versions of mysql. However, since 5.38 has already been released, it likely wouldn't be doable until the release for 5.40. @shawnlaffan ideas?

shawnlaffan commented 1 year ago

If the patch given above still applies then we could add it. Otherwise we'd need some help.

I don't see an issue with adding it for 5.38.1. 5.40 is not due until May or so next year.

dveeden commented 1 year ago

If the patch given above still applies then we could add it. Otherwise we'd need some help.

I don't see an issue with adding it for 5.38.1. 5.40 is not due until May or so next year.

I don't think that patch will apply anymore. Please let me know if you have any issues compiling DBD::mysql.

bryan-valentine commented 10 months ago

@kmx Would it be possible to update the MySQL libs to MySQL 8.0.x ? MySQL 5.7 has reached EOL and DBD::mysql now needs 8.0 or newer.

I'm experiencing this same issue with latest Strawberry and latest DBD:mysql.

shawnlaffan commented 10 months ago

There are some mysql binaries as an attachment at https://github.com/StrawberryPerl/Perl-Dist-Strawberry/discussions/157 that you could try building DBD::mysql against.

dveeden commented 7 months ago

Any update on this? Anything I can do to help?

shawnlaffan commented 7 months ago

I've not had the opportunity yet. If you wanted to have a go then you could try adding the steps in https://github.com/StrawberryPerl/Perl-Dist-Strawberry/discussions/157 to the build system.

It is possible to avoid rebuilding the full set of libs by having them already in the build tree. I need to document that (and would add notes here but I have to do it to remember the steps).

dveeden commented 6 months ago

@shawnlaffan I've tried the files from https://github.com/StrawberryPerl/Perl-Dist-Strawberry/discussions/157

Please note that MySQL has just released 8.4.0 LTS. MySQL 8.2.0 as used in mysql_80200.zip is not an LTS release, it is an innovation release. I would suggest to either use the MySQL 8.0.37 or MySQL 8.4.0.