Icon View Incident Report

Serious Serious
Reported By: Harry Mulder
Reported On: 4/15/2001
For: Version 2.08 Build 1
# 764 Adding an Index, Deleting the Index, Repairing the Table, and then Re-Adding the Index Causes Error

The following code causes a 9217 Read Error in the second AddIndex call after the RepairTable.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
Dialogs,
  StdCtrls, DBISAMTb, Db, EDBISAMTable;

type
  TForm1 = class(TForm)
    tbl: TDBISAMTable;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin

  with Tbl do
  begin
    (* get some data in there, else it 
doesn't "work" *)
    Open;
    for i := 0 to 5000 do
    begin
      insert;
      post;
    end;
    Close;


    (* Next, we create an index; this should go fine.. *)
    Open;
    AddIndex( 'TmpAnalyzeOnParentKey', 'RecKey;
ParentKey', [] );
    Close;

    (* Now things start to get interesting; set a breakpoint on the next       *)
    (* 'Open'. Let it run up to here, and open up DBSys; I have had occurences *)
    (* where the 'Sec.
 index'-tab of 'Open table 
shared' shows that the new    *)
    (* index exists, while 'Restructure' does not !                            *)

    Open;
    DeleteIndex('TmpAnalyzeOnParentKey');
    Close;

    (* with the supplied database, I get the opposite effect of what I said   *)
    (* previously: after this DeleteIndex, 'Open 
table' correctly states that *)
    (* the index is no longer available, while 'Restructure' still thinks its *)
    (* there..                                                                *)

    RepairTable;

    (* and Bingo! this AddIndex will trigger a "#9217 Error reading from      *)
    (* table". Try opening the table in DBSys, and it will tell you the       *)
    (* header is corrupt.                                                     *)

    Open;
    AddIndex( 'TmpAnalyzeOnParentKey', 'RecKey;
ParentKey', [] );
    Close;
  end;


end;

end.



Resolution Resolution
Fixed Problem on 4/20/2001 in version 2.09 build 1
Image