📄 ibdatabaseinfo.pas
字号:
begin
DatabaseInfoCommand := Char(isc_info_implementation);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @DatabaseInfoCommand,
IBLocalBufferLength, local_buffer), True);
result := isc_vax_integer(@local_buffer[4], 1);
end;
function TIBDatabaseInfo.GetNoReserve: Long;
begin
result := GetLongDatabaseInfo(isc_info_no_reserve);
end;
function TIBDatabaseInfo.GetODSMinorVersion: Long;
begin
result := GetLongDatabaseInfo(isc_info_ods_minor_version);
end;
function TIBDatabaseInfo.GetODSMajorVersion: Long;
begin
result := GetLongDatabaseInfo(isc_info_ods_version);
end;
function TIBDatabaseInfo.GetPageSize: Long;
begin
result := GetLongDatabaseInfo(isc_info_page_size);
end;
function TIBDatabaseInfo.GetVersion: String;
var
local_buffer: array[0..IBBigLocalBufferLength - 1] of Char;
DatabaseInfoCommand: Char;
begin
DatabaseInfoCommand := Char(isc_info_version);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @DatabaseInfoCommand,
IBBigLocalBufferLength, local_buffer), True);
local_buffer[5 + Int(local_buffer[4])] := #0;
result := String(PChar(@local_buffer[5]));
end;
function TIBDatabaseInfo.GetCurrentMemory: Long;
begin
result := GetLongDatabaseInfo(isc_info_current_memory);
end;
function TIBDatabaseInfo.GetForcedWrites: Long;
begin
result := GetLongDatabaseInfo(isc_info_forced_writes);
end;
function TIBDatabaseInfo.GetMaxMemory: Long;
begin
result := GetLongDatabaseInfo(isc_info_max_memory);
end;
function TIBDatabaseInfo.GetNumBuffers: Long;
begin
result := GetLongDatabaseInfo(isc_info_num_buffers);
end;
function TIBDatabaseInfo.GetSweepInterval: Long;
begin
result := GetLongDatabaseInfo(isc_info_sweep_interval);
end;
function TIBDatabaseInfo.GetUserNames: TStringList;
var
local_buffer: array[0..IBHugeLocalBufferLength - 1] of Char;
temp_buffer: array[0..IBLocalBufferLength - 2] of Char;
DatabaseInfoCommand: Char;
i, user_length: Integer;
begin
result := FUserNames;
DatabaseInfoCommand := Char(isc_info_user_names);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @DatabaseInfoCommand,
IBHugeLocalBufferLength, local_buffer), True);
FUserNames.Clear;
i := 0;
while local_buffer[i] = Char(isc_info_user_names) do
begin
Inc(i, 3); { skip "isc_info_user_names byte" & two unknown bytes of structure (see below) }
user_length := Long(local_buffer[i]);
Inc(i,1);
Move(local_buffer[i], temp_buffer[0], user_length);
Inc(i, user_length);
temp_buffer[user_length] := #0;
FUserNames.Add(String(temp_buffer));
end;
end;
function TIBDatabaseInfo.GetFetches: Long;
begin
result := GetLongDatabaseInfo(isc_info_fetches);
end;
function TIBDatabaseInfo.GetMarks: Long;
begin
result := GetLongDatabaseInfo(isc_info_marks);
end;
function TIBDatabaseInfo.GetReads: Long;
begin
result := GetLongDatabaseInfo(isc_info_reads);
end;
function TIBDatabaseInfo.GetWrites: Long;
begin
result := GetLongDatabaseInfo(isc_info_writes);
end;
function TIBDatabaseInfo.GetOperationCounts(DBInfoCommand: Integer; FOperation: TStringList): TStringList;
var
local_buffer: array[0..IBHugeLocalBufferLength - 1] of Char;
DatabaseInfoCommand: Char;
i, qtd_tables, id_table, qtd_operations: Integer;
begin
if FOperation = nil then FOperation := TStringList.Create;
result := FOperation;
DatabaseInfoCommand := Char(DBInfoCommand);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @DatabaseInfoCommand,
IBHugeLocalBufferLength, local_buffer), True);
FOperation.Clear;
{ 1. 1 byte specifying the item type requested (e.g., isc_info_insert_count).
2. 2 bytes telling how many bytes compose the subsequent value pairs.
3. A pair of values for each table in the database on wich the requested
type of operation has occurred since the database was last attached.
Each pair consists of:
1. 2 bytes specifying the table ID.
2. 4 bytes listing the number of operations (e.g., inserts) done on that table.
}
qtd_tables := trunc(isc_vax_integer(@local_buffer[1],2)/6);
for i := 0 to qtd_tables - 1 do
begin
id_table := isc_vax_integer(@local_buffer[3+(i*6)],2);
qtd_operations := isc_vax_integer(@local_buffer[5+(i*6)],4);
FOperation.Add(IntToStr(id_table)+'='+IntToStr(qtd_operations));
end;
end;
function TIBDatabaseInfo.GetBackoutCount: TStringList;
begin
result := GetOperationCounts(isc_info_backout_count,FBackoutCount);
end;
function TIBDatabaseInfo.GetDeleteCount: TStringList;
begin
result := GetOperationCounts(isc_info_delete_count,FDeleteCount);
end;
function TIBDatabaseInfo.GetExpungeCount: TStringList;
begin
result := GetOperationCounts(isc_info_expunge_count,FExpungeCount);
end;
function TIBDatabaseInfo.GetInsertCount: TStringList;
begin
result := GetOperationCounts(isc_info_insert_count,FInsertCount);
end;
function TIBDatabaseInfo.GetPurgeCount: TStringList;
begin
result := GetOperationCounts(isc_info_purge_count,FPurgeCount);
end;
function TIBDatabaseInfo.GetReadIdxCount: TStringList;
begin
result := GetOperationCounts(isc_info_read_idx_count,FReadIdxCount);
end;
function TIBDatabaseInfo.GetReadSeqCount: TStringList;
begin
result := GetOperationCounts(isc_info_read_seq_count,FReadSeqCount);
end;
function TIBDatabaseInfo.GetUpdateCount: TStringList;
begin
result := GetOperationCounts(isc_info_update_count,FUpdateCount);
end;
function TIBDatabaseInfo.GetReadOnly: Long;
begin
result := GetLongDatabaseInfo(isc_info_db_read_only);
end;
function TIBDatabaseInfo.GetLongDatabaseInfo(DatabaseInfoCommand: Integer): Long;
var
local_buffer: array[0..IBLocalBufferLength - 1] of Char;
length: Integer;
_DatabaseInfoCommand: Char;
begin
_DatabaseInfoCommand := Char(DatabaseInfoCommand);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @_DatabaseInfoCommand,
IBLocalBufferLength, local_buffer), True);
length := isc_vax_integer(@local_buffer[1], 2);
result := isc_vax_integer(@local_buffer[3], length);
end;
function TIBDatabaseInfo.GetStringDatabaseInfo(DatabaseInfoCommand: Integer): String;
var
local_buffer: array[0..IBBigLocalBufferLength - 1] of Char;
_DatabaseInfoCommand: Char;
begin
_DatabaseInfoCommand := Char(DatabaseInfoCommand);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @_DatabaseInfoCommand,
IBBigLocalBufferLength, local_buffer), True);
local_buffer[4 + Int(local_buffer[3])] := #0;
result := String(PChar(@local_buffer[4]));
end;
function TIBDatabaseInfo.GetDBSQLDialect: Integer;
var
local_buffer: array[0..IBLocalBufferLength - 1] of Char;
length: Integer;
DatabaseInfoCommand: Char;
begin
DatabaseInfoCommand := Char(isc_info_db_SQL_Dialect);
Call(isc_database_info(StatusVector, @FDatabase.Handle, 1, @DatabaseInfoCommand,
IBLocalBufferLength, local_buffer), True);
if (local_buffer[0] <> Char(isc_info_db_SQL_dialect)) then
result := 1
else begin
length := isc_vax_integer(@local_buffer[1], 2);
result := isc_vax_integer(@local_buffer[3], length);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -