Bug #85709 Get rid of tmp_disable_binlog/reenable_binlog macros
Submitted: 30 Mar 2017 13:59 Modified: 31 Mar 2017 18:11
Reporter: Jon Olav Hauglid Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.2 OS:Any
Assigned to: CPU Architecture:Any

[30 Mar 2017 13:59] Jon Olav Hauglid
Description:
#define tmp_disable_binlog(A)       \
  {ulonglong tmp_disable_binlog__save_options= (A)->variables.option_bits; \
  (A)->variables.option_bits&= ~OPTION_BIN_LOG

#define reenable_binlog(A)   (A)->variables.option_bits= tmp_disable_binlog__save_options;}

Note that these two macros:
- Look like functions (lowercase name)
- Starts a scope in the first macro that is ended in the second.

Especially the latter is a problem - it can give hard to understand compiler errors.
Or worse - it can cause strange runtime errors as destructors of variables declared between the first and second macro suddenly goes out of scope.

How to repeat:
Code inspection

Suggested fix:
Replace with a proper RAII construction.
[31 Mar 2017 18:11] Paul DuBois
Posted by developer:
 
Fixed in 8.0.2.

Code cleanup. No changelog entry needed.