Bug #80539 Compilation fails when compiled against pre-5.7 version of the C API
Submitted: 27 Feb 2016 2:05 Modified: 13 Dec 2016 13:59
Reporter: David Bennett Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / C++ Severity:S2 (Serious)
Version:1.1.7 OS:Ubuntu (15.04)
Assigned to: CPU Architecture:Any
Tags: MYSQL_TYPE_JSON libmysqlclient-dev

[27 Feb 2016 2:05] David Bennett
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.
[27 Feb 2016 9:20] MySQL Verification Team
Hello David Bennett,

Thank you for the report.

Thanks,
Umesh
[13 Dec 2016 13:59] Paul DuBois
Posted by developer:
 
Noted in 1.1.8 changelog.

Connector/C++ failed to compile against a version of the MySQL C API
older than 5.7.