[Mono-dev] System.Data.SqlClient TDS 7.0 bigint issue

Kornél Pál kornelpal at hotmail.com
Thu Aug 11 06:22:17 EDT 2005


The range of decimal(19,0) is:
-9,999,999,999,999,999,999..9,999,999,999,999,999,999 (I've tested it on SQL
Server)

The range of Int64 is:
-9,223,372,036,854,775,808..9,223,372,036,854,775,807

You are right that the range of decimal(19,0) is bigger than the range of
Int64 but this can be solved by using Decimal and SqlDecimal for
decimal(19,0) values that cannot be represented using Int64. In other words
that cannot be bigint values.

I know it's an ugly hack to do things like the above and has some
performance penalty but is required to work around TDS 7.0 limitations. And
I think decimal(19,0) is more likely represent a bigint than a real
decimal(19,0).

Kornél

----- Original Message -----
From: "tsureshkumar" <tsureshkumar at novell.com>
To: "Kornél Pál" <kornelpal at hotmail.com>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Thursday, August 11, 2005 9:02 AM
Subject: Re: [Mono-dev] System.Data.SqlClient TDS 7.0 bigint issue


> Kornél Pál wrote:
>> Hi,
>>
>> If you have opinion about this issue please comment it. If the idea will
>> be
>> approved I'll propose a patch.
>>
>> Look at bug http://bugzilla.ximian.com/show_bug.cgi?id=53169
>>
>> The problem is that Decimal is returned instead of Int64.
>>
>> This is a limitation of TDS 7.0 used by Mono. .NET Framework uses TDS
>> 8.0.
>>
>> It is difficult to fix as TDS 8.0 should be implemented.
>>
>> I committed a workaround that makes GetInt64 and GetSqlInt64 able to
>> read decimal(19,0). But there is no way in TDS 7.0 to determine
>> whether the type is bigint.
>>
>> If you use GetValue or GetSqlValue you will get Decimal or SqlDecimal.
>>
>> GetValue seems to be used by Mono users as well. And I think it's more
>> likely to use bigint in an MS SQL database than decimal(19,0).
>>
>> What about trating decimal(19,0) as bigint but let GetDecimal and
>> GetSqlDecimal to return decimal(19,0)? (This would be the revrse of the
>> current solution.)
>
> If I understand your point correctly, you say  that GetValue () should
> return a type of BigInt, instead of Decimal for decimal (19, 0).
>
> I think  this has a potential of treating a decimal field as bigint and
> overflow the Int64. bigint uses 8 bytes whereas decimal uses 9 bytes.
> 10^19 is higher than 2^63. I think bigint to decimal is a safe cast, but
>  not the vice versa.  Ofcourse, in practical, people choose bigint if
> they want higher capacity and our problem lies in, if they want to use
> those extra 7 bits in decimal (19,0) and we are not letting them to use
> through mono, if we follow this approach.
>
>>
>> Kornél
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list