WL#5928: Most statements should clear the diagnostic area

Affects: Server-5.7   —   Status: Complete

According to the SQL standard, the first diagnostics area should be emptied
at the beginning of the execution of any  that is
not an .

Currently, MySQL clears the diagnostic area as follows (start quote):
* When the server starts executing a statement after parsing it, it clears the
  diagnostics area for nondiagnostic statements that use tables. Diagnostic 
  statements are SHOW WARNINGS, SHOW ERRORS, and GET DIAGNOSTICS.

* If a statement raises a condition, the diagnostics area is cleared of 
  conditions that belong to earlier statements. The exception is that conditions 
  raised by GET DIAGNOSTICS and RESIGNAL are added to the diagnostics area 
  without clearing it.

Thus, even a statement that does not normally clear the diagnostics area when it
begins executing clears it if the statement raises a condition. 

Quoted from
http://dev.mysql.com/doc/refman/5.6/en/diagnostics-area.html#diagnostics-area-
populating

This worklog is about changing MySQL to follow the SQL standard with respect
to clearing the diagnostic area. This means that:
1) We will also clear the diagnostic area for non-diagnostic statments that
   does not use tables.
2) Clearing the diagnostic area should be done at one well-defined point
   during statement execution.

User Documentation
==================

http://dev.mysql.com/doc/refman/5.7/en/show-warnings.html
http://dev.mysql.com/doc/refman/5.7/en/diagnostics-area.html#diagnostics-area-
populating
http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-2.html