[Mono-bugs] [Bug 61203][Wis] New - Tokenizer ReadNumber Fails with Int64
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 6 Jul 2004 12:33:01 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by dev@6wardlaw.freeserve.co.uk.
http://bugzilla.ximian.com/show_bug.cgi?id=61203
--- shadow/61203 2004-07-06 12:33:01.000000000 -0400
+++ shadow/61203.tmp.13317 2004-07-06 12:33:01.000000000 -0400
@@ -0,0 +1,100 @@
+Bug#: 61203
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: Tested on windows XP and Fedora Core 1
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: dev@6wardlaw.freeserve.co.uk
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Tokenizer ReadNumber Fails with Int64
+
+Description of Problem:
+
+The Mono.Data.SqlExpressions.Tokenizer will fail to read an Int64 from
+the text as it uses Int32.Parse( ).
+
+private object ReadNumber ()
+{
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (Current ());
+
+ char next;
+
+ while (Char.IsDigit (next = Next ()) || next == '.') {
+ sb.Append (next);
+ MoveNext ();
+ }
+
+ string str = sb.ToString ();
+
+ if (str.IndexOf(".") == -1)
+****************************************
+ return int.Parse( str );
+****************************************
+ else
+ return double.Parse (str);
+}
+
+Steps to reproduce the problem:
+1. Create a datatable with a column populated with long integers ( above
+Int32.MaxValue )
+2. Parse the table using an expression
+3. You will see an overflow exception as Int32.Parse( ) is passed a
+string containing a long integer
+
+Actual Results:
+
+Exception: System.OverflowException
+Message: Number overflow.
+Source: mscorlib
+in <0x0019a> System.Int32:Parse (string)
+in <0x00123> Mono.Data.SqlExpressions.Tokenizer:ReadNumber ()
+in <0x001dc> Mono.Data.SqlExpressions.Tokenizer:ParseToken ()
+in <0x0003e> Mono.Data.SqlExpressions.Tokenizer:advance ()
+in <0x0020a> Mono.Data.SqlExpressions.Parser:yyparse
+(Mono.Data.SqlExpressions.yyParser.yyInput)
+in <0x00051> Mono.Data.SqlExpressions.Parser:Compile (string)
+in <0x000a8> System.Data.DataTable:Select
+(string,string,System.Data.DataViewRowState)
+in <0x00080> System.Data.DataView:UpdateIndex (bool)
+in <0x00013> System.Data.DataView:Open ()
+in <0x000aa> System.Data.DataView:.ctor
+(System.Data.DataTable,string,string,System.Data.DataViewRowState)
+
+
+Expected Results:
+
+Should successfully conver to Int64
+
+How often does this happen?
+
+Everytime the value of the integer represented by the string is larger
+than Int32.MaxValue
+
+
+Additional Information:
+
+Suggest changing line 125 from:
+
+return int.Parse( str );
+
+to:
+
+return Int64.Parse( str );
+
+OR
+==
+
+Convert to the largets possible number storage type ( Decimal? ) and pass
+that back as it will have to be cast by the user of the function anyway -
+unless they want to be able to reflect on the type of object returned....
+
+Thanks.