ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBDatabaseInfo.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBDatabaseInfo.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 83 by tony, Mon Jan 1 11:31:15 2018 UTC

# Line 40 | Line 40 | uses
40  
41   type
42  
43 +  { TIBDatabaseInfo }
44 +
45    TIBDatabaseInfo = class(TComponent)
46    protected
45    FIBLoaded: Boolean;
47      FDatabase: TIBDatabase;
48      FUserNames   : TStringList;
49      FBackoutCount: TStringList;
# Line 53 | Line 54 | type
54      FReadIdxCount: TStringList;
55      FReadSeqCount: TStringList;
56      FUpdateCount: TStringList;
57 +    procedure CheckDatabase;
58      function GetAllocation: Long;
59      function GetBaseLevel: Long;
60      function GetDBFileName: String;
# Line 82 | Line 84 | type
84      function GetReadIdxCount: TStringList;
85      function GetReadSeqCount: TStringList;
86      function GetUpdateCount: TStringList;
87 <    function GetOperationCounts(DBInfoCommand: Integer; FOperation: TStringList): TStringList;
87 >    function GetOperationCounts(DBInfoCommand: Integer; var FOperation: TStringList): TStringList;
88      function GetReadOnly: Long;
89      function GetStringDatabaseInfo(DatabaseInfoCommand: Integer): String;
90      function GetDBSQLDialect: Long;
# Line 135 | Line 137 | uses
137   constructor TIBDatabaseInfo.Create(AOwner: TComponent);
138   begin
139    inherited Create(AOwner);
138  FIBLoaded := False;
139  CheckIBLoaded;
140  FIBLoaded := True;
140    FUserNames := TStringList.Create;
141    FBackoutCount                        := nil;
142    FDeleteCount                         := nil;
# Line 151 | Line 150 | end;
150  
151   destructor TIBDatabaseInfo.Destroy;
152   begin
153 <  if FIBLoaded then
154 <  begin
155 <    FUserNames.Free;
156 <    FBackoutCount.Free;
157 <    FDeleteCount.Free;
158 <    FExpungeCount.Free;
159 <    FInsertCount.Free;
160 <    FPurgeCount.Free;
161 <    FReadIdxCount.Free;
163 <    FReadSeqCount.Free;
164 <    FUpdateCount.Free;
165 <  end;
153 >  if assigned(FUserNames) then FUserNames.Free;
154 >  if assigned(FBackoutCount) then FBackoutCount.Free;
155 >  if assigned(FDeleteCount) then FDeleteCount.Free;
156 >  if assigned(FExpungeCount) then FExpungeCount.Free;
157 >  if assigned(FInsertCount) then FInsertCount.Free;
158 >  if assigned(FPurgeCount) then FPurgeCount.Free;
159 >  if assigned(FReadIdxCount) then FReadIdxCount.Free;
160 >  if assigned(FReadSeqCount) then FReadSeqCount.Free;
161 >  if assigned(FUpdateCount) then FUpdateCount.Free;
162    inherited Destroy;
163   end;
164  
165 + procedure TIBDatabaseInfo.CheckDatabase;
166 + begin
167 +  if Database = nil then
168 +    IBError(ibxeDatabaseNotAssigned,[]);
169 +  if Database.Attachment = nil then
170 +    IBError(ibxeDatabaseClosed,[]);
171 + end;
172  
173   function TIBDatabaseInfo.GetAllocation: Long;
174   begin
# Line 175 | Line 178 | end;
178   function TIBDatabaseInfo.GetBaseLevel: Long;
179   var Response: TByteArray;
180   begin
181 +  CheckDatabase;
182    with Database.Attachment.GetDBInformation([isc_info_base_level]) do
183      if (Count > 0) and (Items[0].GetItemType = isc_info_base_level) then
184      begin
# Line 190 | Line 194 | var
194    ConnectionType: integer;
195    SiteName: string;
196   begin
197 +  CheckDatabase;
198    with Database.Attachment.GetDBInformation([isc_info_db_id]) do
199      if (Count > 0) and (Items[0].GetItemType = isc_info_db_id) then
200        Items[0].DecodeIDCluster(ConnectionType,Result,SiteName)
# Line 202 | Line 207 | var
207    ConnectionType: integer;
208    FileName: string;
209   begin
210 +  CheckDatabase;
211    with Database.Attachment.GetDBInformation([isc_info_db_id]) do
212      if (Count > 0) and (Items[0].GetItemType = isc_info_db_id) then
213        Items[0].DecodeIDCluster(ConnectionType,FileName,Result)
# Line 212 | Line 218 | end;
218   function TIBDatabaseInfo.GetDBImplementationNo: Long;
219   var Response: TByteArray;
220   begin
221 +  CheckDatabase;
222    with Database.Attachment.GetDBInformation([isc_info_implementation]) do
223      if (Count > 0) and (Items[0].GetItemType = isc_info_implementation) then
224      begin
# Line 225 | Line 232 | end;
232   function TIBDatabaseInfo.GetDBImplementationClass: Long;
233   var Response: TByteArray;
234   begin
235 +  CheckDatabase;
236    with Database.Attachment.GetDBInformation([isc_info_implementation]) do
237      if (Count > 0) and (Items[0].GetItemType = isc_info_implementation) then
238      begin
# Line 258 | Line 266 | end;
266   function TIBDatabaseInfo.GetVersion: String;
267   var Version: byte;
268   begin
269 +  CheckDatabase;
270    with Database.Attachment.GetDBInformation([isc_info_version]) do
271      if (Count > 0) and (Items[0].GetItemType = isc_info_version) then
272        Items[0].DecodeVersionString(Version,Result)
# Line 292 | Line 301 | end;
301  
302   function TIBDatabaseInfo.GetUserNames: TStringList;
303   begin
304 +  CheckDatabase;
305    Result := FUserNames;
306    FUserNames.Clear;
307    with Database.Attachment.GetDBInformation([isc_info_user_names]) do
# Line 321 | Line 331 | begin
331    result := GetLongDatabaseInfo(isc_info_writes);
332   end;
333  
334 < function TIBDatabaseInfo.GetOperationCounts(DBInfoCommand: Integer; FOperation: TStringList): TStringList;
334 > function TIBDatabaseInfo.GetOperationCounts(DBInfoCommand: Integer;
335 >  var FOperation: TStringList): TStringList;
336   var opCounts: TDBOperationCounts;
337      i: integer;
338   begin
339 +  CheckDatabase;
340    if FOperation = nil then FOperation := TStringList.Create;
341    result := FOperation;
342    with Database.Attachment.GetDBInformation([DBInfoCommand]) do
# Line 383 | Line 395 | end;
395  
396   function TIBDatabaseInfo.GetLongDatabaseInfo(DatabaseInfoCommand: Integer): Long;
397   begin
398 +  CheckDatabase;
399    with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do
400      if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then
401        Result := Items[0].AsInteger
# Line 392 | Line 405 | end;
405  
406   function TIBDatabaseInfo.GetStringDatabaseInfo(DatabaseInfoCommand: Integer): String;
407   begin
408 +  CheckDatabase;
409    with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do
410      if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then
411        Result := Items[0].AsString
# Line 400 | Line 414 | begin
414   end;
415  
416  
417 < function TIBDatabaseInfo.GetDBSQLDialect: Integer;
417 > function TIBDatabaseInfo.GetDBSQLDialect: Long;
418   begin
419 +  CheckDatabase;
420    with Database.Attachment.GetDBInformation([isc_info_db_SQL_Dialect]) do
421      if (Count > 0) and (Items[0].GetItemType = isc_info_db_SQL_Dialect) then
422        Result := Items[0].AsInteger

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines