Icon View Incident Report

Serious Serious
Reported By: Rich Walker
Reported On: 7/11/2002
For: Version 3.11 Build 1
# 1155 BlockReadSize Not Working Properly and Returning Incorrect Field Information

Attached is the code demonstrating a serious problem with BlockReadSize in 3.11.

procedure TForm1.Button1Click(Sender: TObject);
var tot1,tot2 : Currency;
begin
  // First, with a query
  qryTemp17.Close;
  qryTemp17.DatabaseName := ExtractFilePath(Application.ExeName);
  qryTemp17.SQL.Clear;
  qryTemp17.SQL.Add('select Amount from "Temp17"');

  tot1 := 0;
  qryTemp17.Open;
  try
    qryTemp17.First;
    qryTemp17.BlockReadSize := 100;
    while not qryTemp17.Eof do begin
      tot1 := tot1 + qryTemp17.FieldByName('Amount').AsCurrency;
      qryTemp17.Next;
    end;
    qryTemp17.BlockReadSize := 0;
  finally
    qryTemp17.Close;
  end;

  tot2 := 0;
  qryTemp17.Open;
  try
    qryTemp17.First;
    while not qryTemp17.Eof do begin
      tot2 := tot2 + qryTemp17.FieldByName('Amount').AsCurrency;
      qryTemp17.Next;
    end;
  finally
    qryTemp17.Close;
  end;

  ShowMessageFmt('Using a TDBISAMQuery:'#13#10+
                 'tot1 (BlockReadSize=100): %m'#13#10+
                 'tot2 (BlockReadSize=0): %m'#13#10#13#10+
                 'Why are these amounts different?',[tot1,tot2]);


  // Now 
let's try the same logic with a table
  tblTemp17.Close;
  tblTemp17.DatabaseName := ExtractFilePath(Application.ExeName);
  tblTemp17.TableName := 'Temp17';

  tot1 := 0;
  tblTemp17.Open;
  try
    tblTemp17.First;
    tblTemp17.BlockReadSize := 100;
    while not tblTemp17.Eof do begin
      tot1 := tot1 + tblTemp17.FieldByName('Amount').AsCurrency;
      tblTemp17.Next;
    end;
    tblTemp17.BlockReadSize := 0;
  finally
    tblTemp17.Close;
  end;

  tot2 := 0;
  tblTemp17.Open;
  try
    tblTemp17.First;
    while not tblTemp17.Eof do begin
      tot2 := tot2 + tblTemp17.FieldByName('Amount').AsCurrency;
      tblTemp17.Next;
    end;
  finally
    tblTemp17.Close;
  end;

  ShowMessageFmt('Using 
a TDBISAMTable:'#13#10+
                 'tot1 (BlockReadSize=100): 
%m'#13#10+
                 'tot2 (BlockReadSize=0): 
%m'#13#10#13#10+
                 'Why are these amounts different?',[tot1,tot2]);

end;



Comments Comments
Setting of field data was not accessing the read-ahead buffer correctly for block reads. Was introduced in the process of trying to improve the functionality of the block read-ahead to make it more flexible than the Borland implementation.


Resolution Resolution
Fixed Problem on 7/11/2002 in version 3.12 build 1
Image