Bug #91841 MySQL Connector/ODBC 5.3.11 does not compile on Slackware Linux
Submitted: 31 Jul 2018 10:40 Modified: 25 Jan 2019 9:34
Reporter: Georgi Sotirov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.3.11 OS:Linux (Slackware)
Assigned to: CPU Architecture:x86 (Intel Core i7-2600 CPU @ 3.40GHz)

[31 Jul 2018 10:40] Georgi Sotirov
Description:
The yesterday released MySQL Connector/ODBC 5.3.11 does not compile on Slackware Linux. I'm getting the following errors:

[  1%] Building CXX object util/CMakeFiles/myodbc-util.dir/stringutil.cc.o
In file included from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../MYODBC_MYSQL.h:81:0,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.h:37,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.cc:36:
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:696:3: error: 'FILETIME' does not name a type
   FILETIME ft;
   ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:697:3: error: '__int64' does not name a type
   __int64 i64;
   ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:700:8: error: redefinition of 'struct timespec'
 struct timespec {
        ^
In file included from /usr/include/sys/select.h:43:0,
                 from /usr/include/sys/types.h:219,
                 from /usr/include/stdlib.h:314,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:55,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../MYODBC_MYSQL.h:81,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.h:37,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.cc:36:
/usr/include/time.h:120:8: error: previous definition of 'struct timespec'
 struct timespec
        ^
In file included from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../MYODBC_MYSQL.h:81:0,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.h:37,
                 from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/stringutil.cc:36:
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h: In function 'void set_timespec_nsec(timespec*, ulonglong)':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:726:31: error: 'union ft64' has no member named 'ft'
   GetSystemTimeAsFileTime(&tv.ft);
                               ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:726:33: error: 'GetSystemTimeAsFileTime' was not declared in this scope
   GetSystemTimeAsFileTime(&tv.ft);
                                 ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:727:12: error: 'struct timespec' has no member named 'tv'
   abstime->tv.i64= tv.i64 + (__int64)(nsec / 100);
            ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:727:23: error: 'union ft64' has no member named 'i64'
   abstime->tv.i64= tv.i64 + (__int64)(nsec / 100);
                       ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:727:30: error: '__int64' was not declared in this scope
   abstime->tv.i64= tv.i64 + (__int64)(nsec / 100);
                              ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:732:12: error: 'struct timespec' has no member named 'max_timeout_msec'
   abstime->max_timeout_msec= (long)max_timeout_msec;
            ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h: In function 'int cmp_timespec(timespec*, timespec*)':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:758:12: error: 'struct timespec' has no member named 'tv'
   if (ts1->tv.i64 > ts2->tv.i64)
            ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:758:26: error: 'struct timespec' has no member named 'tv'
   if (ts1->tv.i64 > ts2->tv.i64)
                          ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:760:12: error: 'struct timespec' has no member named 'tv'
   if (ts1->tv.i64 < ts2->tv.i64)
            ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:760:26: error: 'struct timespec' has no member named 'tv'
   if (ts1->tv.i64 < ts2->tv.i64)
                          ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h: In function 'ulonglong diff_timespec(timespec*, timespec*)':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:772:16: error: 'struct timespec' has no member named 'tv'
   return (ts1->tv.i64 - ts2->tv.i64) * 100;
                ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/util/../include/sys/my_global.h:772:30: error: 'struct timespec' has no member named 'tv'
   return (ts1->tv.i64 - ts2->tv.i64) * 100;
                              ^
util/CMakeFiles/myodbc-util.dir/build.make:62: recipe for target 'util/CMakeFiles/myodbc-util.dir/stringutil.cc.o' failed
make[2]: *** [util/CMakeFiles/myodbc-util.dir/stringutil.cc.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'util/CMakeFiles/myodbc-util.dir/all' failed
make[1]: *** [util/CMakeFiles/myodbc-util.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

There was no such problem with 5.3.10 and the same configuration:

cmake . -LA \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
        -DCMAKE_CXX_FLAGS="-O3" \
        -DCMAKE_C_COMPILER=/usr/bin/gcc \
        -DCMAKE_C_FLAGS="-O3" \
        -DCMAKE_MAKE_PROGRAM=/usr/bin/gmake \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DMYSQLCLIENT_STATIC_LINKING=OFF

How to repeat:
Try building MySQL Connector/ODBC 5.3.11 from source on Slackware Linux.

Suggested fix:
I think the problem is due to lack of check for timespec structure. In the build log for 5.3.10 I found the following:

-- Check size of struct timespec
-- Check size of struct timespec - done

Which is missing in 5.3.11
[31 Jul 2018 10:51] Georgi Sotirov
Yep, CHECK_TYPE_SIZE("struct timespec" STRUCT_TIMESPEC) is missing from configure.cmake and I do not understand why.
[31 Jul 2018 10:56] Georgi Sotirov
After adding back check for struct timespec the following errors remain:

[  3%] Built target myodbc-util
[ 27%] Built target mysql_strings
[ 27%] Building C object mysql_sys/CMakeFiles/mysql_sys.dir/my_error.c.o
In file included from /usr/src/tmp/mysql-connector-odbc-5.3.11-src/mysql_sys/my_error.c:35:0:
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/include/sys/my_base.h:212:25: error: field 'flag' has incomplete type
   enum ha_rkey_function flag;
                         ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/include/sys/my_base.h:244:2: error: #endif without #if
 #endif /* _my_base_h */
  ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/mysql_sys/my_error.c: In function 'mysys_strerror':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/mysql_sys/my_error.c:102:14: error: 'HA_ERR_FIRST' undeclared (first use in this function)
   if ((nr >= HA_ERR_FIRST) && (nr <= HA_ERR_LAST))
              ^
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/mysql_sys/my_error.c:102:14: note: each undeclared identifier is reported only once for each function it appears in
mysql_sys/CMakeFiles/mysql_sys.dir/build.make:326: recipe for target 'mysql_sys/CMakeFiles/mysql_sys.dir/my_error.c.o' failed
make[2]: *** [mysql_sys/CMakeFiles/mysql_sys.dir/my_error.c.o] Error 1
CMakeFiles/Makefile2:1554: recipe for target 'mysql_sys/CMakeFiles/mysql_sys.dir/all' failed
make[1]: *** [mysql_sys/CMakeFiles/mysql_sys.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
[31 Jul 2018 11:02] Georgi Sotirov
Check for struct timespec was removed in commit b9ab968980d495fb4f0ec46973834acc325507c1 - see https://github.com/mysql/mysql-connector-odbc/commit/b9ab968980d495fb4f0ec46973834acc32550...
[31 Jul 2018 11:08] Georgi Sotirov
For the next errors as it appears large portion from the begging of include/sys/my_base.h was wiped out with revision 434d1b73210fb830c0b34f11f85a91f1cd391ba9 - see https://github.com/mysql/mysql-connector-odbc/commit/434d1b73210fb830c0b34f11f85a91f1cd391... and I just wonder how this compiled at all on your side :-)
[31 Jul 2018 11:13] Georgi Sotirov
After fixing my_base.h contents the build continues, but the next problem is:

[  3%] Built target myodbc-util
[ 27%] Built target mysql_strings
[ 43%] Built target mysql_sys
[ 44%] Building CXX object driver/CMakeFiles/myodbc5w.dir/handle.cc.o
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/driver/handle.cc: In function 'SQLRETURN my_SQLAllocStmt(SQLHDBC, void**)':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/driver/handle.cc:496:66: error: 'init_alloc_root' was not declared in this scope
   init_alloc_root(PSI_NOT_INSTRUMENTED, &stmt->alloc_root, 32, 32);
                                                                  ^
driver/CMakeFiles/myodbc5w.dir/build.make:254: recipe for target 'driver/CMakeFiles/myodbc5w.dir/handle.cc.o' failed
make[2]: *** [driver/CMakeFiles/myodbc5w.dir/handle.cc.o] Error 1
CMakeFiles/Makefile2:144: recipe for target 'driver/CMakeFiles/myodbc5w.dir/all' failed
make[1]: *** [driver/CMakeFiles/myodbc5w.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
[31 Jul 2018 11:32] MySQL Verification Team
Hello Georgi,

Thank you for the report!

Thanks,
Umesh
[31 Jul 2018 11:44] Georgi Sotirov
There's a missing header for the last problem. Do you know which one exactly?
[2 Aug 2018 11:23] Georgi Sotirov
I wasn't able to figure out (and had not more time to spare) the right header for driver/handle.cc, so I just added init_alloc_root's prototype. The next problem was:

[ 49%] Building CXX object driver/CMakeFiles/myodbc5w.dir/utility.cc.o
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/driver/utility.cc: In function 'void myodbc_net_end(NET*)':
/usr/src/tmp/mysql-connector-odbc-5.3.11-src/driver/utility.cc:4275:20: error: 'my_free' was not declared in this scope
   my_free(net->buff);
                    ^
driver/CMakeFiles/myodbc5w.dir/build.make:494: recipe for target 'driver/CMakeFiles/myodbc5w.dir/utility.cc.o' failed

Which I fixed by including mysql/service_mysql_alloc.h and was finally able to built the new release successfully.

All my modifications are summarized in Pull Request #3 for MySQL Connector/ODBC in GitHub (see https://github.com/mysql/mysql-connector-odbc/pull/3 ).
[19 Sep 2018 7:43] Bogdan Degtyariov
Posted by developer:
 
This bug is considered a duplicate of 28609434, which explains the reasons for the failure.
The base bug is fixed. No need to document this bug as a duplicate.
[19 Sep 2018 8:18] Georgi Sotirov
Where could I find bug 28609434 to read about "the reasons for the failure"? When there would be a new release with the fixes?
[21 Sep 2018 4:32] Bogdan Degtyariov
Hi Georgi,

Sorry, this public bug report got closed by a bug bot after updating the internal bug. We appreciate your report and efforts to bring the attention to this issue.

The bigger problem was the breakage of the dynamic linking in ODBC Driver 5.3.11. That is why we had to create another bug report.

To restore the dynamic linking the internal mysql headers for ODBC Driver 5.3 had to be updated from the last version of MySQL Server 5.7 headers. Also, the back-merge from ODBC Driver 8.0 had to be done.

The fix will be available in the version 5.3.12. Unfortunately, I am not at liberty to disclose the date of this release before the official announcement is made.

I hope it gives some explanations...
[24 Sep 2018 17:42] Georgi Sotirov
Well, thanks for providing some explanations at least. It's not good that bug information is hidden, but that's how it goes nowadays...
[25 Jan 2019 9:34] Georgi Sotirov
According to the release notes for 5.3.12 (see https://dev.mysql.com/doc/relnotes/connector-odbc/en/news-5-3-12.html ) it should have been released on 2019-01-21, but when I go to the downloads page (see https://dev.mysql.com/downloads/connector/odbc/ ) I only find 5.3.11 as the latest version from the 5.3 series. Trying to download directly from https://dev.mysql.com/get/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.12-src.tar... (e.g. in case download page is not updated) returns "ERROR 404: Not Found". So could you please, shed some light whether 5.3.12 would be released and when?