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 79 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 80 by tony, Mon Jan 1 11:31:07 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 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 325 | Line 335 | function TIBDatabaseInfo.GetOperationCou
335   var opCounts: TDBOperationCounts;
336      i: integer;
337   begin
338 +  CheckDatabase;
339    if FOperation = nil then FOperation := TStringList.Create;
340    result := FOperation;
341    with Database.Attachment.GetDBInformation([DBInfoCommand]) do
# Line 383 | Line 394 | end;
394  
395   function TIBDatabaseInfo.GetLongDatabaseInfo(DatabaseInfoCommand: Integer): Long;
396   begin
397 +  CheckDatabase;
398    with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do
399      if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then
400        Result := Items[0].AsInteger
# Line 392 | Line 404 | end;
404  
405   function TIBDatabaseInfo.GetStringDatabaseInfo(DatabaseInfoCommand: Integer): String;
406   begin
407 +  CheckDatabase;
408    with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do
409      if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then
410        Result := Items[0].AsString
# Line 400 | Line 413 | begin
413   end;
414  
415  
416 < function TIBDatabaseInfo.GetDBSQLDialect: Integer;
416 > function TIBDatabaseInfo.GetDBSQLDialect: Long;
417   begin
418 +  CheckDatabase;
419    with Database.Attachment.GetDBInformation([isc_info_db_SQL_Dialect]) do
420      if (Count > 0) and (Items[0].GetItemType = isc_info_db_SQL_Dialect) then
421        Result := Items[0].AsInteger

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines