Bug #69700 | MYSQL_SERVER_VERSION value missmatch with mysql-connector-c but not in server | ||
---|---|---|---|
Submitted: | 9 Jul 2013 16:48 | Modified: | 11 Apr 2014 13:38 |
Reporter: | Ian Flynn | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / C | Severity: | S3 (Non-critical) |
Version: | 6.1.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[9 Jul 2013 16:48]
Ian Flynn
[10 Jul 2013 8:50]
MySQL Verification Team
what is the reason to have a separate version of mysql-connector-c that is not the same as the client/server version on which it is based?
[16 Jul 2013 17:34]
MySQL Verification Team
Thank you for the bug report. c:\tmp>bug69700a.exe Client Info: 5.6.12 Done c:\tmp>bug69700a.exe Client Info: 6.1.0 Done c:\tmp>type c:\mysql-connector-c-6.1.0-winx64\include\mysql_version.h | findstr MYSQL_SERVER_VERSION #define MYSQL_SERVER_VERSION "5.7.2-m12" c:\tmp>
[26 Nov 2013 10:22]
Rafal Somla
Posted by developer: Refined problem description =========================== It is not possible to write portable code which checks version of libmysql at runtime that would work with both libmysql from server distribution and with Connector/C. If using server's version of the library the check might look as follows: if (mysql_get_client_version() < MYSQL_VERSION_ID) { // Error: we use too old version of libmysql } This code will not work with Connector/C for which mysql_get_client_version() returns something like 6XXYY and MYSQL_VERSION_ID is 506ZZ. In Connector/C one needs to use the following check instead: if (mysql_get_client_version() < LIBMYSQL_VERSION_ID) { // Error: we use too old version of libmysql } But this code will not build with server sources because there LIBMYSQL_VERSION_ID is not defined. Currently there is no portable way to write such a check so that the code would compile and work correctly both with server sources and with c/C. Proposed solution ================= Introduce LIBMYSQL_VERSION_ID constant to server sources. Here it will be equal to MYSQL_VERSION_ID. Thus the second variant of version check would work for both server and c/C. Note: we would still have a problem that code which contains such checks and is built with c/C sources will refuse to work with server's version of libmysql - only c/C version will pass the check because c/C's version number is higher than server version number.
[11 Apr 2014 13:38]
Paul DuBois
Noted in MySQL 5.7.4 and Connector/C 6.1.3 changelogs. The mysql_version.h file defines two new macros, LIBMYSQL_VERSION and LIBMYSQL_VERSION_ID, that indicate the string and numeric forms of the client library version. * In the client library included with MySQL Server distributions, these macros have the same values as MYSQL_SERVER_VERSION and MYSQL_VERSION_ID. For example, in MySQL 5.7.4, MYSQL_SERVER_VERSION and LIBMYSQL_VERSION are "5.7.4-m14", and MYSQL_VERSION_ID and LIBMYSQL_VERSION_ID are 50704. * In the client library included with Connector/C distributions, MYSQL_SERVER_VERSION and MYSQL_VERSION_ID have the values of the MySQL version on which the Connector/C distribution is based, whereas LIBMYSQL_VERSION and LIBMYSQL_VERSION_ID indicate the Connector/C version. For example, Connector/C 6.1.3 is based on MySQL 5.7.4, so MYSQL_SERVER_VERSION and MYSQL_VERSION_ID have values of "5.7.4-m14" and 50704, whereas LIBMYSQL_VERSION and LIBMYSQL_VERSION_ID have values of "6.1.3" and 60103. In addition, the mysql_get_client_info() and mysql_get_client_version() C API functions in the client library now return values that reflect the type of distribution that provides the client library: * In MySQL distributions, mysql_get_client_info() returns MYSQL_SERVER_VERSION and mysql_get_client_version() returns MYSQL_VERSION_ID. This is the same as before. * In Connector/C distributions, mysql_get_client_info() returns LIBMYSQL_VERSION and mysql_get_client_version() returns LIBMYSQL_VERSION_ID. Previously, these functions returned the MySQL version, the same as in MySQL distributions.