Bug #19024 SHOW COUNT(*) WARNINGS not return Errors
Submitted: 11 Apr 2006 21:52 Modified: 11 Nov 2006 3:47
Reporter: Jeffrey Dettmann Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:mysql-standard-5.0.18/5.1BK OS:MacOS (Mac OS 10.4.6/Linux)
Assigned to: Iggy Galarza CPU Architecture:Any

[11 Apr 2006 21:52] Jeffrey Dettmann
Description:
SHOW COUNT(*) WARNINGS does not return the number of Errors

How to repeat:
mysql> insert into city 'blah';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blah'' at line 1
mysql> show count(*) warnings;
+-------------------------+
| @@session.warning_count |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set (0.00 sec)

mysql> show count(*) errors;
+-----------------------+
| @@session.error_count |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)
[11 Apr 2006 21:54] Jeffrey Dettmann
mysql> show warnings;         
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                  |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''blah'' at line 1 |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
[11 Apr 2006 22:45] MySQL Verification Team
Thank you for the bug report. I was able to repeat also on Linux.

http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html

The SHOW COUNT(*) WARNINGS statement displays the total number of errors, warnings, and notes. You can also retrieve this number from the warning_count variable:

SHOW COUNT(*) WARNINGS;
SELECT @@warning_count;

miguel@hegel:~/dbs/5.0> bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.1.10-beta-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> insert into city 'blah';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
 1
mysql> show count(*) warnings;
+-------------------------+
| @@session.warning_count |
+-------------------------+
| 0                       |
+-------------------------+
1 row in set (0.00 sec)

mysql> insert into city 'blah';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual tha
 1
mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
| 0               |
+-----------------+
1 row in set (0.01 sec)

mysql>
[4 Oct 2006 14:48] 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/13071

ChangeSet@1.2291, 2006-10-04 10:49:39-04:00, iggy@rolltop.ignatz42.dyndns.org +3 -0
  Bug #19024- SHOW COUNT(*) WARNINGS not return Errors
    
  The server variable warning_count should include the number of warnings, errors and notes according to the manual
[11 Nov 2006 3:47] Paul DuBois
Noted in 5.0.30 (not 5.0.29), 5.1.13 changelogs.

The value of the warning_count system variable was not being
calculated correctly (also affecting SHOW COUNT(*) WARNINGS).