Bug #21976 Unnecessary warning with count(decimal)
Submitted: 1 Sep 2006 20:45 Modified: 11 Apr 2007 2:33
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.1.12-beta-debug/5.0BK OS:Linux (SUSE 10.0 / 64-bit)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[1 Sep 2006 20:45] Peter Gulutzan
Description:
I create a table with a DECIMAL(20) column.
I insert a 20-digit number.
I say "SELECT COUNT(column_name) FROM table_name".
I see a warning: Truncated incorrect DECIMAL value: ''.
This is unnecessary. Nothing was truncated.

How to repeat:
mysql> create table t9 (s1 decimal(20));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t9 values (12345678901234567890);
Query OK, 1 row affected (0.00 sec)

mysql> select count(s1) from t9;
+-----------+
| count(s1) |
+-----------+
|         1 |
+-----------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+---------------------------------------+
| Level | Code | Message                               |
+-------+------+---------------------------------------+
| Error | 1292 | Truncated incorrect DECIMAL value: '' |
+-------+------+---------------------------------------+
1 row in set (0.00 sec)
[1 Sep 2006 20:52] MySQL Verification Team
Thank you for the bug report.

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

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

mysql> create table t9 (s1 decimal(20));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t9 values (12345678901234567890);
Query OK, 1 row affected (0.00 sec)

mysql> select count(s1) from t9;
+-----------+
| count(s1) |
+-----------+
|         1 | 
+-----------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+---------------------------------------+
| Level | Code | Message                               |
+-------+------+---------------------------------------+
| Error | 1292 | Truncated incorrect DECIMAL value: '' | 
+-------+------+---------------------------------------+
1 row in set (0.00 sec)
[22 Dec 2006 5:29] 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/17307

ChangeSet@1.2336, 2006-12-22 09:29:28+04:00, ramil@mysql.com +4 -0
  Fix for bug #21976: Unnecessary warning with count(decimal)
  
  We use val_int() calls (followed by null_value check) to determine 
  nullness in some Item_sum_count' and Item_sum_count_distinct' methods, 
  as a side effect we get extra warnings raised in the val_int().
  Fix: use is_null() instead.
[6 Apr 2007 17:21] Bugs System
Pushed into 5.0.40
[6 Apr 2007 17:24] Bugs System
Pushed into 5.1.18-beta
[11 Apr 2007 2:33] Paul Dubois
Noted in 5.0.40, 5.1.18 changelogs.

COUNT(decimal_expr) sometimes generated a spurious truncation
warning.