Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0014769
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformmajoralways2010-10-05 18:042023-07-11 05:13
ReporterchristiancorrodiView Statuspublic 
Assigned ToAugustoMauch 
PriorityurgentResolutionfixedFixed in Version
StatusclosedFix in branchFixed in SCM revision34727a4bec62
ProjectionnoneETAnoneTarget Version
OSAnyDatabasePostgreSQLJava version
OS VersionDatabase version8.3Ant version
Product Version2.40SCM revision 
Review Assigned To
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0014769: prescript-PostgreSql.sql: to_number(text) function returning wrong values for inputs in scientific notation

DescriptionGiven a number x as a String. When x >= 1E7 or x <= 1E-4 the value stored to the database is wrong.

This error comes for example from calling Double.toString(). Under Oracle this function returns a value of the type numeric for this case.

1E7 -> 17 instead of 10000000
1E-4 -> 14 instead of .0001
Proposed SolutionCREATE OR REPLACE FUNCTION to_number
(
text
)
RETURNS NUMERIC AS '
DECLARE
  v_Pos INTEGER;
  v_Mant NUMERIC;
  v_Exp NUMERIC;
  v_Res NUMERIC;
BEGIN
  v_Pos := position(''E'' in upper($1));
  IF v_Pos = 0 THEN
    -- this is the old behaviour
    RETURN to_number($1, ''S99999999999999D999999'');
  ELSE
    v_Mant := substring($1 from 1 for v_Pos - 1); -- Mantissa, implicit cast to data type NUMERIC
    v_Exp := substring($1 from v_Pos + 1); -- Exponent, implicit cast to data type NUMERIC
    v_Res := v_Mant * power(10, v_Exp);
    RETURN v_Res;
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    RETURN NULL;
END;
' LANGUAGE 'plpgsql' IMMUTABLE
/-- END
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0032951 closedalostale Fix Stock process rounds the quantities to 6 decimals and it should not 

-  Notes
(0045073)
hgbot (developer)
2012-02-13 16:31

Repository: erp/devel/pi
Changeset: 34727a4bec62fdee0e39b43a4b0d79605cd4a6b7
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Mon Feb 13 16:30:57 2012 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/34727a4bec62fdee0e39b43a4b0d79605cd4a6b7 [^]

Fixes issue 14769: to_text function now supports scientific notation

---
M src-db/database/model/prescript-PostgreSql.sql
---
(0045075)
AugustoMauch (administrator)
2012-02-13 16:39

If the number to be converted is written in scientific notation (e.g. 1e5), the convertion now returns 10000 (prior to the fix, it would have returned 15).

If the number to be converted is not written in scientific notation, the convertion is the same as before, so I think that this is not a risky fix.
(0045836)
hudsonbot (developer)
2012-03-02 15:36

A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/544d64e0c159 [^]

Maturity status: Test

- Issue History
Date Modified Username Field Change
2010-10-05 18:04 christiancorrodi New Issue
2010-10-05 18:04 christiancorrodi Assigned To => alostale
2010-10-11 09:05 alostale Priority normal => urgent
2010-10-11 09:06 alostale Status new => scheduled
2011-11-16 16:30 alostale Assigned To alostale => marvintm
2012-02-13 12:08 marvintm Assigned To marvintm => AugustoMauch
2012-02-13 16:31 hgbot Checkin
2012-02-13 16:31 hgbot Note Added: 0045073
2012-02-13 16:31 hgbot Status scheduled => resolved
2012-02-13 16:31 hgbot Resolution open => fixed
2012-02-13 16:31 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/34727a4bec62fdee0e39b43a4b0d79605cd4a6b7 [^]
2012-02-13 16:39 AugustoMauch Note Added: 0045075
2012-02-21 17:26 marvintm Status resolved => closed
2012-03-02 15:36 hudsonbot Checkin
2012-03-02 15:36 hudsonbot Note Added: 0045836
2016-05-25 11:05 alostale Relationship added related to 0032951
2023-07-11 05:13 thielmikayla Note Added: 0152297
2023-07-11 13:48 shuehner Note Deleted: 0152297


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker