Description:
When compiling version 1.1.7 of the MySQL Connector/C++ against a MySQL C API prior to 5.7, the compilation fails due to the reference to MYSQL_TYPE_JSON.
How to repeat:
(Assuming that mysql_config -fno-rtti patch has already been applied)
On Ubuntu 15.04:
~/mysql-connector-cpp$ sudo apt-get install -y libmysqlclient-dev
~/mysql-connector-cpp$ cmake .
~/mysql-connector-cpp$ make
Results in:
Scanning dependencies of target mysqlcppconn
[ 1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.cpp.o
...
[ 8%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_resultbind.cpp.o
/root/git/MetricBench.perclab/build/mysql-connector-cpp/driver/mysql_resultbind.cpp: In function ‘sql::mysql::st_buffer_size_type sql::mysql::allocate_buffer_for_field(const MYSQL_FIELD*)’:
/root/git/MetricBench.perclab/build/mysql-connector-cpp/driver/mysql_resultbind.cpp:89:10: error: ‘MYSQL_TYPE_JSON’ was not declared in this scope
case MYSQL_TYPE_JSON:
^
driver/CMakeFiles/mysqlcppconn.dir/build.make:284: recipe for target 'driver/CMakeFiles/mysqlcppconn.dir/mysql_resultbind.cpp.o' failed
make[2]: *** [driver/CMakeFiles/mysqlcppconn.dir/mysql_resultbind.cpp.o] Error 1
CMakeFiles/Makefile2:92: recipe for target 'driver/CMakeFiles/mysqlcppconn.dir/all' failed
make[1]: *** [driver/CMakeFiles/mysqlcppconn.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2
Suggested fix:
This can be fixed by checking for the MYSQL_TYPE_JSON at compile time and optionally including those switch/case conditionals only if detected in the underlying C API.