1 |
tony |
45 |
unit Test9; |
2 |
tony |
56 |
{$IFDEF MSWINDOWS} |
3 |
|
|
{$DEFINE WINDOWS} |
4 |
|
|
{$ENDIF} |
5 |
tony |
45 |
|
6 |
tony |
56 |
{$IFDEF FPC} |
7 |
|
|
{$mode delphi} |
8 |
tony |
45 |
{$codepage utf8} |
9 |
tony |
56 |
{$ENDIF} |
10 |
tony |
45 |
|
11 |
|
|
{Test 9: Database Information tests} |
12 |
|
|
|
13 |
|
|
{ |
14 |
|
|
This test opens the employee example databases with the supplied user name/password |
15 |
|
|
and then reads and prints all defined database information. |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
interface |
19 |
|
|
|
20 |
|
|
uses |
21 |
|
|
Classes, SysUtils, TestManager, IB; |
22 |
|
|
|
23 |
|
|
type |
24 |
|
|
|
25 |
|
|
{ TTest9 } |
26 |
|
|
|
27 |
|
|
TTest9 = class(TTestBase) |
28 |
|
|
private |
29 |
|
|
procedure GetDBInformation(Attachment: IAttachment); |
30 |
|
|
public |
31 |
tony |
56 |
function TestTitle: AnsiString; override; |
32 |
|
|
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
33 |
tony |
45 |
end; |
34 |
|
|
|
35 |
|
|
implementation |
36 |
|
|
|
37 |
|
|
{ TTest9 } |
38 |
|
|
|
39 |
|
|
procedure TTest9.GetDBInformation(Attachment: IAttachment); |
40 |
|
|
var DBInfo: IDBInformation; |
41 |
tony |
143 |
DBRequest: IDIRB; |
42 |
tony |
45 |
begin |
43 |
tony |
143 |
{First check ODS version to avoid information requests supported DB 2.5 and later} |
44 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_ods_version,isc_info_ods_minor_version]); |
45 |
|
|
if (DBInfo.Count > 1) and (DBInfo[0].AsInteger > 11) or |
46 |
|
|
((DBInfo[0].AsInteger = 11) and (DBInfo[1].AsInteger > 1)) then |
47 |
|
|
begin |
48 |
|
|
WriteDBInfo(Attachment.GetDBInformation(isc_info_db_id)); |
49 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_allocation,isc_info_base_level, |
50 |
tony |
45 |
isc_info_implementation,isc_info_no_reserve,isc_info_ods_minor_version, |
51 |
tony |
143 |
isc_info_ods_version,isc_info_page_size,isc_info_version,isc_info_db_read_only, |
52 |
|
|
isc_info_creation_date,fb_info_pages_used,fb_info_pages_free]); |
53 |
|
|
WriteDBInfo(DBInfo); |
54 |
|
|
|
55 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_current_memory, isc_info_forced_writes, |
56 |
|
|
isc_info_max_memory, isc_info_num_buffers, isc_info_sweep_interval, |
57 |
|
|
isc_info_user_names,isc_info_active_tran_count]); |
58 |
|
|
WriteDBInfo(DBInfo); |
59 |
|
|
|
60 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_fetches,isc_info_marks, |
61 |
|
|
isc_info_reads, isc_info_writes]); |
62 |
|
|
WriteDBInfo(DBInfo); |
63 |
|
|
|
64 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_backout_count, isc_info_delete_count, |
65 |
|
|
isc_info_expunge_count,isc_info_insert_count, isc_info_purge_count, |
66 |
|
|
isc_info_read_idx_count, isc_info_read_seq_count, isc_info_update_count]); |
67 |
|
|
WriteDBInfo(DBInfo); |
68 |
|
|
|
69 |
|
|
DBRequest := Attachment.AllocateDIRB; |
70 |
|
|
|
71 |
|
|
DBRequest.Add(isc_info_page_size); |
72 |
|
|
|
73 |
|
|
{Only enable during unit test. This result will always be different for |
74 |
|
|
each run and you will only get false positives in the log} |
75 |
|
|
// DBRequest.Add(fb_info_page_contents).AsInteger := 100; |
76 |
|
|
WriteDBInfo(Attachment.GetDBInformation(DBRequest)); |
77 |
|
|
end |
78 |
|
|
else |
79 |
|
|
begin |
80 |
|
|
WriteDBInfo(Attachment.GetDBInformation(isc_info_db_id)); |
81 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_allocation,isc_info_base_level, |
82 |
|
|
isc_info_implementation,isc_info_no_reserve,isc_info_ods_minor_version, |
83 |
tony |
61 |
isc_info_ods_version,isc_info_page_size,isc_info_version,isc_info_db_read_only]); |
84 |
tony |
45 |
WriteDBInfo(DBInfo); |
85 |
|
|
|
86 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_current_memory, isc_info_forced_writes, |
87 |
|
|
isc_info_max_memory, isc_info_num_buffers, isc_info_sweep_interval, |
88 |
|
|
isc_info_user_names]); |
89 |
|
|
WriteDBInfo(DBInfo); |
90 |
|
|
|
91 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_fetches,isc_info_marks, |
92 |
|
|
isc_info_reads, isc_info_writes]); |
93 |
|
|
WriteDBInfo(DBInfo); |
94 |
|
|
|
95 |
|
|
DBInfo := Attachment.GetDBInformation([isc_info_backout_count, isc_info_delete_count, |
96 |
|
|
isc_info_expunge_count,isc_info_insert_count, isc_info_purge_count, |
97 |
|
|
isc_info_read_idx_count, isc_info_read_seq_count, isc_info_update_count]); |
98 |
|
|
WriteDBInfo(DBInfo); |
99 |
tony |
143 |
|
100 |
|
|
DBRequest := Attachment.AllocateDIRB; |
101 |
|
|
DBRequest.Add(isc_info_page_size); |
102 |
|
|
WriteDBInfo(Attachment.GetDBInformation(DBRequest)); |
103 |
|
|
end; |
104 |
tony |
45 |
end; |
105 |
|
|
|
106 |
tony |
56 |
function TTest9.TestTitle: AnsiString; |
107 |
tony |
45 |
begin |
108 |
|
|
Result := 'Test 9: Database Information tests'; |
109 |
|
|
end; |
110 |
|
|
|
111 |
tony |
56 |
procedure TTest9.RunTest(CharSet: AnsiString; SQLDialect: integer); |
112 |
tony |
45 |
var DPB: IDPB; |
113 |
|
|
Attachment: IAttachment; |
114 |
|
|
begin |
115 |
|
|
DPB := FirebirdAPI.AllocateDPB; |
116 |
|
|
DPB.Add(isc_dpb_user_name).setAsString(Owner.GetUserName); |
117 |
|
|
DPB.Add(isc_dpb_password).setAsString(Owner.GetPassword); |
118 |
|
|
DPB.Add(isc_dpb_lc_ctype).setAsString(CharSet); |
119 |
|
|
DPB.Add(isc_dpb_set_db_SQL_dialect).setAsByte(SQLDialect); |
120 |
|
|
Attachment := FirebirdAPI.OpenDatabase(Owner.GetEmployeeDatabaseName,DPB); |
121 |
|
|
|
122 |
|
|
GetDBInformation(Attachment); |
123 |
|
|
end; |
124 |
|
|
|
125 |
|
|
initialization |
126 |
|
|
RegisterTest(TTest9); |
127 |
|
|
|
128 |
|
|
end. |
129 |
|
|
|