Bug 219797

Summary: databases/py-MySQLdb: Fails to build with MariaDB 10.2.6
Product: Ports & Packages Reporter: Sir l33tname <sirl33tname>
Component: Individual Port(s)Assignee: Bernard Spil <brnrd>
Status: Closed FIXED    
Severity: Affects Many People CC: brnrd, koobs, olivierw1+bugzilla-freebsd, python, sirl33tname
Priority: --- Keywords: needs-qa, patch
Version: LatestFlags: bugzilla: maintainer-feedback? (python)
koobs: maintainer-feedback? (brnrd)
koobs: merge-quarterly?
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D11054
Attachments:
Description Flags
svn diff for databases/p5-DBD-mysql
none
svn diff for databases/py-MySQLdb none

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 freebsd_triage 2017-06-06 08:32:28 UTC
Created attachment 183258 [details]
svn diff for databases/p5-DBD-mysql

Hi,

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 freebsd_triage 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
Hello,

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,
Olivier
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 freebsd_triage 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 freebsd_triage 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

Log:
  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
   - Add LICENSE/LICENSE_FILE
   - 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

Changes:
  head/databases/py-MySQLdb/Makefile
  head/databases/py-MySQLdb/files/patch-_mysql.c