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; |
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; |
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 |
250 |
|
|
251 |
|
function TIBDatabaseInfo.GetODSMinorVersion: Long; |
252 |
|
begin |
253 |
< |
result := GetLongDatabaseInfo(isc_info_ods_minor_version); |
253 |
> |
CheckDatabase; |
254 |
> |
Result := Database.Attachment.GetODSMinorVersion; |
255 |
|
end; |
256 |
|
|
257 |
|
function TIBDatabaseInfo.GetODSMajorVersion: Long; |
258 |
|
begin |
259 |
< |
result := GetLongDatabaseInfo(isc_info_ods_version); |
259 |
> |
CheckDatabase; |
260 |
> |
Result := Database.Attachment.GetODSMajorVersion; |
261 |
|
end; |
262 |
|
|
263 |
|
function TIBDatabaseInfo.GetPageSize: Long; |
268 |
|
function TIBDatabaseInfo.GetVersion: String; |
269 |
|
var Version: byte; |
270 |
|
begin |
271 |
+ |
CheckDatabase; |
272 |
|
with Database.Attachment.GetDBInformation([isc_info_version]) do |
273 |
|
if (Count > 0) and (Items[0].GetItemType = isc_info_version) then |
274 |
|
Items[0].DecodeVersionString(Version,Result) |
303 |
|
|
304 |
|
function TIBDatabaseInfo.GetUserNames: TStringList; |
305 |
|
begin |
306 |
+ |
CheckDatabase; |
307 |
|
Result := FUserNames; |
308 |
|
FUserNames.Clear; |
309 |
|
with Database.Attachment.GetDBInformation([isc_info_user_names]) do |
333 |
|
result := GetLongDatabaseInfo(isc_info_writes); |
334 |
|
end; |
335 |
|
|
336 |
< |
function TIBDatabaseInfo.GetOperationCounts(DBInfoCommand: Integer; FOperation: TStringList): TStringList; |
336 |
> |
function TIBDatabaseInfo.GetOperationCounts(DBInfoCommand: Integer; |
337 |
> |
var FOperation: TStringList): TStringList; |
338 |
|
var opCounts: TDBOperationCounts; |
339 |
|
i: integer; |
340 |
|
begin |
341 |
+ |
CheckDatabase; |
342 |
|
if FOperation = nil then FOperation := TStringList.Create; |
343 |
|
result := FOperation; |
344 |
|
with Database.Attachment.GetDBInformation([DBInfoCommand]) do |
397 |
|
|
398 |
|
function TIBDatabaseInfo.GetLongDatabaseInfo(DatabaseInfoCommand: Integer): Long; |
399 |
|
begin |
400 |
+ |
CheckDatabase; |
401 |
|
with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do |
402 |
|
if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then |
403 |
|
Result := Items[0].AsInteger |
407 |
|
|
408 |
|
function TIBDatabaseInfo.GetStringDatabaseInfo(DatabaseInfoCommand: Integer): String; |
409 |
|
begin |
410 |
+ |
CheckDatabase; |
411 |
|
with Database.Attachment.GetDBInformation([DatabaseInfoCommand]) do |
412 |
|
if (Count > 0) and (Items[0].GetItemType = DatabaseInfoCommand) then |
413 |
|
Result := Items[0].AsString |
416 |
|
end; |
417 |
|
|
418 |
|
|
419 |
< |
function TIBDatabaseInfo.GetDBSQLDialect: Integer; |
419 |
> |
function TIBDatabaseInfo.GetDBSQLDialect: Long; |
420 |
|
begin |
421 |
+ |
CheckDatabase; |
422 |
|
with Database.Attachment.GetDBInformation([isc_info_db_SQL_Dialect]) do |
423 |
|
if (Count > 0) and (Items[0].GetItemType = isc_info_db_SQL_Dialect) then |
424 |
|
Result := Items[0].AsInteger |