Bug 219797 - databases/py-MySQLdb: Fails to build with MariaDB 10.2.6
Summary: databases/py-MySQLdb: Fails to build with MariaDB 10.2.6
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Bernard Spil
URL: https://reviews.freebsd.org/D11054
Keywords: needs-qa, patch
Depends on:
Reported: 2017-06-05 08:15 UTC by Sir l33tname
Modified: 2018-03-02 06:43 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (python)
koobs: maintainer-feedback? (brnrd)
koobs: merge-quarterly?

svn diff for databases/p5-DBD-mysql (2.09 KB, patch)
2017-06-06 08:32 UTC, Bernard Spil
no flags Details | Diff
svn diff for databases/py-MySQLdb (1.19 KB, patch)
2017-07-23 19:46 UTC, Bernard Spil
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sir l33tname 2017-06-05 08:15:59 UTC
With Mariadb 10.2.6 the Connect/C is updated to ~3.0. This means the C interface changed slightly and some functions are changed. 

I updated the _mysql.c and cleaned up the Makefile a bit. See review D11054 .

But since I only use the latest mariadb I'm not sure if it works with older versions and MySQL. Also I don't know how exactly python C extensions work. So maybe my patch is horribly wrong. 

Why is this port important? Because it's used by www/observium.
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2017-06-05 08:28:28 UTC
What are the current symptoms of the issue? Is there a failure to build/package, run time issues/incompatibilities or other?
Comment 2 Sir l33tname 2017-06-05 08:33:14 UTC
The symptoms are that you can't build the port (see below) with MariaDB 10.2.6 (the latest release). Run time should be fine.

building '_mysql' extension
creating build/temp.freebsd-11.0-RELEASE-p10-amd64-2.7
cc -DNDEBUG -O2 -pipe -fstack-protector -fno-strict-aliasing -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/include/mysql -I/usr/local/include/mysql/mysql -I/usr/local/include/python2.7 -c _mysql.c -o build/temp.freebsd-11.0-RELEASE-p10-amd64-2.7/_mysql.o
_mysql.c:1593:10: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (how < 0 || how >= sizeof(row_converters)) {
            ~~~ ^ ~
_mysql.c:1947:47: warning: incompatible pointer types passing 'MYSQL *' (aka 'struct st_mysql *') to parameter of type 'MYSQL_RES *' (aka 'struct st_mysql_res *') [-Wincompatible-pointer-types]
        return PyInt_FromLong((long)mysql_num_fields(&(self->connection)));
/usr/local/include/mysql/mysql.h:470:50: note: passing argument to parameter 'res' here
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
_mysql.c:2009:42: error: no member named 'reconnect' in 'struct st_mysql'
        if ( reconnect != -1 ) self->connection.reconnect = reconnect;
                               ~~~~~~~~~~~~~~~~ ^
_mysql.c:2089:3: error: too few arguments to function call, expected 2, have 1
/usr/local/include/mysql/mysql.h:518:1: note: 'mysql_shutdown' declared here
int             STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level);
2 warnings and 2 errors generated.
error: command 'cc' failed with exit status 1
*** Error code 1
Comment 3 Bernard Spil freebsd_committer 2017-06-06 08:32:28 UTC
Created attachment 183258 [details]
svn diff for databases/p5-DBD-mysql


Just added a patch to fix this. Can you please test and let me know if this fixes the build and does not introduce regressions at runtime?

Thanks! Bernard (maintainer MariaDB ports)
Comment 4 Bernard Spil freebsd_committer 2017-06-06 08:34:25 UTC
Comment on attachment 183258 [details]
svn diff for databases/p5-DBD-mysql

Sorry, wrong PR... This was perl not python... See 219788
Comment 5 Sir l33tname 2017-06-06 15:53:25 UTC
(In reply to Bernard Spil from comment #4)
Hey maybe checkout review D11054 you can do reconnect with the new interface.
Comment 6 OlivierW 2017-07-20 15:50:18 UTC

I wanted to upgrade from MariaDB 10.1 to 10.2 but I also have the same compilation problem with poudriere.

@Sir l33tname: you mention "Connect/C" in your interface.
I had a different problem with MariaDB 10.1 and databases/mysql-connector-odbc: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218645 which was fixed by using databases/mariadb-connector-odbc 2.3.0 (sadly, not in ports, yet :-( brnrd@, I've a pull request on your github ;-) )

I'm wondering if just upgrading databases/mariadb-connector-odbc to the last 3.0 version would solve it.

PS: maybe I'm completely wrong and the problem may not be related at all.

Best Regards,
Comment 7 OlivierW 2017-07-20 15:57:24 UTC
Well, sorry, my mistake.
I was talking about "mariadb-connector-odbc", when in fact you talked about "mariadb-connector-c".
Comment 8 Bernard Spil freebsd_committer 2017-07-23 19:46:20 UTC
Created attachment 184640 [details]
svn diff for databases/py-MySQLdb

Updated patch for 10.2.7 port
Comment 9 commit-hook freebsd_committer 2017-07-24 09:43:57 UTC
A commit references this bug:

Author: brnrd
Date: Mon Jul 24 09:43:40 UTC 2017
New revision: 446515
URL: https://svnweb.freebsd.org/changeset/ports/446515

  bases/py-MySQLdb: Fix build with MariaDB 10.2.7

  With MariaDB 10.2.6 the Connect/C is updated to ~3.0. This means the C interface changed slightly and some functions are changed.

   - Replace direct struct access with accessor in _mysql.c
   - Strip Binaries
   - Remove conflict with itself

  PR:		219797
  Reviewed_by:	sunpoet, koobs, brnrd
  Submitted by:	sirl33tname@gmail.com
  Approved by:	koobs (python)
  Differential Revision:	https://reviews.freebsd.org/D11054