Bug #106899 MySQL-Workbench FTBFS with unixodbc 2.3.9
Submitted: 3 Apr 2022 10:20 Modified: 22 Mar 2023 7:11
Reporter: Dmitry Smirnov Email Updates:
Status: QA review Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:8.0.32 OS:Debian (unstable)
Assigned to: Marcin Marek CPU Architecture:Other (x64)

[3 Apr 2022 10:20] Dmitry Smirnov
Description:
M-W FTBFS on amd64 with unixodbc 2.3.9:

```
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::end_select_table()': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:975: undefined reference to `SQLFreeHandle' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::~ODBCCopyDataSource()': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:679: undefined reference to `SQLFreeHandle' 
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:678: undefined reference to `SQLFreeHandle' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function ConnectionError::process[abi:cxx11](short] short, void*)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:254: undefined reference to `SQLGetDiagRec' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::get_wchar_buffer_data(RowBuffer&, int)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:694: undefined reference to `SQLGetData' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::get_date_time_data(RowBuffer&, int, int)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:741: undefined reference to `SQLGetData' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::get_char_buffer_data(RowBuffer&, int)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:767: undefined reference to `SQLGetData' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::get_geometry_buffer_data(RowBuffer&, int)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:794: undefined reference to `SQLGetData' 
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::fetch_row(RowBuffer&)': 
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:982: undefined reference to `SQLFetch'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1155: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1117: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1073: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:991: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1027: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1013: undefined reference to `SQLGetDiagRec'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1091: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:1081: undefined reference to `SQLGetData'
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::count_rows(...)':
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:829: undefined reference to `SQLAllocHandle'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:866: undefined reference to `SQLExecDirect'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:870: undefined reference to `SQLFetch'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:871: undefined reference to `SQLGetData'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:873: undefined reference to `SQLFreeHandle'
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::ODBCCopyDataSource(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:656: undefined reference to `SQLAllocHandle'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:659: undefined reference to `SQLSetConnectAttr'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:667: undefined reference to `SQLDriverConnect'
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/copytable.cpp.o: in function `ODBCCopyDataSource::begin_select_table(...)':
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:891: undefined reference to `SQLAllocHandle'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:914: undefined reference to `SQLExecDirect'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:918: undefined reference to `SQLNumResultCols'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:935: undefined reference to `SQLDescribeCol'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:942: undefined reference to `SQLColAttribute'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/copytable.cpp:945: undefined reference to `SQLColAttribute'
/usr/bin/ld: CMakeFiles/wbcopytables-bin.dir/copytable/main.cpp.o: in function `main':
./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/main.cpp:877: undefined reference to `SQLAllocHandle'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/main.cpp:878: undefined reference to `SQLSetEnvAttr'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/main.cpp:820: undefined reference to `SQLAllocHandle'
/usr/bin/ld: ./obj-x86_64-linux-gnu/plugins/migration/./plugins/migration/copytable/main.cpp:821: undefined reference to `SQLSetEnvAttr'
collect2: error: ld returned 1 exit status
make[4] *** [plugins/migration/CMakeFiles/wbcopytables-bin.dir/build.make:163: plugins/migration/wbcopytables-bin] Error 1
```

(Compilation succeeds with an older version of UnixODBS 2.3.6).

How to repeat:
Build in Debian "unstable".
[5 May 2022 5:50] Dmitry Smirnov
Still a problem on 8.0.29. Please prioritise.

FYI this problem is holding back progress in Debian. It would be great if this bug could be fixed in (next minor) release. Thanks.
[17 Nov 2022 12:26] MySQL Verification Team
Hello Dmitry Smirnov,

Thank you for the bug report.
Could you please try with the latest version i.e 8.0.31?

Regards,
Ashwini Patil
[22 Nov 2022 13:01] Dmitry Smirnov
8.0.31 did not even get that far as it FTBFS as follows:

```
/build/mysql-workbench-8.0.31+dfsg/library/sql.parser/source/myx_statement_parser.cpp: In member function 'void mysql_parser::MyxStatementParser::process(std::istream&, mysql_parser::process_sql_statement_callback, void*, int)': 
/build/mysql-workbench-8.0.31+dfsg/library/sql.parser/source/myx_statement_parser.cpp:159:5: error: 'state' may be used uninitialized [-Werror=maybe-uninitialized] 
  159 |     switch(state) { 
      |     ^~~~~~ 
/build/mysql-workbench-8.0.31+dfsg/library/sql.parser/source/myx_statement_parser.cpp:145:15: note: 'state' was declared here 
  145 |   ParserState state= start, prevState; 
      |               ^~~~~ 
cc1plus: all warnings being treated as errors 
make[4] *** [library/sql.parser/source/CMakeFiles/sqlparser.dir/build.make:429: library/sql.parser/source/CMakeFiles/sqlparser.dir/myx_statement_parser.cpp.o] Error 1 
```

With `-Wno-error=maybe-uninitialized` compilation progressed a bit further then FTBFS as follows:

```
/mnt/01/src/m-w/mysql-workbench-community-8.0.31-src/library/base/file_utilities.cpp:118:28: error: ‘g_pattern_spec_match_string’ was not declared in this scope; did you mean ‘g_pattern_match_string’?                                                                                                                                                        
  118 |       bool match_string  = g_pattern_spec_match_string(pat, filename); 
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      |                            g_pattern_match_string 
make[4] *** [library/base/CMakeFiles/wbbase.dir/build.make:149: library/base/CMakeFiles/wbbase.dir/file_utilities.cpp.o] Error 1 
```

---

Worst of all, Ashwini Patil, you are wasting my time by doing support on me: comparing to 8.0.30 (which FTBFS just like 8.0.29), 8.0.31 have no ODBC-related changes in source. As far as I can see, nobody even tried to address this issue yet...  :(
[14 Mar 2023 12:51] Marcin Marek
Build fixed, we are using that libs

Dependencies:
boost_1_73_0
connector-cpp-8.0.33
mysql-8.0.33
antlr-4.9.1-jar
antlr4-cpp-runtime-4.9.1
gdal-3.2.1-gpl
iodbc-3.52.14
libssh-0.9.6
pyodbc-4.0.30
sqlite-3.39.2
vsqlitepp-0.3.13
[14 Mar 2023 12:54] Marcin Marek
Build fixed on debian 11
[15 Mar 2023 8:21] Dmitry Smirnov
Adjusted affected version.
[15 Mar 2023 8:26] Dmitry Smirnov
Marcin Marek, would you care to address this issue properly please?
(Or escalate to someone who can read/understand issue description.)

Build was NOT broken on Debian 11 which have unixodbc-dev 2.3.6.

However M-W 8.0.32 FTBFS in "unstable" and "testing" where we have newer unixodbc-dev 2.3.11.
[15 Mar 2023 8:42] Dmitry Smirnov
About building with iODBC:

1) iodbc-3.52.14 is NOT available in Debian.
2) libiodbc2-dev in Debian is 3.52.9
3) Debian builds with UnixODBC which is better supported.
4) We can't build with iODBC because unixodbc-dev conflicts with libiodbc2-dev (hence only one can be installed at a time) and another M-W dependency libgdal-dev depends on unixodbc-dev.
5) Currently we have libgdal-dev 3.6.2 in Debian "testing" and "unstable".
6) All software on Debian is built from packages from official Debian repositories.
7) I'm a Debian maintainer of MySQL-Workbench in Debian so I can't just use some random releases of dependency libraries.
8) Handling of this bug report is very unprofessional.
[17 Mar 2023 13:40] Marcin Marek
I can repeat the problem with unixodbc 2.3.11 (observed same issue on ubuntu 22.10, unixodbc 2.3.11)
Modified FindUNIXODBC.cmake file in build/cmake folder

cmake used to build 
cmake   -DCMAKE_BUILD_TYPE=Release
        -DMySQL_CONFIG_PATH=/usr/bin/mysql_config
        -DUSE_BUNDLED_MYSQLDUMP=1
        -DMySQLCppConn_LIBRARIES="-L/home/marcinm/develop/workbench/bundle/lib -lmysqlcppconn"
        -DMySQLCppConn_INCLUDE_DIR=/home/marcinm/develop/workbench/bundle/include/cppconn
        -DGDAL_INCLUDE_DIR=/home/marcinm/develop/workbench/bundle/include
        -DGDAL_LIBRARY=/home/marcinm/develop/workbench/bundle/lib/libgdal.so
        -DUNIXODBC_INCLUDE_PATH=/usr/inclue/
        -DUNIXODBC_LIBRARIES="-L/usr/lib/x86_64-linux-gnu -lodbc"
        -DUSE_UNIXODBC=ON 
        -DRAPIDJSON_INCLUDE_DIR=/home/marcinm/develop/workbench/bundle/include
        -DVSQLITE_INCLUDE_DIR=/home/marcinm/develop/workbench/bundle/include
        -DVSQLITE_LIBRARIES="-L/home/marcinm/develop/workbench/bundle/lib -lvsqlitepp"
        -Dlibssh_DIR=/home/marcinm/develop/workbench/bundle/lib/cmake/libssh
        -DANTLR4_INCLUDE_DIR=/home/marcinm/develop/workbench/bundle/include
        -DANTLR4_LIBRARIES="-L/home/marcinm/develop/workbench/bundle/lib -lantlr4-runtime"
        -DWITH_ANTLR_JAR=/home/marcinm/develop/workbench/bundle/bin/antlr-4.9.1-complete.jar
        -DBOOST_ROOT=/home/marcinm/develop/workbench/bundle/include
        -DBoost_NO_BOOST_CMAKE=ON
        ../master/

Fixed in 8.0.33 release (can be that this cmake settings will fix the issue)
        -DUNIXODBC_INCLUDE_PATH=/usr/inclue/
        -DUNIXODBC_LIBRARIES="-L/usr/lib/x86_64-linux-gnu -lodbc"
        -DUSE_UNIXODBC=ON
[22 Mar 2023 7:11] Dmitry Smirnov
Thanks, with `-DUNIXODBC_LIBRARIES="-lodbc"` workaround, build finally succeeded for a first time in over a year, so I've managed to upload 8.0.32 as the official package: https://buildd.debian.org/status/package.php?p=mysql-workbench&suite=sid

It seems that with `-DUSE_UNIXODBC=ON` it should not be necessary to have explicit `-DUNIXODBC_LIBRARIES="-lodbc"` so perhaps that could be addressed in CMAKE scripts?

Also, since package is built on various architectures it would be wrong to hard-code architecture-specific paths in `-L` arguments to `-DUNIXODBC_LIBRARIES`. Build works well without that.

FYI the Debian packaging is here: https://salsa.debian.org/debian/mysql-workbench

Thanks!