* Checking for MaxRows (guess: max rows to load) != 0 before checking whether the requested row is out of range seems unreasonable, since asking for a maximum of 0 rows is not uncommon. Change the default value to -1, and change the checks to look for -1, allowing for MaxRows := 0.

* There seems to be disagreement between drivers on whether to check for Row > MaxRows or Row >= MaxRows.  Guessing that it's a typo, change to the most common variant (Row >= MaxRows, meaning that the row numbers given to MoveAbsolute, MoveRelative, Next, Fetch etc are 0-based).
This commit is contained in:
rosenfield
2007-10-05 17:59:32 +00:00
parent fccb838455
commit ee353d15cc
9 changed files with 12 additions and 13 deletions

View File

@ -1528,8 +1528,7 @@ begin
if IsUniDirectional then if IsUniDirectional then
Statement.SetResultSetType(rtForwardOnly) Statement.SetResultSetType(rtForwardOnly)
else Statement.SetResultSetType(rtScrollInsensitive); else Statement.SetResultSetType(rtScrollInsensitive);
if MaxRows > 0 then Statement.SetMaxRows(MaxRows);
Statement.SetMaxRows(MaxRows);
if doSmartOpen in FOptions then if doSmartOpen in FOptions then
begin begin

View File

@ -575,7 +575,7 @@ end;
function TZASAResultSet.MoveAbsolute(Row: Integer): Boolean; function TZASAResultSet.MoveAbsolute(Row: Integer): Boolean;
begin begin
Result := False; Result := False;
if (MaxRows > 0) and (Row >= MaxRows) then if (MaxRows > -1) and (Row >= MaxRows) then
Exit; Exit;
FASAConnection.GetPlainDriver.db_fetch( FASAConnection.GetDBHandle, FASAConnection.GetPlainDriver.db_fetch( FASAConnection.GetDBHandle,
@ -601,7 +601,7 @@ end;
function TZASAResultSet.MoveRelative(Rows: Integer): Boolean; function TZASAResultSet.MoveRelative(Rows: Integer): Boolean;
begin begin
Result := False; Result := False;
if (MaxRows > 0) and ( Abs( RowNo) + Rows >= MaxRows) then if (MaxRows > -1) and ( Abs( RowNo) + Rows >= MaxRows) then
Exit; Exit;
FASAConnection.GetPlainDriver.db_fetch( FASAConnection.GetDBHandle, FASAConnection.GetPlainDriver.db_fetch( FASAConnection.GetDBHandle,

View File

@ -1736,7 +1736,7 @@ var
TempRow: PZRowBuffer; TempRow: PZRowBuffer;
begin begin
Result := FResultSet.Next; Result := FResultSet.Next;
if not Result or ((MaxRows > 0) and (LastRowNo >= MaxRows)) then if not Result or ((MaxRows > -1) and (LastRowNo >= MaxRows)) then
Exit; Exit;
TempRow := RowAccessor.RowBuffer; TempRow := RowAccessor.RowBuffer;
@ -1928,7 +1928,7 @@ function TZCachedResultSet.MoveAbsolute(Row: Integer): Boolean;
begin begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (Row > MaxRows) then if (MaxRows > -1) and (Row >= MaxRows) then
Exit; Exit;
{ Processes negative rows } { Processes negative rows }

View File

@ -547,7 +547,7 @@ var
begin begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (LastRowNo >= MaxRows) then if (MaxRows > -1) and (LastRowNo >= MaxRows) then
Exit; Exit;
{ Fetch row. } { Fetch row. }

View File

@ -791,7 +791,7 @@ begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (Row > MaxRows) then if (MaxRows > -1) and (Row >= MaxRows) then
Exit; Exit;
if not FUseResult then if not FUseResult then
@ -837,7 +837,7 @@ function TZMySQLResultSet.Next: Boolean;
begin begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (RowNo >= MaxRows) then if (MaxRows > -1) and (RowNo >= MaxRows) then
Exit; Exit;
FRowHandle := FPlainDriver.FetchRow(FQueryHandle); FRowHandle := FPlainDriver.FetchRow(FQueryHandle);

View File

@ -886,7 +886,7 @@ var
begin begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (RowNo > LastRowNo) or ((MaxRows > 0) and (RowNo >= MaxRows)) then if (RowNo > LastRowNo) or ((MaxRows > -1) and (RowNo >= MaxRows)) then
Exit; Exit;
if RowNo = 0 then if RowNo = 0 then

View File

@ -636,7 +636,7 @@ begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (Row > MaxRows) then if (MaxRows > -1) and (Row >= MaxRows) then
Exit; Exit;
{ Processes negative rows. } { Processes negative rows. }

View File

@ -356,7 +356,7 @@ begin
FResultSetConcurrency := rcReadOnly; FResultSetConcurrency := rcReadOnly;
FPostUpdates := poColumnsAll; FPostUpdates := poColumnsAll;
FLocateUpdates := loWhereAll; FLocateUpdates := loWhereAll;
FMaxRows := 0; FMaxRows := -1;
end end
else else
begin begin

View File

@ -734,7 +734,7 @@ begin
{ Checks for maximum row. } { Checks for maximum row. }
Result := False; Result := False;
if (MaxRows > 0) and (RowNo >= MaxRows) then if (MaxRows > -1) and (RowNo >= MaxRows) then
Exit; Exit;
if LastRowNo = 0 then if LastRowNo = 0 then