Hi all,
System.Data.Odbc.OdbcDataReader.GetColumn(int) works fine for us
(linux x86_64, unixODBC) in Mono 3.12.1, but it is broken in Mono
4.0.1. The reason for this is that the ReferenceSource implementation
of System.Text.UnicodeEncoding.GetString(byte[]) behaves differently
when you call it with a byte[] of odd length.
mono 3.12.1:
csharp> System.Text.Encoding.Unicode.GetString(new byte[3]);
""
Which is a string of length 1 containing one '\x0' character.
mono 4.0.1:
csharp> System.Text.Encoding.Unicode.GetString(new byte[3]);
"?"
Which is a string of length 2 containing one '\x0' character followed
by a '?' (question mark)
We use the attached patch for Mono 4.0.1 which changes the
implementation of System.Data.Odbc.OdbcDataReader.GetColumn(int) to make
it work with either implementation of
System.Text.UnicodeEncoding.GetString.
Does it make sense to bring in patches like this or will
System.Data.Odbc be replaced by ReferenceSource in the (near) future?
Regards,
Markus
diff -Naur mono-4.0.1/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs mono-4.0.1_zkrd/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
--- mono-4.0.1/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs 2015-04-24 03:26:16.000000000 +0200
+++ mono-4.0.1_zkrd/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs 2015-04-30 17:50:17.028091575 +0200
@@ -180,7 +180,7 @@
{
if (cols [ordinal] == null) {
short bufsize = 255;
- byte [] colname_buffer = new byte [bufsize];
+ byte [] colname_buffer = new byte [2*bufsize];
string colname;
short colname_size = 0;
uint ColSize = 0;
@@ -190,7 +190,8 @@
ref DecDigits, ref Nullable);
if ((ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
throw Connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
- colname = RemoveTrailingNullChar (Encoding.Unicode.GetString (colname_buffer));
+ if (colname_size >= bufsize) colname_size = (short)(bufsize - 1);
+ colname = Encoding.Unicode.GetString (colname_buffer, 0, colname_size*2);
OdbcColumn c = new OdbcColumn (colname, (SQL_TYPE) dt);
c.AllowDBNull = (Nullable != 0);
c.Digits = DecDigits;
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list