Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle newer libmysqlclient #1

Open
mbeijen opened this issue Sep 6, 2016 · 19 comments
Open

Bundle newer libmysqlclient #1

mbeijen opened this issue Sep 6, 2016 · 19 comments

Comments

@mbeijen
Copy link

mbeijen commented Sep 6, 2016

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
Copy link
Member

kmx commented Oct 11, 2016

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
Copy link
Author

mbeijen commented Oct 11, 2016

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: perl5-dbi/DBD-mysql@1f8c3fc

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
Copy link
Member

kmx commented Oct 11, 2016

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
Copy link
Author

mbeijen commented Oct 11, 2016

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
Copy link
Member

kmx commented Oct 11, 2016

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
Copy link
Member

kmx commented Oct 11, 2016

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
Copy link
Author

mbeijen commented Oct 11, 2016

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

@kmx
Copy link
Member

kmx commented Oct 16, 2016

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
Copy link
Author

mbeijen commented Oct 16, 2016

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

Op zondag 16 oktober 2016 heeft kmx [email protected] 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
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAoQMGo6H0WnJEk9DNHSLc7gX6bdd3R6ks5q0ljEgaJpZM4J1fqx
.

@kmx
Copy link
Member

kmx commented Oct 18, 2016

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
Copy link

dveeden commented Nov 1, 2023

@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
Copy link
Member

genio commented Nov 1, 2023

@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
Copy link
Contributor

shawnlaffan commented Nov 1, 2023

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
Copy link

dveeden commented Nov 2, 2023

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
Copy link

@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
Copy link
Contributor

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

@dveeden
Copy link

dveeden commented Mar 21, 2024

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

@shawnlaffan
Copy link
Contributor

I've not had the opportunity yet. If you wanted to have a go then you could try adding the steps in StrawberryPerl/Perl-Dist-Strawberry#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
Copy link

dveeden commented May 3, 2024

@shawnlaffan I've tried the files from StrawberryPerl/Perl-Dist-Strawberry#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants