Bug #32309 warning COUNT inconsistent

Submitted: 13 Nov 2007 10:17 Modified: 13 Nov 2007 12:10
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.45, 5.1.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[13 Nov 2007 10:17] Peter Laursen
Description:
In 'real world' warning counts do not seem to behave as documented in
http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html

"select count(*) warnings;" seems always to return '1'

How to repeat:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

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

mysql> select version();
+---------------------+
| version()           |
+---------------------+
| 5.0.45-community-nt |
+---------------------+
1 row in set (0.08 sec)

mysql> show variables like 'max_error_count';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_error_count | 64    |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> select count(*) warnings;
+----------+
| warnings |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql> show warnings;
Empty set (0.00 sec)

mysql> use test;
Database changed
mysql> select * from blabla;
ERROR 1146 (42S02): Table 'test.blabla' doesn't exist
mysql> select count(*) warnings;
+----------+
| warnings |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
|               1 |
+-----------------+
1 row in set (0.00 sec)

mysql> show warnings;
+-------+------+-----------------------------------+
| Level | Code | Message                           |
+-------+------+-----------------------------------+
| Error | 1146 | Table 'test.blabla' doesn't exist |
+-------+------+-----------------------------------+
1 row in set (0.00 sec)

mysql> select a,b,c from dummy; -- the table exists, columns do not
ERROR 1054 (42S22): Unknown column 'a' in 'field list'
mysql> select count(*) warnings;
+----------+
| warnings |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
|               2 |
+-----------------+
1 row in set (0.00 sec)

mysql> show warnings;
+-------+------+------------------------------------+
| Level | Code | Message                            |
+-------+------+------------------------------------+
| Error | 1054 | Unknown column 'a' in 'field list' |
| Error | 1105 | Unknown error                      |
+-------+------+------------------------------------+
2 rows in set (0.00 sec)

Suggested fix:
I think this is a plain bug with "select count(*) warnings;", that should be fixed!
[13 Nov 2007 11:22] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[13 Nov 2007 12:10] Sergei Golubchik
The manual (the url you're referring to) talks about SHOW COUNT(*) WANRINGS not SELECT.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.