Bug 29078 - Commit f763a006329a4a04aac7ea7a4fa03cad18b20193 has broken application
Summary: Commit f763a006329a4a04aac7ea7a4fa03cad18b20193 has broken application
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Atsushi Eno
Depends on:
Reported: 2015-04-14 10:19 UTC by Neale Ferguson
Modified: 2017-09-01 09:29 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Program to load the database (3.77 KB, application/octet-stream)
2015-04-21 15:16 UTC, Neale Ferguson
Program to run query against database (1.59 KB, application/octet-stream)
2015-04-21 15:17 UTC, Neale Ferguson
Program to run a query against database (1.30 KB, application/octet-stream)
2015-04-21 15:17 UTC, Neale Ferguson
Output of --trace=T:System.Data.SqlClient.SqlParameter (13.74 KB, application/octet-stream)
2015-04-21 15:18 UTC, Neale Ferguson

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Neale Ferguson 2015-04-14 10:19:03 UTC
A previously working application now crashes since the application of the commit specified in the subject line:

Error message:System.NotImplementedException: Type Not Supported : NVarChar
at System.Data.SqlClient.SqlParameter.ConvertToFrameworkType (System.Object value) <0x40306c60 + 0x0028f> in <filename unknown>:0
at System.Data.SqlClient.SqlParameter.SqlTypeToFrameworkType (System.Object value) <0x403060c0 + 0x001b7> in <filename unknown>:0
at System.Data.SqlClient.SqlParameter.GetFrameworkValue (System.Object rawValue, System.Boolean& updated) <0x40306040 + 0x00057> in <filename unknown>:0
at Mono.Data.Tds.TdsMetaParameter.get_Value () <0x40305fa0 + 0x00037> in <filename unknown>:0
at Mono.Data.Tds.TdsMetaParameter.GetActualSize () <0x40305da0 + 0x0001f> in <filename unknown>:0
at Mono.Data.Tds.Protocol.Tds70.ExecRPC (TdsRpcProcId rpcId, System.String sql, Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean wantResults) <0x403051c0 + 0x0015f> in <filename unknown>:0
at Mono.Data.Tds.Protocol.Tds80.Execute (System.String commandText, Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean wantResults) <0x4024aed0 + 0x000a3> in <filename unknown>:0
at System.Data.SqlClient.SqlCommand.Execute (Boolean wantResults) <0x4024a3d0 + 0x00745> in <filename unknown>:0
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery () <0x402504c0 + 0x00043> in <filename unknown>:0
at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery (IDbCommand cmd) <0x40304d40 + 0x0009a> in <filename unknown>:0

The fix affected the SystemType/DbMapping methods.

Comment 1 Atsushi Eno 2015-04-14 11:38:33 UTC
Please provide repro.
Comment 2 Neale Ferguson 2015-04-15 16:58:27 UTC
We have not been able to create a simple sample from the much larger application. However,  upon debugging the app it something strange was noticed. In the SqlParameter.cs the Systemtype get is looking up dbtypeMapping[DbType]  but the DbTypeMapping is initialized with SqlDbType (an enum) so dbtype is string and its trying to lookup with a dbtype of string but that’s not in there. Now these 2 types have the same int numbers in the enums so maybe something maybe crossed up and working that way but I'm not sure why it would be doing that. At any rate the error is happing because its looking up a dbtype.string type and its not found in the DbTypemapping. Does that kind of make sense? Look at line 65 and see how its looking up and line 107 and see how its initialized this hashset and its seems to be looking it up with something different from what it was initialized with.
Comment 3 Neale Ferguson 2015-04-21 15:16:40 UTC
Created attachment 10847 [details]
Program to load the database
Comment 4 Neale Ferguson 2015-04-21 15:17:00 UTC
Created attachment 10848 [details]
Program to run query against database
Comment 5 Neale Ferguson 2015-04-21 15:17:41 UTC
Created attachment 10849 [details]
Program to run a query against database
Comment 6 Neale Ferguson 2015-04-21 15:18:35 UTC
Created attachment 10850 [details]
Output of --trace=T:System.Data.SqlClient.SqlParameter
Comment 7 Neale Ferguson 2015-04-21 15:19:13 UTC
I was able to create a simple test case. It produces the following output on 3.10.1:

Connection successful!
High salaries: HARDING
High salaries: GARFIELD
High salaries: JACKSON
High salaries: FILLMORE

But gives me the following on trunk:

Type Not Supported : Int

I have attached the program that creates and loads the database, the query program that fails, and the output of --trace=T:System.Data.SqlClient.SqlParameter
Comment 8 Neale Ferguson 2015-04-21 15:22:54 UTC
BTW the same result for NVarChar parameter as well.
Comment 9 Neale Ferguson 2015-04-21 16:05:58 UTC
The following appears to get things to work again, but I am not sure of what other implications it has:

--- a/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
+++ b/mcs/class/System.Data/System.Data.SqlClient/SqlParameter.cs
@@ -64,7 +64,7 @@ namespace System.Data.SqlClient {
                 // LAMESPEC: Implementors should populate the dbTypeMapping accordingly
                 internal Type SystemType {
                         get {
-                                return (Type) dbTypeMapping [DbType];
+                                return (Type) dbTypeMapping [SqlDbType];
Comment 10 Atsushi Eno 2015-04-24 02:51:22 UTC
Applied your change. Thanks!
Comment 11 Atsushi Eno 2015-04-24 02:51:33 UTC
[master 537fb5c]