mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 19:29:26 +02:00
* Fixed warning
* Use consistent test data between 32-bit and 64-bit * Fix range-overflow problem in building indexes git-svn-id: trunk@10807 -
This commit is contained in:
parent
0d1a85715a
commit
6714fbc056
@ -306,7 +306,14 @@ end;
|
||||
function DBCompareLargeInt(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||
|
||||
begin
|
||||
Result := PInt64(subValue)^-PInt64(aValue)^;
|
||||
// A simple subtraction doesn't work, since it could be that the result
|
||||
// doesn't fit into a LargeInt
|
||||
if PLargeInt(subValue)^ < PLargeInt(aValue)^ then
|
||||
result := -1
|
||||
else if PLargeInt(subValue)^ > PLargeInt(aValue)^ then
|
||||
result := 1
|
||||
else
|
||||
result := 0;
|
||||
end;
|
||||
|
||||
function DBCompareWord(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||
@ -318,16 +325,27 @@ end;
|
||||
function DBCompareQWord(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||
|
||||
begin
|
||||
Result := PQWord(subValue)^-PQWord(aValue)^;
|
||||
// A simple subtraction doesn't work, since it could be that the result
|
||||
// doesn't fit into a LargeInt
|
||||
if PQWord(subValue)^ < PQWord(aValue)^ then
|
||||
result := -1
|
||||
else if PQWord(subValue)^ > PQWord(aValue)^ then
|
||||
result := 1
|
||||
else
|
||||
result := 0;
|
||||
end;
|
||||
|
||||
function DBCompareDouble(subValue, aValue: pointer; options: TLocateOptions): LargeInt;
|
||||
var Dbl : Double;
|
||||
begin
|
||||
Dbl := PDouble(subValue)^-PDouble(aValue)^;
|
||||
if dbl < 0 then result := -1
|
||||
else if dbl > 0 then result := 1
|
||||
else result := 0;
|
||||
// A simple subtraction doesn't work, since it could be that the result
|
||||
// doesn't fit into a LargeInt
|
||||
if PDouble(subValue)^ < PDouble(aValue)^ then
|
||||
result := -1
|
||||
else if PDouble(subValue)^ > PDouble(aValue)^ then
|
||||
result := 1
|
||||
else
|
||||
result := 0;
|
||||
end;
|
||||
|
||||
function IndexCompareRecords(Rec1,Rec2 : pointer; ADBCompareRecs : TDBCompareStruct) : LargeInt;
|
||||
@ -1103,8 +1121,7 @@ function TBufDataset.getnextpacket : integer;
|
||||
|
||||
var i : integer;
|
||||
pb : pchar;
|
||||
IndexNr : integer;
|
||||
|
||||
|
||||
begin
|
||||
if FAllPacketsFetched then
|
||||
begin
|
||||
|
@ -86,7 +86,7 @@ const
|
||||
testCurrencyValues : Array[0..testValuesCount-1] of currency = (-100,-65.5,-54.34,-43.34,-2.50,-0.2,45.40,0.3,45.4,127,128,255,256,45,0.3,45.4,127,128,255,256,45,1234.56,43.23,43.43,99.88);
|
||||
testIntValues : Array[0..testValuesCount-1] of integer = (-maxInt,-maxInt+1,-maxSmallint-1,-maxSmallint,-256,-255,-128,-127,-1,0,1,127,128,255,256,maxSmallint,maxSmallint+1,MaxInt-1,MaxInt,100,130,150,-150,-132,234);
|
||||
testSmallIntValues : Array[0..testValuesCount-1] of smallint = (-maxSmallint,-maxSmallint+1,-256,-255,-128,-127,-1,0,1,127,128,255,256,maxSmallint,maxSmallint-1,100,110,120,130,150,-150,-132,234,231,42);
|
||||
testLargeIntValues : Array[0..testValuesCount-1] of LargeInt = (-MaxSIntValue,-MaxSIntValue+1,-maxInt-1,-maxInt+1,-maxSmallint,-maxSmallint+1,-256,-255,-128,-127,-1,0,1,127,128,255,256,maxSmallint,maxSmallint-1,maxSmallint+1,MaxInt-1,MaxInt,MaxSIntValue-1,MaxSIntValue,235253244);
|
||||
testLargeIntValues : Array[0..testValuesCount-1] of LargeInt = ( -$7fffffffffffffff,-$7ffffffffffffffe,-maxInt-1,-maxInt+1,-maxSmallint,-maxSmallint+1,-256,-255,-128,-127,-1,0,1,127,128,255,256,maxSmallint,maxSmallint-1,maxSmallint+1,MaxInt-1,MaxInt,$7fffffffffffffff-1,$7fffffffffffffff,235253244);
|
||||
testBooleanValues : Array[0..testValuesCount-1] of boolean = (true,false,false,true,true,false,false,true,false,true,true,true,false,false,false,false,true,true,true,true,false,true,true,false,false);
|
||||
testStringValues : Array[0..testValuesCount-1] of string = (
|
||||
'',
|
||||
|
Loading…
Reference in New Issue
Block a user