Bug #41167 Multiplication of integers results in wrapped around output
Submitted: 2 Dec 2008 8:07 Modified: 22 Mar 2010 12:33
Reporter: Prafulla Tekawade Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.1.15, 4.1, 5.0, 5.1, 6.0 bzr OS:Linux (Ubuntu)
Assigned to: Assigned Account CPU Architecture:Any

[2 Dec 2008 8:07] Prafulla Tekawade
Description:
create table t2(i1 bigint unsigned, i2 bigint unsigned);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435457, 268435457);
insert into t2 values(268435457, 268435457);
insert into t2 values(268435457, 268435457);
select * from t2;
select i1*i1*i1 from t2;

mysql> select i1*i1*i1 from t2;
+--------------------+
| i1*i1*i1           |
+--------------------+
|                  0 | 
|                  0 | 
|                  0 | 
| 216172782919090177 | 
| 216172782919090177 | 
| 216172782919090177 | 
+--------------------+
6 rows in set (0.00 sec)

Result of this query truncates the values to 64-bits.
Is this expected behaviour ?
What does SQL standard say about it ?
Why does MySQL not promote output to Decimal and show the correct result?

How to repeat:
create table t2(i1 bigint unsigned, i2 bigint unsigned);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435456, 268435456);
insert into t2 values(268435457, 268435457);
insert into t2 values(268435457, 268435457);
insert into t2 values(268435457, 268435457);
select * from t2;
select i1*i1*i1 from t2;
[2 Dec 2008 8:19] Sveta Smirnova
Thank you for the report.

Verified as described.
[22 Mar 2010 12:33] Alexey Kopytov
Fixed in 5.5.4-m3 by the patch for bug #8433.