Bug #58630 Debug 'd' list should stay empty after SET debug="+d,<symbol>"
Submitted: 1 Dec 2010 12:30 Modified: 22 Jul 2013 15:35
Reporter: Bjørn Munch Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.1+, 5.6.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: debug

[1 Dec 2010 12:30] Bjørn Munch
Description:
When the debug 'd' flag has been set, but is set to empty, it means *all* DBUG_ macros are enabled. But if one then sets debug="+d,foo" then only foo becomes enabled, all others are turned off.

How to repeat:
See Bug #58122. With a debug server, run mtr--debug <some test> and have that test do SET debug="+d,symbol". This causes *less* debug to be produced. But the intent should be to add debug for 'symbol' in addition to whatever was enabled before.

Suggested fix:
This is presumably implemented the straightforward way: adding an element to an empty list gives a one-element list. But in this case an empty list has a different semantics, meaning all rather than none. So logically, it should not change if we attempt to add an element to it.
[1 Dec 2010 18:41] Sveta Smirnova
Thank you for the report.

Verified as described.
[22 Jul 2013 15:35] Paul DuBois
Noted in 5.6.12, 5.7.2 changelogs.

Two problems adding or subtracting keyword from the current debug
system variable setting were corrected:

1) A debug value of 'd' means "all debug macros enabled". The following
sequence left the value in an incorrect state:

mysql> SET debug = 'd';SELECT @@debug;
+---------+
| @@debug |
+---------+
| d       |
+---------+

mysql> SET debug = '+d,M1';SELECT @@debug;
+---------+
| @@debug |
+---------+
| d,M1    |
+---------+

The first SET statement enables all debug macros. The second SET
should add the M1 macro to the current set, which should result in no
change because the current set is already "all macros". Instead, the
second SET reset the current set to only the M1 macro, effectively
disabling all others. The server now correctly leaves debug set to
'd'.

2) A debug value of '' means "no debug macros enabled". The following
sequence left the value in an incorrect state:

mysql> SET debug = 'd,M1';SELECT @@debug; 
+---------+
| @@debug |
+---------+
| d,M1    |
+---------+

mysql> SET debug = '-d,M1';SELECT @@debug; 
+---------+
| @@debug |
+---------+
| d       |
+---------+

The first SET statement sets debug to the M1* macro. The second SET
should subtract the M1 macro from the current set, leaving no debug
macros enabled. Instead, the second SET reset the current set to 'd'
(all macros enabled). The server now correctly sets debug ''.