Bug 62631

Summary: apr-util-1.6.1 fail to compile with mysql8
Product: APR Reporter: Please <support>
Component: APR-utilAssignee: Apache Portable Runtime bugs mailinglist <bugs>
Status: NEW ---    
Severity: normal CC: petr.sumbera, support
Priority: P2    
Version: 1.6.3   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: this fix two problems - one in mysql library and second in m4 build script.
Minimal patch file needed for MySQL 8.

Description Please 2018-08-17 08:07:38 UTC
Created attachment 36097 [details]
this fix two problems - one in mysql library and second in m4 build script.

It looks like it is a APR1 conflict with Mysql80-client 

(build and install apr manually)
./configure --with-apr=../apr-1.6.3/ --with-mysql 

apr-util configure gives this with mysql80-client 

....
checking for mysql_config... /usr/local/bin/mysql_config
  adding "-I/usr/local/include/mysql" to CPPFLAGS
  setting LIBS to "-L/usr/local/lib/mysql -lmysqlclient -pthread -lz -lm -lrt -lexecinfo -lssl -lcrypto"
checking for mysql.h... no
checking for mysql/mysql.h... no
...

when mysql57-client gives:
....
checking for mysql_config... /usr/local/bin/mysql_config
  adding "-I/usr/local/include/mysql" to CPPFLAGS
  setting LIBS to "-L/usr/local/lib/mysql -lmysqlclient -pthread -lz -lm -lrt -lexecinfo -lssl -lcrypto"
checking for mysql.h... yes
checking for mysql_init in -lmysqlclient... yes
checking for my_global.h... yes
....

Two changes:
1. add c99 my_bool to apr_dbd_mysql.c
2. update build/dbd.m4 to not check agains my_global.h 


For more details please see bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230538
Comment 1 Bernard Spil 2018-10-24 16:44:10 UTC
I'm trying to fix this as team-member of the apache@ team in FreeBSD which is also the maintainer of the APR packages.

Looks like this issue is NOT FreeBSD specific, MySQL 8 ships different headers than 5.x. The autoconf needs some 

Looking at the config.log I see
> configure:20376: checking for mysql.h
> configure:20376: cc -c -O2 -fno-strict-aliasing -pipe -march=native  -DLIBICONV_PLUG -fstack-protector  -I/usr/ports/devel/apr1/work/apr-1.6.5/include -I/usr/local/include -I/usr/local/include/mysql -DHAVE_MYSQL_H -I/usr/local/include -DLIBICONV_PLUG conftest.c >&5
> conftest.c:21:10: fatal error: 'my_global.h' file not found
> #include <my_global.h>
>          ^~~~~~~~~~~~~
> 1 error generated.
> configure:20376: $? = 1
> configure: failed program was:

MySQL 8.0 does not ship a my_global.h, and APR decides that there's no usable MySQL.
There's a my_global.h in 
   https://github.com/mysql/mysql-server/tree/5.7/include 
but not in 
   https://github.com/mysql/mysql-server/tree/8.0/include

The requirement for my_global.h was introduced in 2008
https://svn.apache.org/viewvc?view=revision&revision=747625
Comment 2 Bernard Spil 2023-04-01 12:17:06 UTC
(In reply to Please from comment #0)
> Created attachment 36097 [details]
> this fix two problems - one in mysql library and second in m4 build script.
> 
> It looks like it is a APR1 conflict with Mysql80-client 
> 
> (build and install apr manually)

> 
> Two changes:
> 1. add c99 my_bool to apr_dbd_mysql.c
> 2. update build/dbd.m4 to not check agains my_global.h 
> 
> 
> For more details please see bug:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230538

Can you please check with 1.6.3? The `dbd.m4` part of the patch seems no longer required, the my_bool is still an issue.
Comment 3 Petr Sumbera 2023-05-31 07:54:23 UTC
I can build APR-util 1.6.3 with MySQL 8.0.33. Just needed my_bool part of of attached patch file.
Comment 4 Petr Sumbera 2023-05-31 12:15:19 UTC
There is also problem with MySQL 8 and dbd test. It fails with:

  Failed to load driver file apr_dbd_mysql.so

This is due calling my_init which is no longer wanted since 8.0.2:

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-2.html

Following fixes the issue:

--- dbd/apr_dbd_mysql.c
+++ dbd/apr_dbd_mysql.c
@@ -1262,7 +1262,7 @@                                                                          
                                                                                               
 static void dbd_mysql_init(apr_pool_t *pool)                                                  
 {                                                                                             
-#if MYSQL_VERSION_ID < 100000                                                                 
+#if MYSQL_VERSION_ID < 80002                                                                  
     my_init();                                                                                
 #endif                                                                                        
     mysql_thread_init();
Comment 5 Petr Sumbera 2023-05-31 12:19:43 UTC
Created attachment 38568 [details]
Minimal patch file needed for MySQL 8.