[CONC-200] Lack of include files compatibility for applications written for libmysqlclient Created: 2016-09-03  Updated: 2020-09-13

Status: Open
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.0.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Floris Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The connector was advertised in the past as a libmysqlclient drop-in replacement.
However you seem to be renaming include files in 3.x which breaks source code compatibility with the majority of programs that was written for that.
It this intended?

Dovecot:

==
driver-mysql.c:24:20: fatal error: errmsg.h: No such file or directory
==

PHP:

==
php-7.0.9/ext/mysqli/php_mysqli_structs.h:63:23: fatal error: my_global.h: No such file or directory
compilation terminated.
==

(yes, I know I could use mysqlnd instead, but that's not the point)

Kodi:

==
mysqldataset.cpp:34:26: fatal error: mysql/errmsg.h: No such file or directory
==

Along with other include file related errors.
E.g. Qt 4, Qt 5 and poco library are missing the definition for my_ulonglong:

==
drivers/mysql/qsql_mysql.cpp:562:5: error: ‘my_ulonglong’ was not declared in this scope
my_ulonglong numRows;

==
../../../sql/drivers/mysql/qsql_mysql.cpp:553:5: error: ‘my_ulonglong’ was not declared in this scope
my_ulonglong numRows;
==
src/StatementExecutor.cpp: In member function ‘void Poco::Data::MySQL::StatementExecutor::execute()’:
src/StatementExecutor.cpp:110:2: error: ‘my_ulonglong’ was not declared in this scope
my_ulonglong affectedRows = mysql_affected_rows(_pSessionHandle);
==



 Comments   
Comment by Daniel Black [ 2020-09-12 ]

mysql8 drops my_global.h so I think that's ok. Looking at PHP upstream on https://github.com/grooverdan/php-src/commit/32b6d708c93d47730ba340affaf70f10e15bec17

errmsg.h is still in 5.6, 5.7 and 8.0 and not mariadb.

my_ulonglong is in mysql.h in mariadb now, however with a differing definition.

mysql-5.6.49-linux-glibc2.12-x86_64/include/mysql.h

#ifndef MY_GLOBAL_INCLUDED
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif
#endif

mariadb-10.5.6/include/mysql/mysql.h

#if !defined (_global_h) && !defined (MY_GLOBAL_INCLUDED) /* If not standard header */
#include <sys/types.h>
typedef char my_bool;
typedef unsigned long long my_ulonglong;

The right on is here however this isn't the included file:

mariadb-10.5.6/include/mysql/server/mysql.h

#ifndef MY_GLOBAL_INCLUDED
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
#elif defined (__WIN__)
typedef unsigned __int64 my_ulonglong;
#else
typedef unsigned long long my_ulonglong;
#endif

These differences cause the compile warning:

php-7.3 compile warning

  version=mariadb-10.5.6; ../php-src/configure --enable-debug --with-mysqli=/usr/local/$version/bin/mysql_config   --with-pdo-mysql=/usr/local/$version
 
 
 
/home/dan/repos/php-src/ext/mysqli/mysqli.c: In function ‘php_mysqli_fetch_into_hash_aux’:
/home/dan/repos/php-src/ext/mysqli/php_mysqli_structs.h:179:25: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘my_ulonglong’ {aka ‘long long unsigned int’} [-Wformat=]
  179 | #define MYSQLI_LLU_SPEC "%" PRIu64
      |                         ^~~
/home/dan/repos/php-src/ext/mysqli/mysqli.c:1176:94: note: in expansion of macro ‘MYSQLI_LLU_SPEC’
 1176 |     snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
      |                                                                                              ^~~~~~~~~~~~~~~
In file included from /home/dan/repos/php-src/main/php_stdint.h:72,
                 from /home/dan/repos/php-src/Zend/../TSRM/TSRM.h:23,
                 from /home/dan/repos/php-src/Zend/zend_portability.h:47,
                 from /home/dan/repos/php-src/Zend/zend_types.h:25,
                 from /home/dan/repos/php-src/Zend/zend.h:27,
                 from /home/dan/repos/php-src/main/php.h:33,
                 from /home/dan/repos/php-src/ext/mysqli/mysqli.c:27:
/usr/include/inttypes.h:105:34: note: format string is defined here
  105 | # define PRIu64  __PRI64_PREFIX "u"
In file included from /home/dan/repos/php-src/ext/mysqli/mysqli.c:32:
/home/dan/repos/php-src/ext/mysqli/php_mysqli_structs.h:180:24: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘my_ulonglong’ {aka ‘long long unsigned int’} [-Wformat=]
  180 | #define MYSQLI_LL_SPEC "%" PRId64
      |                        ^~~
/home/dan/repos/php-src/ext/mysqli/mysqli.c:1176:112: note: in expansion of macro ‘MYSQLI_LL_SPEC’
 1176 |     snprintf(tmp, sizeof(tmp), (mysql_fetch_field_direct(result, i)->flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval);
      |                                                                                                                ^~~~~~~~~~~~~~
In file included from /home/dan/repos/php-src/main/php_stdint.h:72,
                 from /home/dan/repos/php-src/Zend/../TSRM/TSRM.h:23,
                 from /home/dan/repos/php-src/Zend/zend_portability.h:47,
                 from /home/dan/repos/php-src/Zend/zend_types.h:25,
                 from /home/dan/repos/php-src/Zend/zend.h:27,
                 from /home/dan/repos/php-src/main/php.h:33,
                 from /home/dan/repos/php-src/ext/mysqli/mysqli.c:27:
/usr/include/inttypes.h:57:34: note: format string is defined here

Comment by Daniel Black [ 2020-09-13 ]

Edit: I was wrong about my_ulonglong warnings - they happen in [MySQL-5.6 too](https://travis-ci.org/github/grooverdan/php-src/jobs/726539689#L983)

And errmsg.h is there in server and connector-c releases.:

$ find /usr/local/m* -name errmsg.h
/usr/local/mariadb-10.5.6/include/mysql/errmsg.h
/usr/local/mariadb-10.5.6/include/mysql/server/errmsg.h
/usr/local/mariadb-connector-c-3.1.9-ubuntu-xenial-amd64/include/mariadb/errmsg.h
/usr/local/mysql-5.6.49-linux-glibc2.12-x86_64/include/errmsg.h
/usr/local/mysql-5.7.31-linux-glibc2.12-x86_64/include/errmsg.h
/usr/local/mysql-8.0.21-linux-glibc2.12-x86_64/include/errmsg.h

Generated at Thu Feb 08 03:03:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.