* 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
Statement.SetResultSetType(rtForwardOnly)
else Statement.SetResultSetType(rtScrollInsensitive);
if MaxRows > 0 then
Statement.SetMaxRows(MaxRows);
Statement.SetMaxRows(MaxRows);
if doSmartOpen in FOptions then
begin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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