Bug #85131 Remove my_bool
Submitted: 22 Feb 2017 15:30 Modified: 24 Feb 2017 17:37
Reporter: Steinar Gunderson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[22 Feb 2017 15:30] Steinar Gunderson
Description:
Most of MySQL is C++ these days, and all C compilers we support support C99 (which has bool through <stdbool.h>). Thus, we can remove our typedef of my_bool to char, and instead just use bool everywhere. This yields stronger type checking (preparatory work already found a few cases where we used bool for things like ASCII characters!), and also gives the compiler more value range information to work with when optimizing.

How to repeat:
N/A

Suggested fix:
Replace my_bool with bool, TRUE with true, and FALSE with false.
[24 Feb 2017 17:37] Paul DuBois
Posted by developer:
 
Fixed in 8.0.1.

Code cleanup. No changelog entry needed.
[27 Feb 2017 9:29] Steinar Gunderson
Posted by developer:
 
Sorry, I meant to write something about documentation here, but it got lost in everything.

There _is_ a user-visible change here that should be documented:

- mysql.h now requires a C++ or C99 header to compile. (All supported platforms have C99 compilers, but some are C89 by default and need mode switches like --std=gnu99 or --std=c99.)
- The my_bool type no longer exists, and people may have been using it in their own code since some mysql.h functions have been returning that. The recommended fix is to use bool or int, which will work both in 8.0 and older versions.
[28 Feb 2017 17:48] Paul DuBois
Posted by developer:
 
Noted in 8.0.1 changelog.

The mysql.h header file now requires a C++ or C99 compiler to
compile.

The my_bool type is no longer used in MySQL source code. Any
third-party code that used this type to represent C boolean variables
should use the bool or int C type instead.