Bug #55847 SHOW WARNINGS returns empty result set when SQLEXCEPTION is active
Submitted: 9 Aug 2010 16:30 Modified: 28 Apr 2011 15:57
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S2 (Serious)
Version:M3 (Celosia), M4 (Dahlia) OS:Any
Assigned to: Alexander Nozdrin
Triage: Triaged: D3 (Medium)

[9 Aug 2010 16:30] Alexander Nozdrin
Description:
Due to hackish THD::no_warnings_for_error flag in few cases
Warning_info is empty when Diagnostics_are has an error.

How to repeat:
This test case is extracted from commit_1innodb.test
(include/commit.inc), which is included in the test suite,
and was recorded with wrong results.

> delimiter |

> create table t1(a int unique)|

> create function f2(x int) returns int
begin
  insert into t1(a) values(x);
  insert into t1(a) values(x);
end|

>  show tables where (f2(11) = 11)|
ERROR 1062 (23000): Duplicate entry '11' for key 'a'

> show warnings|
Empty set (0,00 sec)
[9 Aug 2010 17:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/115353

3167 Alexander Nozdrin	2010-08-09
      A patch for Bug#55847 (SHOW WARNINGS returns empty result set
      when SQLEXCEPTION is active).
      
      The problem was that SHOW WARNINGS returned empty result set
      for an SQL statement that returned an error. That happened due to
      misuse of THD::no_warnings_for_error flag.
      
      The fix is to replace two use cases of THD::no_warnings_for_error
      by Internal_error_handler.
[11 Dec 2010 20:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/126573

3421 Alexander Nozdrin	2010-12-11
      A patch for Bug#55847: SHOW WARNINGS returns empty result set
      when SQLEXCEPTION is active.
      
      The problem was in a hackish THD::no_warnings_for_error attribute.
      When it was set, an error was not written to Warning_info -- only
      Diagnostics_area state was changed.
      
      The fix is to remove that hack.
[19 Jan 2011 12:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/129185

3532 Alexander Nozdrin	2011-01-19
      A patch for Bug#55847: SHOW WARNINGS returns empty result set
      when SQLEXCEPTION is active.
      
      The problem was in a hackish THD::no_warnings_for_error attribute.
      When it was set, an error was not written to Warning_info -- only
      Diagnostics_area state was changed. That means, Diagnostics_area
      might contain error state, which is not present in Warning_info.
      
      The fix is to remove that hack. This patch is needed to fix Bug 55843.
[28 Apr 2011 15:57] Paul Dubois
Noted in 5.5.13, 5.6.3 changelogs.

In some cases, SHOW WARNINGS returned an empty result when the
previous statement failed. 

CHANGESET - http://lists.mysql.com/commits/135519