This project has moved and is read-only. For the latest updates, please go here.

variable declerations for CLR in SQL 2008

Jun 18, 2010 at 4:38 PM

Ichbin:

First, this code is great. I have created an CLR to use it in a database.  I want to set the project Permission Level to Safe and the database Trustworthy to False.

I have three code requests:

1) Will you please add 'readonly' to 'static' fields?

2) Will you please add public override int GetHashCode()
        {
            return base.GetHashCode();
        }

to the following functions:

• Functions.Spin
• Functions.SpinState
• Matrices.Matrix
• Matrices.SymmetricMatrix
• Matrices.TridiagonalMatrix

3) Change Stastics.DataSet.DataPoint from 'internal' to 'public'.

since I am new to CLR and C#, will you please explain what, or point to a link, to help me understand these finer changes in code?

thank you.

Jun 20, 2010 at 11:12 PM
Hi, I want to accomodate your requests so I'll need to understand them a little better. (1) It looks to me like all public static fields are already readonly; can you point me to one that is not? (2) Yes, GetHashCode() needs to be implemented on the classes you list. This part I understand. (3) DataPoint is already public; are you sure you didn't mean some other class? Finally, are these requests related to the SQL permission/trust settings, or just seperate observations? Thanks, David
Jun 21, 2010 at 2:39 PM
Edited Jun 21, 2010 at 2:42 PM
David: 1) During the deploy these are the errors: Deploy error SQL01268: .Net SqlClient Data Provider: Msg 6211, Level 16, State 1, Line 1 CREATE ASSEMBLY failed because type 'Meta.Numerics.Global' in safe assembly 'Meta.Numerics' has a static field 'SqrtMax'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language. I had to add readonly even though static implies readonly: public static readonly double SqrtMax = Math.Pow(2.0, 512); The variables are: • Global.SqrtMax • Global.Accuracy • Functions.factorialTable • GaussKronrodIntegrator.x • GaussKronrodIntegrator.c1 • GaussKronrodIntegrator.c2 • AdvancedMath.Dawson_Rybicki_h • AdvancedMath.Dawson_Rybicki_coefficients • AdvancedMath.DirichletEta_Coefficients • AdvancedMath.StieltjesConstants • AdvancedComplexMath.Faddeeva_Weideman_L • AdvancedComplexMath.Faddeeva_Weideman_Coefficients 2) Great... as you see I went the most rudimentary route to include GetHashCode. 3) you are correct. it is around line 335 in the DataSet.cs file public class DataSet<T> public IEnumerator<DataPoint<T>>; GetEnumerator() Finally) These observations are related to the SQL Trustworthy facet. Danke für Ihre zeit. Rogge
Jun 21, 2010 at 2:44 PM
(trying to format my reply...) 1) During the deploy these are the errors: Deploy error SQL01268: .Net SqlClient Data Provider: Msg 6211, Level 16, State 1, Line 1 CREATE ASSEMBLY failed because type 'Meta.Numerics.Global' in safe assembly 'Meta.Numerics' has a static field 'SqrtMax'. Attributes of static fields in safe assemblies must be marked readonly in Visual C#, ReadOnly in Visual Basic, or initonly in Visual C++ and intermediate language. I had to add readonly even though static implies readonly: public static readonly double SqrtMax = Math.Pow(2.0, 512); The variables are: • Global.SqrtMax • Global.Accuracy • Functions.factorialTable • GaussKronrodIntegrator.x • GaussKronrodIntegrator.c1 • GaussKronrodIntegrator.c2 • AdvancedMath.Dawson_Rybicki_h • AdvancedMath.Dawson_Rybicki_coefficients • AdvancedMath.DirichletEta_Coefficients • AdvancedMath.StieltjesConstants • AdvancedComplexMath.Faddeeva_Weideman_L • AdvancedComplexMath.Faddeeva_Weideman_Coefficients 2) Great... as you see I went the most rudimentary route to include GetHashCode. 3) you are correct. it is around line 335 in the DataSet.cs file public class DataSet<T> public IEnumerator<DataPoint<T>>; GetEnumerator() Finally) These observations are related to the SQL Trustworthy facet. Danke für Ihre zeit. Rogge
Jun 23, 2010 at 11:27 AM

Hmm, it looks like SQL server is complaining even about internal static fields that are not readonly. I'm a little surprised at that, but it's certainly not impossible. For most of those fields, I don't expect making them readonly would cause any problem. I'm going to do a SQL deployment myself so I can get a better feel for these issues. I've created a work item (#4682) to track progress on the issue.

I'm glad you were able to adapt the code to make it work for you, and I appreciate your surfacing the issue for the rest of us. You can expect that any necessary code changes will make their way into the next release.

Jun 23, 2010 at 4:43 PM
Thank you very much. have a good week.
Sep 21, 2010 at 7:59 PM

Just downloaded and implemented release 51292.  it works great... thank you for including code to make use with SQL Server easier.