artyom-beilis / cppcms

CppCMS Framework
Other
443 stars 107 forks source link

cppdb and MySQL 8 #70

Closed dreaming-augustin closed 1 year ago

dreaming-augustin commented 4 years ago

The mysql back end no longer compiles with the latest MySQL 8.

There are two sets of changes to make.

my_bool

The first one is straight forward: the type my_bool has been removed in MySQL 8.0. Simply replace all instances of my_bool with bool in drivers/mysql_backend.cpp

embedded server

The second one is more problematic: MySQL removed the embedded server.

See announcement here: MySQL 8.0: Retiring support for libmysqld https://mysqlserverteam.com/mysql-8-0-retiring-support-for-libmysqld/

Old documentation: https://dev.mysql.com/doc/refman/5.7/en/libmysqld.html

Removal notice: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-1.html#mysqld-8-0-1-deprecation-removal

During compilation, we get the following errors as a result:

cppdb/drivers/mysql_backend.cpp:1203:22: error: ‘MYSQL_OPT_GUESS_CONNECTION’ was not declared in this scope;
cppdb/drivers/mysql_backend.cpp:1240:21: error: ‘MYSQL_SET_CLIENT_IP’ was not declared in this scope;
cppdb/drivers/mysql_backend.cpp:1245:22: error: ‘MYSQL_OPT_SSL_VERIFY_SERVER_CERT’ was not declared in this scope;
cppdb/drivers/mysql_backend.cpp:1250:22: error: ‘MYSQL_OPT_USE_EMBEDDED_CONNECTION’ was not declared in this scope;
cppdb/drivers/mysql_backend.cpp:1255:22: error: ‘MYSQL_OPT_USE_REMOTE_CONNECTION’ was not declared in this scope;
cppdb/drivers/mysql_backend.cpp:1281:22: error: ‘MYSQL_SECURE_AUTH’ was not declared in this scope;

I do not use the embedded mysql server, so for me, the hackish way to get cppdb to compile was to use include guards:

     #if MYSQL_VERSION_ID < 80000
     ....
    #endif

like this:

                #if MYSQL_VERSION_ID < 80000
                if(ci.has("secure_auth")) {
                        if(unsigned secure = ci.get("secure_auth", 1)) {
                                bool value = secure;
                                mysql_set_option(MYSQL_SECURE_AUTH, &value);
                        }
                }
                #endif

Obviously, a proper fix would require much more extensive changes, with more include guards, or a complete removal of all the code related to the embedded mysql server.

I hope it helps some.

dreaming-augustin commented 4 years ago

I attached the relevant patches to the related Gentoo issue: https://bugs.gentoo.org/710132