Bug #87337 8.0.2 reintroduces my_bool to client API
Submitted: 7 Aug 2017 8:18 Modified: 21 Aug 2017 19:35
Reporter: Alexey Kopytov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[7 Aug 2017 8:18] Alexey Kopytov
Description:
my_bool was removed in MySQL 8.0.0 everywhere, including the client API:

"The my_bool type was used before MySQL 8.0. As of MySQL 8.0, use the
bool or int C type instead."

https://dev.mysql.com/doc/refman/8.0/en/c-api-data-structures.html

However, in MySQL 8.0.2 the new udf_registration_types.h header file was
introduced which defines my_bool to char, thus reintroducing my_bool to
client API.

Which it poses a problem for client applications that need to be
portable across multiple MySQL releases (I hit it with sysbench):

- pre-8.0 releases use my_bool in the client API, so it is natural to
  declare boolean application variables that are used to interface with
  the MySQL API as my_bool;

- since my_bool is gone in MySQL 8.0.0 and 8.0.1, it would be natural to
  "typedef bool my_bool", since bool is used everywhere my_bool was
  previously used, and the typedef allows to avoid massive application
  code changes;

- now 8.0.2 re-introduces my_bool as an alias to char, which is
  compatible with the pre-8.0 definition of my_bool, but is incompatible
  with bool. Which conflicts with "typedef bool my_bool":

drv_mysql.c:54:14: error: typedef redefinition with different types ('bool' vs 'char')
typedef bool my_bool;
             ^
/usr/local/mysql/include/mysql/udf_registration_types.h:19:14: note: previous definition is here
typedef char my_bool;

I can abstract bool/char/my_bool differences in sysbench code at the
cost of massive code modifications, but:

- I'm not sure re-introduction of my_bool to client API was intentional
- I'm also not sure if making my_bool an alias to char rather than bool
  was intentional
- if both changes were intentional, then C API docs need to be corrected

How to repeat:
1. Look at my_bool definition in udf_registration_types.h

2. Note that udf_registration_types.h is now the only place where
my_bool is defined and used

3. Note that my_bool definition is present in include/mysql.h.pp, which
means it is a part of the client API again.
[7 Aug 2017 9:06] MySQL Verification Team
Hello Alexey,

Thank you for the report and feedback.

Thanks,
Umesh
[8 Aug 2017 12:28] Tor Didriksen
Posted by developer:
 
Fixed by patch for internal bug:

commit 606b344a671a56ffa52939fdb3182a0450fd101f
Author: Steinar H. Gunderson <steinar.gunderson@oracle.com>
Date:   Tue Aug 8 10:43:35 2017 +0200

    Bug #26588846: MYSQL CUSTOM TYPES LEAK INTO THE CLIENT NAMESPACE
    
    Since WL#8020, we now leak MySQL-specific typedefs (uchar, my_bool, etc.)
    into the client namespace when including mysql.h. This is bound to cause
    problems for users sooner or later, and also reintroduces the dreaded my_bool
    type. Get rid of them again.
    
    Change-Id: Ie2358999558f61b1a501884388cd6ae7f07770d8
[21 Aug 2017 19:35] Paul DuBois
Posted by developer:
 
Fixed in 8.0.3.

MySQL-specific typedefs such as uchar and my_bool were inadvertently
reintroduced into the client namespace if the mysql.h header file was
included.