17 |
|
{$IFDEF FPC} |
18 |
|
{$mode delphi} |
19 |
|
{$codepage utf8} |
20 |
+ |
{$define HASREQEX} |
21 |
|
{$ENDIF} |
22 |
|
|
23 |
|
interface |
32 |
|
TTest1 = class(TTestBase) |
33 |
|
private |
34 |
|
procedure DoQuery(Attachment: IAttachment); |
35 |
+ |
procedure WriteAttachmentInfo(Attachment: IAttachment); |
36 |
|
public |
37 |
|
function TestTitle: AnsiString; override; |
38 |
|
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
64 |
|
end; |
65 |
|
end; |
66 |
|
|
67 |
+ |
procedure TTest1.WriteAttachmentInfo(Attachment: IAttachment); |
68 |
+ |
begin |
69 |
+ |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
70 |
+ |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
71 |
+ |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
72 |
+ |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
73 |
+ |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
74 |
+ |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
75 |
+ |
writeln(outfile,'User Authentication Method = ',Attachment.GetAuthenticationMethod); |
76 |
+ |
writeln(outfile,'Firebird Library Path = ',Attachment.getFirebirdAPI.GetFBLibrary.GetLibraryFilePath); |
77 |
+ |
writeln(outfile,'DB Client Implementation Version = ',Attachment.getFirebirdAPI.GetImplementationVersion); |
78 |
+ |
end; |
79 |
+ |
|
80 |
|
function TTest1.TestTitle: AnsiString; |
81 |
|
begin |
82 |
|
Result := 'Test 1: Create and Drop a Database'; |
86 |
|
var DPB: IDPB; |
87 |
|
Attachment: IAttachment; |
88 |
|
createSQL: AnsiString; |
89 |
+ |
libpath: string; |
90 |
+ |
FBLibrary: IFirebirdLibrary; |
91 |
|
begin |
92 |
|
writeln(OutFile,'Creating a Database with empty parameters'); |
93 |
|
Attachment := FirebirdAPI.CreateDatabase('',nil,false); |
101 |
|
[Owner.GetNewDatabaseName, Owner.GetUserName, Owner.GetPassword, CharSet]); |
102 |
|
Attachment := FirebirdAPI.CreateDatabase(createSQL,SQLDialect); |
103 |
|
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_db_SQL_Dialect])); |
104 |
< |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
88 |
< |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
89 |
< |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
90 |
< |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
91 |
< |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
92 |
< |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
104 |
> |
WriteAttachmentInfo(Attachment); |
105 |
|
PrintDPB(Attachment.getDPB); |
106 |
|
|
107 |
+ |
{$IFDEF HASREQEX} |
108 |
|
{Demonstrate reconnect when database created with SQL Statement} |
109 |
< |
Attachment.Disconnect; |
110 |
< |
Attachment.Connect; |
109 |
> |
try |
110 |
> |
Attachment.Disconnect; |
111 |
> |
Attachment.Connect; |
112 |
> |
except on E:Exception do |
113 |
> |
writeln(OutFile,'Error reconnecting to Database: ',E.Message); |
114 |
> |
end; |
115 |
> |
{$ENDIF} |
116 |
|
|
117 |
|
writeln(OutFile,'Dropping Database'); |
118 |
|
if Attachment <> nil then |
127 |
|
|
128 |
|
Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); |
129 |
|
|
130 |
< |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
113 |
< |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
114 |
< |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
115 |
< |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
116 |
< |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
117 |
< |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
130 |
> |
WriteAttachmentInfo(Attachment); |
131 |
|
|
132 |
|
writeln(OutFile,'Dropping Database'); |
133 |
|
if Attachment <> nil then |
144 |
|
Exit; |
145 |
|
end; |
146 |
|
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version])); |
147 |
< |
writeln(outfile,'DB Connect String = ',Attachment.GetConnectString); |
135 |
< |
writeln(outfile,'DB Charset ID = ',Attachment.GetDefaultCharSetID); |
136 |
< |
writeln(outfile,'DB SQL Dialect = ',Attachment.GetSQLDialect); |
137 |
< |
writeln(outfile,'DB Remote Protocol = ', Attachment.GetRemoteProtocol); |
138 |
< |
writeln(outfile,'DB ODS Major Version = ',Attachment.GetODSMajorVersion); |
139 |
< |
writeln(outfile,'DB ODS Minor Version = ',Attachment.GetODSMinorVersion); |
147 |
> |
WriteAttachmentInfo(Attachment); |
148 |
|
|
149 |
|
{Querying Database} |
150 |
|
DoQuery(Attachment); |
151 |
|
|
152 |
|
writeln(OutFile,'Dropping Database'); |
153 |
|
Attachment.DropDatabase; |
154 |
+ |
|
155 |
+ |
libpath := GetEnvironmentVariable('TESTFIREBIRDLIBRARY'); |
156 |
+ |
if libpath <> '' then |
157 |
+ |
begin |
158 |
+ |
FBLibrary := LoadFBLibrary(libpath); |
159 |
+ |
|
160 |
+ |
writeln(OutFile,'Creating a Database with a DPD using Firebird Library in ',libpath); |
161 |
+ |
Attachment := FBLibrary.GetFirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB); |
162 |
+ |
if Attachment = nil then |
163 |
+ |
begin |
164 |
+ |
writeln(OutFile,'Create Database Failed'); |
165 |
+ |
Exit; |
166 |
+ |
end; |
167 |
+ |
WriteDBInfo(Attachment.GetDBInformation([isc_info_db_id,isc_info_ods_version,isc_info_ods_minor_version])); |
168 |
+ |
WriteAttachmentInfo(Attachment); |
169 |
+ |
|
170 |
+ |
{Querying Database} |
171 |
+ |
DoQuery(Attachment); |
172 |
+ |
|
173 |
+ |
writeln(OutFile,'Dropping Database'); |
174 |
+ |
Attachment.DropDatabase; |
175 |
+ |
end; |
176 |
|
end; |
177 |
|
|
178 |
|
|