Bug #71769 GET STACKED DIAGNOSTICS not behaving as described
Submitted: 19 Feb 2014 14:03 Modified: 21 Nov 2014 22:55
Reporter: Filipe Silva Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.7.2 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[19 Feb 2014 14:03] Filipe Silva
Description:
Hi,

According the documentation of GET DIAGNOSTICS:

«When a condition handler activates, a push to the diagnostics area stack occurs. The first (current) diagnostics area becomes the second (stacked) diagnostics area and a new current diagnostics area is created as a copy of it.»

However this is not happening at least since MySQL 5.7.2, while in version 5.7.0 it worked as described.

For the example provided in the documentation, instead of returning:
+---------------------------------+-------+----------------------------+
| op                              | errno | msg                        |
+---------------------------------+-------+----------------------------+
| current DA before mapped insert |  1048 | Column 'c1' cannot be null |
+---------------------------------+-------+----------------------------+

+---------------------------------+-------+----------------------------+
| op                              | errno | msg                        |
+---------------------------------+-------+----------------------------+
| stacked DA before mapped insert |  1048 | Column 'c1' cannot be null |
+---------------------------------+-------+----------------------------+

it returns:

+---------------------------------+-------+------+
| op                              | errno | msg  |
+---------------------------------+-------+------+
| current DA before mapped insert |  NULL | NULL |
+---------------------------------+-------+------+
1 row in set (0,03 sec)

+---------------------------------+-------+----------------------------+
| op                              | errno | msg                        |
+---------------------------------+-------+----------------------------+
| stacked DA before mapped insert |  1048 | Column 'c1' cannot be null |
+---------------------------------+-------+----------------------------+

How to repeat:
Execute GET STACKED DIAGNOSTICS example provided in documentation: 
http://dev.mysql.com/doc/refman/5.7/en/get-diagnostics.html

Compare results.

Suggested fix:
None.
[20 Feb 2014 12:38] MySQL Verification Team
Hello Filipe,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[20 Nov 2014 16:29] Paul DuBois
Per Jon Olav Hauglid:

"
This is due to a change of behavior introduced by WL#5928.
After WL#5928, DECLARE <variable> clears the (first) diagnostics area
so that GET CURRENT DIAGNOSTICS CONDITION 1 in the example will not
return anything. DECLARE <variable> can contain expressions and is thus
able to generate conditions.

This is therefore a documentation issue as the behavior has changed.
"
[21 Nov 2014 22:55] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly.

See:
http://dev.mysql.com/doc/refman/5.7/en/get-diagnostics.html