mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
* 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:
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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 }
|
||||
|
@ -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. }
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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. }
|
||||
|
@ -356,7 +356,7 @@ begin
|
||||
FResultSetConcurrency := rcReadOnly;
|
||||
FPostUpdates := poColumnsAll;
|
||||
FLocateUpdates := loWhereAll;
|
||||
FMaxRows := 0;
|
||||
FMaxRows := -1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user