Browse Source

* Moved implementation of IndexDefs from sqldb to bufdataset

git-svn-id: trunk@9504 -
joost 17 years ago
parent
commit
9f97f670ab
2 changed files with 15 additions and 12 deletions
  1. 13 0
      packages/fcl-db/src/base/bufdataset.pas
  2. 2 12
      packages/fcl-db/src/sqldb/sqldb.pp

+ 13 - 0
packages/fcl-db/src/base/bufdataset.pas

@@ -144,6 +144,8 @@ type
     FOpen           : Boolean;
     FUpdateBuffer   : TRecordsUpdateBuffer;
     FCurrentUpdateBuffer : integer;
+    
+    FIndexDefs      : TIndexDefs;
 
     FParser         : TBufDatasetParser;
 
@@ -155,6 +157,7 @@ type
     FBlobBuffers      : array of PBlobBuffer;
     FUpdateBlobBuffers: array of PBlobBuffer;
 
+    function GetIndexDefs : TIndexDefs;
     procedure AddRecordToIndex(var AIndex: TBufIndex; ARecBuf: pchar);
     function  GetCurrentBuffer: PChar;
     procedure CalcRecordSize;
@@ -232,6 +235,7 @@ type
   published
     property PacketRecords : Integer read FPacketRecords write SetPacketRecords default 10;
     property OnUpdateError: TResolverErrorEvent read FOnUpdateError write SetOnUpdateError;
+    property IndexDefs : TIndexDefs read GetIndexDefs;
     property IndexName : String read GetIndexName write SetIndexName;
   end;
 
@@ -286,6 +290,7 @@ begin
   setlength(FFirstRecBufs,FIndexesCount);
   SetLength(FLastRecBufs,FIndexesCount);
 {$ENDIF}
+  FIndexDefs := TIndexDefs.Create(Self);
 
   SetLength(FUpdateBuffer,0);
   SetLength(FBlobBuffers,0);
@@ -303,9 +308,17 @@ end;
 
 destructor TBufDataset.Destroy;
 begin
+  FreeAndNil(FIndexDefs);
+
   inherited destroy;
 end;
 
+function TBufDataset.GetIndexDefs : TIndexDefs;
+
+begin
+  Result := FIndexDefs;
+end;
+
 Function TBufDataset.GetCanModify: Boolean;
 begin
   Result:= False;

+ 2 - 12
packages/fcl-db/src/sqldb/sqldb.pp

@@ -179,7 +179,6 @@ type
     FDeleteSQL           : TStringList;
     FIsEOF               : boolean;
     FLoadingFieldDefs    : boolean;
-    FIndexDefs           : TIndexDefs;
     FReadOnly            : boolean;
     FUpdateMode          : TUpdateMode;
     FParams              : TParams;
@@ -199,7 +198,6 @@ type
     FInsertQry           : TCustomSQLQuery;
 
     procedure FreeFldBuffers;
-    function GetIndexDefs : TIndexDefs;
     function GetStatementType : TStatementType;
     procedure SetReadOnly(AValue : Boolean);
     procedure SetParseSQL(AValue : Boolean);
@@ -281,7 +279,6 @@ type
     property UpdateSQL : TStringlist read FUpdateSQL write FUpdateSQL;
     property InsertSQL : TStringlist read FInsertSQL write FInsertSQL;
     property DeleteSQL : TStringlist read FDeleteSQL write FDeleteSQL;
-    property IndexDefs : TIndexDefs read GetIndexDefs;
     property Params : TParams read FParams write FParams;
     property UpdateMode : TUpdateMode read FUpdateMode write SetUpdateMode;
     property UsePrimaryKeyAsKey : boolean read FUsePrimaryKeyAsKey write SetUsePrimaryKeyAsKey;
@@ -1220,7 +1217,6 @@ begin
   FDeleteSQL := TStringList.Create;
   FDeleteSQL.OnChange := @OnChangeModifySQL;
 
-  FIndexDefs := TIndexDefs.Create(Self);
   FReadOnly := false;
   FParseSQL := True;
   
@@ -1244,7 +1240,6 @@ begin
   FreeAndNil(FInsertSQL);
   FreeAndNil(FDeleteSQL);
   FreeAndNil(FUpdateSQL);
-  FreeAndNil(FIndexDefs);
   inherited Destroy;
 end;
 
@@ -1288,8 +1283,9 @@ end;
 Procedure TCustomSQLQuery.UpdateIndexDefs;
 
 begin
+  Inherited;
   if assigned(DataBase) and (FTableName<>'') then
-    TSQLConnection(DataBase).UpdateIndexDefs(FIndexDefs,FTableName);
+    TSQLConnection(DataBase).UpdateIndexDefs(IndexDefs,FTableName);
 end;
 
 Procedure TCustomSQLQuery.ApplyRecUpdate(UpdateKind : TUpdateKind);
@@ -1420,12 +1416,6 @@ begin
     Result := False;
 end;
 
-function TCustomSQLQuery.GetIndexDefs : TIndexDefs;
-
-begin
-  Result := FIndexDefs;
-end;
-
 procedure TCustomSQLQuery.SetUpdateMode(AValue : TUpdateMode);
 
 begin