[Mono-bugs] [Bug 81306][Nor] Changed - UTF8Encoding.InternalGetCharCount fails during OdbcCommand.ExecuteReader with Informix

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Apr 5 01:39:30 EDT 2007


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 will.mooar at tait.co.nz.

http://bugzilla.ximian.com/show_bug.cgi?id=81306

--- shadow/81306	2007-04-04 01:07:27.000000000 -0400
+++ shadow/81306.tmp.30087	2007-04-05 01:39:30.000000000 -0400
@@ -196,6 +196,57 @@
 unixodbc-2.1.1 or unixODBC-2.2.13pre
 mono-1.2.3.1_0.sunos8.novell.sparc.pkg
 
 ------- Additional Comments From atsushi at ximian.com  2007-04-04 01:07 -------
 It rather looks like Odbc, unixodbc or Informix issue that passes
 wrong arguments to Encoding.
+
+------- Additional Comments From will.mooar at tait.co.nz  2007-04-05 01:39 -------
+Found the cause: The unixODBC layer or Informix ODBC driver is
+returning the wrong length in outsize.  I've worked around the issue
+with the following patch (sorry, not std diff format as I'm not used
+to those tools).
+
+OdbcDataReader.cs:
+                private string GetColumnAttributeStr (int column,
+FieldIdentifier fieldId)
+                {
+                        OdbcReturn ret = OdbcReturn.Error;
+                        byte [] buffer = new byte [255];
+                        int outsize = 0;
+                        int val = 0;
+                        ret = libodbc.SQLColAttribute (hstmt, column,
+fieldId,
+                                                       buffer,
+buffer.Length,
+                                                       ref outsize,
+ref val);
+                        if (ret != OdbcReturn.Success && ret !=
+OdbcReturn.SuccessWithInfo)
+                                throw new OdbcException (new OdbcError
+("SQLColAttribute",
+                                                                     
+  OdbcHandleType.Stmt,
+                                                                     
+  hstmt)
+                                                         );
+/*NEW.sn*/
+                        /* outsize may be garbage - auto calc the size */
+                        outsize = 0;
+                                /* look for first null */
+                        while(outsize < buffer.Length &&
+buffer[outsize] != 0)
+                                outsize++;
+                                /* strip trailing spaces (if any) */
+                        while(outsize > 0 && buffer[outsize-1] == ' ')
+                                outsize--;
+/*NEW.en*/
+                        string value = "";
+                        if (outsize > 0)
+                                value = Encoding.Default.GetString
+(buffer, 0, outsize);
+                        return value;
+                }
+
+So in short, it doesn't appear to be a Mono bug at this time, but
+maybe the above patch might prove useful to anyone suffering this
+problem until the maintainers of unixODBC (or Informix ODBC) can fix this.


More information about the mono-bugs mailing list