Bug #26607 Falcon: decimal(31,30) does not work
Submitted: 23 Feb 2007 19:34 Modified: 19 Jun 2007 12:24
Reporter: Hakan Küçükyılmaz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S2 (Serious)
Version: OS:Any
Assigned to: Christopher Powers CPU Architecture:Any

[23 Feb 2007 19:34] Hakan Küçükyılmaz
Description:
Inserting into a decimal(31, 30) field works but SELECTING afterwards does not.

How to repeat:
CREATE TABLE t1 (a decimal(31, 30)) Engine Falcon;

INSERT INTO t1 VALUES (-9.999999999999999999999999999999);
INSERT INTO t1 VALUES (9.999999999999999999999999999999);

SELECT count(*) FROM t1 WHERE a = -9.999999999999999999999999999999;
-- count is zero.

SELECT count(*) FROM t1 WHERE a = 9.999999999999999999999999999999;
-- count is zero.
[23 Feb 2007 23:01] MySQL Verification Team
Thank you for the bug report. Verified as described.
[31 May 2007 17:07] Peter Gulutzan
It's not just DECIMAL(31,30) that's affected, and it fails during INSERT.

Here are three examples inserting into decimal(31,30) and decimal(20,20)
and decimal(18,18) columns. In all three cases, the post-decimal digits
are partially lost.

mysql> create table t1 (s1 decimal(31,30)) engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (9.999999999999999999999999999999);
Query OK, 1 row affected (0.01 sec)

mysql> select * from t1;
+----------------------------------+
| s1                               |
+----------------------------------+
| 9.000000000000000000000000000999 |
+----------------------------------+
1 row in set (0.00 sec)

mysql>
mysql> create table t2 (s1 decimal(20,20)) engine=falcon;
Query OK, 0 rows affected (0.02 sec)

mysql> insert into t2 values (0.123456789012345678901234567890);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from t2;
+------------------------+
| s1                     |
+------------------------+
| 0.00000000000000000012 |
+------------------------+
1 row in set (0.00 sec)

mysql>
mysql> create table t3 (s1 decimal(18,18)) engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t3 values (0.123456789012345678);
Query OK, 1 row affected (0.01 sec)

mysql> select * from t3;
+----------------------+
| s1                   |
+----------------------+
| 0.123456789788225870 |
+----------------------+
1 row in set (0.00 sec)
[31 May 2007 17:30] Peter Gulutzan
Also ALTER ruins the post-decimal digits.
And even if I try to search for the ruined value, I get nothing.

For example:

mysql> create table t6 (s1 decimal(40,30));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t6 values      (9999999999.999999999999999999999999999999);
Query OK, 1 row affected (0.01 sec)

mysql> select * from t6;
+-------------------------------------------+
| s1                                        |
+-------------------------------------------+
| 9999999999.999999999999999999999999999999 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql> create index i on t6 (s1);
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> alter table t6 engine=falcon;
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from t6;
+-------------------------------------------+
| s1                                        |
+-------------------------------------------+
| 9999999999.000000000000000000000000000999 |
+-------------------------------------------+
1 row in set (0.01 sec)

mysql> select * from t6 where s1 = 9999999999.000000000000000000000000000999;
Empty set (0.00 sec)

mysql> drop index i on t6;
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from t6 where s1 = 9999999999.000000000000000000000000000999;
Empty set (0.00 sec)
[18 Jun 2007 23:13] 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/29043

ChangeSet@1.2575, 2007-06-18 18:13:08-05:00, chris@terrazzo.site +3 -0
  Added arbitrary division capability to the BigInt class. This
  enables operations on numbers having greater than 9 digits, for
  example DECIMAL(65,30).
  
  WL#3923 "Arbitrary Precision Division for Falcon BigInt
  Bug#26607 "Falcon: decimal(31,30) does not work"
  Bug#28725 "Falcon: crash with decimal"
[19 Jun 2007 2:02] 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/29052

ChangeSet@1.2576, 2007-06-18 21:02:14-05:00, chris@terrazzo.site +1 -0
  Pushbuild break, BigInt division. Replaced calls to malloca/freea with malloc/free in BigInt.cpp.
  
  WL#3923 "Arbitrary Precision Division for Falcon BigInt
  Bug#26607 "Falcon: decimal(31,30) does not work"
  Bug#28725 "Falcon: crash with decimal"
[19 Jun 2007 7:15] Hakan Küçükyılmaz
falcon_bug_26607.test passes now.
[19 Jun 2007 12:24] MC Brown
A note has been added to the 6.0.1 changelog: 

<literal>DECIMAL</literal> columns with large widths did not
  work, either during <literal>INSERT</literal> or <literal>SELECT</literal>.