| Bug #35920 | get wrong result with decimal(8,2) field type | ||
|---|---|---|---|
| Submitted: | 9 Apr 2008 2:52 | Modified: | 8 Jul 2008 9:30 |
| Reporter: | Kuang Yinong | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S2 (Serious) |
| Version: | 5.1.3 | OS: | Windows |
| Assigned to: | Jess Balint | CPU Architecture: | Any |
| Tags: | 5.1, decimal, double, MyODBC | ||
[9 Apr 2008 2:52]
Kuang Yinong
[9 Apr 2008 3:38]
Jess Balint
Verified as described. Result received is 8000000.00.
[9 Apr 2008 4:50]
Jess Balint
If the decimal point was on the beginning edge of one of the segments, it would be skipped.
Index: driver/utility.c
===================================================================
--- driver/utility.c (revision 1088)
+++ driver/utility.c (working copy)
@@ -2371,7 +2371,7 @@
if we have the decimal point, ignore it by setting it to the
last char (will be ignored by strtoul)
*/
- if (decpt && decpt > numstr + i && decpt < numstr + i + usedig)
+ if (decpt && decpt >= numstr + i && decpt < numstr + i + usedig)
{
usedig = (int) (decpt - (numstr + i) + 1);
sqlnum->scale= len - (i + usedig);
Index: test/my_types.c
===================================================================
--- test/my_types.c (revision 1088)
+++ test/my_types.c (working copy)
@@ -879,6 +879,9 @@
is(sqlnum_test_from_str(hstmt, num3, 6, -1, 0, NULL, 10123, 0) == OK);
is(sqlnum_test_from_str(hstmt, num3, 5, -1, 0, NULL, 10123, 0) == OK);
+ /* Bug#35920 */
+ is(sqlnum_test_from_str(hstmt, "8000.00", 30, 2, 1, NULL, 800000, 0) == OK);
+ is(sqlnum_test_from_str(hstmt, "1234567.00", 30, 2, 1, NULL, 123456700, 0) == OK);
/* some larger numbers */
{SQLCHAR expdata[SQL_MAX_NUMERIC_LEN]= {0xD5, 0x50, 0x94, 0x49, 0,0,0,0,0,0,0,0,0,0,0,0};
[9 Apr 2008 13:29]
Kuang Yinong
other field Estimated_Clicks mediumint(9) NOT NULL, Estimated_Conversions mediumint(9) NOT NULL, also will have the problem sometimes, but not always. also change it to double will ok.
[14 Apr 2008 22:02]
Lawrenty Novitsky
approved
[15 Apr 2008 5:32]
Jess Balint
Fix committed in rev 1105, will be released in 5.1.4.
[8 Jul 2008 9:30]
Tony Bedford
An entry has been added to the 5.1.4 Changelog: Wrong result obtained when using sum() on a decimal(8,2) field type.
