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; |
54 |
|
FReadIdxCount: TStringList; |
55 |
|
FReadSeqCount: TStringList; |
56 |
|
FUpdateCount: TStringList; |
57 |
+ |
procedure CheckDatabase; |
58 |
|
function GetAllocation: Long; |
59 |
|
function GetBaseLevel: Long; |
60 |
|
function GetDBFileName: String; |
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; |
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 |
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 |
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) |
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) |
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 |
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 |
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) |
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 |
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 |
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 |
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 |
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 |