| Bug #102308 | Compilation error for Boolean literal in sql/mysqld.cc with MySQL 8.0.23 | ||
|---|---|---|---|
| Submitted: | 20 Jan 2021 7:41 | Modified: | 22 Jan 2021 19:05 |
| Reporter: | Georgi Sotirov | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
| Version: | 8.0.23 | OS: | Linux (Slackware) |
| Assigned to: | CPU Architecture: | x86 | |
[21 Jan 2021 8:38]
Tor Didriksen
Posted by developer:
We removed my_bool and TRUE/FALSE almost four years ago:
commit f870e0fd12ed906569c8dcabd9da23c1a1fc6d7f
Author: Steinar H. Gunderson <steinar.gunderson@oracle.com>
Date: Fri Feb 24 13:47:08 2017 +0100
Bug #25597667: REMOVE MY_BOOL
Replace TRUE with true and FALSE with false, with some notable exceptions:
- In SQL, where we keep talking about TRUE and FALSE.
- In comments that talk about SQL.
- In string literals, especially in the parser and such.
- In InnoDB, which has its own �<80><9C>ibool�<80><9D> type and TRUE/FALSE definitions.
- In NDB, which get their own TRUE and FALSE definitions in ndb_global.h.
But evidently, some TRUE/FALSE instances have managed to creep in after that.
The build didn't break, since there are plenty of Unix system headers which do:
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
[21 Jan 2021 8:53]
Tor Didriksen
Posted by developer: It seems mysqld.cc got the definition of TRUE from extra/icu/source/common/unicode/umachine.h uncommenting the defines there, I get sql/mysqld.cc:7093:32: error: ‘TRUE’ was not declared in this scope 7093 | my_getopt_skip_unknown = TRUE; our bundled ICU sources are at version 65 However, recent ICU versions no longer define TRUE and FALSE, so -DWITH_ICU=system will break the build. Apparently there is an -DU_DEFINE_FALSE_AND_TRUE=1 you can add to CMAKE_CXX_FLAGS to unbreak the build.
[21 Jan 2021 9:12]
Georgi Sotirov
Thanks for the detailed explanation Tor. The ICU version on the system I am building is 68.2, but although I presumed TRUE/FALSE could have come from some header I did not suspect ICU at all. Anyway, do not you think that it is better to fix MySQL's source sql/mysqld.cc, instead of relying on headers from external libraries and -D flags to provide TRUE/FALSE macros? As I wrote in the description in sql/mysqld.cc there are other occasions where my_getopt_skip_unknown is properly set with true or false, so it only remains to fix the problematic line. The simple patch I gave in "Suggested fix" solved the problem for me and IMHO is the right solution.
[21 Jan 2021 9:22]
Tor Didriksen
Yes, of course mysql source should be fixed. A patch will show up in 8.0.24 I was just showing some workarounds for you.
[21 Jan 2021 12:36]
Georgi Sotirov
Ah, OK. Thanks again Tor.
[22 Jan 2021 19:05]
Paul DuBois
Posted by developer: Fixed in 8.0.24. Use of the symbol TRUE in the source resulted in a build failure on some platforms. This was replaced by true.

Description: When trying to compile MySQL 8.0.23 on Slackware Linux current with GCC 10.2.0 I get the following error: /tmp/mysql-8.0.23/sql/mysqld.cc: In function ‘int mysqld_main(int, char**)’: /tmp/mysql-8.0.23/sql/mysqld.cc:7041:30: error: ‘TRUE’ was not declared in this scope 7041 | my_getopt_skip_unknown = TRUE; | ^~~~ The problem seems to be the usage of wrong C++ Boolean literal - should be true instead of TRUE (see https://github.com/mysql/mysql-server/blob/8.0/sql/mysqld.cc#L7041). Please, consider that in the same source for the same global variable the correct Boolean literals are used. P.S. The same problem is reproducible on i686 and x86_64 and I guess also other architectures. How to repeat: 1. Get MySQL 8.0.23 source archive from https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23.tar.gz wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23.tar.gz 2. Unpack with tar -xvf mysql-8.0.23.tar.gz 3. Configure with the following commands: mkdir -p build; cd build cmake .. -LAH \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=gcc \ -DCMAKE_C_FLAGS="-O3 -march=i686 -mtune=i686 -fPIC" \ -DCMAKE_CXX_COMPILER=g++ \ -DCMAKE_CXX_FLAGS="-O3 -march=i686 -mtune=i686 -fPIC" \ -DCMAKE_MAKE_PROGRAM=gmake \ -DDOWNLOAD_BOOST=ON \ -DFEATURE_SET="community" \ -DMYSQL_DATADIR=/var/lib/mysql \ -DSYSCONFDIR=/etc/mysql \ -DCMAKE_INSTALL_PREFIX=/usr \ -DENABLED_PROFILING=ON \ -DINSTALL_SUPPORTFILESDIR=/etc/mysql \ -DINSTALL_BINDIR=bin \ -DINSTALL_SBINDIR=sbin \ -DINSTALL_DOCDIR=doc/mysql-8.0.23 \ -DINSTALL_DOCREADMEDIR=doc/mysql-8.0.23 \ -DINSTALL_INCLUDEDIR=include/mysql \ -DINSTALL_LIBDIR=lib \ -DINSTALL_PLUGINDIR=lib/mysql/plugin \ -DINSTALL_MANDIR=man \ -DINSTALL_LAYOUT=STANDALONE \ -DINSTALL_SHAREDIR=share/mysql \ -DINSTALL_MYSQLSHAREDIR=share/mysql \ -DINSTALL_MYSQLDATADIR=lib/mysql \ -DINNODB_COMPILER_HINTS=ON \ -DWITH_ARCHIVE_STORAGE_ENGINE=ON \ -DWITH_AUTHENTICATION_LDAP=ON \ -DWITH_BOOST=/tmp \ -DWITH_BLACKHOLE_STORAGE_ENGINE=ON \ -DWITH_CURL=system \ -DWITH_EDITLINE=system \ -DWITH_EXAMPLE_STORAGE_ENGINE=ON \ -DWITH_FEDERATED_STORAGE_ENGINE=ON \ -DWITH_ICU=system \ -DWITH_INNODB_MEMCACHED=ON \ -DWITH_LIBEVENT=system \ -DWITH_LZ4=system \ -DWITH_NUMA=ON \ -DWITH_PROTOBUF=system \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_SSL=system \ -DWITH_RAPIDJSON=bundled \ -DWITH_ROUTER=OFF \ -DWITH_UNIT_TESTS=ON \ -DWITH_ZLIB=system 4. Build with: make -j8 VERBOSE=1 Suggested fix: The fix as simple as: diff -urNad mysql-8.0.23-orig/sql/mysqld.cc mysql-8.0.23/sql/mysqld.cc --- mysql-8.0.23-orig/sql/mysqld.cc 2020-12-11 09:42:20.000000000 +0200 +++ mysql-8.0.23/sql/mysqld.cc 2021-01-20 08:54:05.398405624 +0200 @@ -7038,7 +7038,7 @@ if (opt_keyring_migration_source || opt_keyring_migration_destination || migrate_connect_options) { Migrate_keyring mk; - my_getopt_skip_unknown = TRUE; + my_getopt_skip_unknown = true; if (mk.init(remaining_argc, remaining_argv, opt_keyring_migration_source, opt_keyring_migration_destination, opt_keyring_migration_user, opt_keyring_migration_host, opt_keyring_migration_password,