46 |
|
TFB30Attachment = class(TFBAttachment,IAttachment, IActivityMonitor) |
47 |
|
private |
48 |
|
FAttachmentIntf: Firebird.IAttachment; |
49 |
+ |
FFirebird30ClientAPI: TFB30ClientAPI; |
50 |
|
protected |
51 |
|
procedure CheckHandle; override; |
52 |
|
public |
53 |
< |
constructor Create(DatabaseName: AnsiString; aDPB: IDPB; |
53 |
> |
constructor Create(api: TFB30ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; |
54 |
|
RaiseExceptionOnConnectError: boolean); |
55 |
< |
constructor CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB; RaiseExceptionOnError: boolean); overload; |
56 |
< |
constructor CreateDatabase(sql: AnsiString; aSQLDialect: integer; |
55 |
> |
constructor CreateDatabase(api: TFB30ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; RaiseExceptionOnError: boolean); overload; |
56 |
> |
constructor CreateDatabase(api: TFB30ClientAPI; sql: AnsiString; aSQLDialect: integer; |
57 |
|
RaiseExceptionOnError: boolean); overload; |
58 |
|
destructor Destroy; override; |
59 |
+ |
function GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; |
60 |
+ |
override; |
61 |
|
property AttachmentIntf: Firebird.IAttachment read FAttachmentIntf; |
62 |
+ |
property Firebird30ClientAPI: TFB30ClientAPI read FFirebird30ClientAPI; |
63 |
|
|
64 |
|
public |
65 |
|
{IAttachment} |
91 |
|
function CreateArray(transaction: ITransaction; ArrayMetaData: IArrayMetaData): IArray; overload; |
92 |
|
function CreateArrayMetaData(SQLType: cardinal; tableName: AnsiString; |
93 |
|
columnName: AnsiString; Scale: integer; size: cardinal; aCharSetID: cardinal; |
94 |
< |
dimensions: cardinal; bounds: TArrayBounds): IArrayMetaData; |
94 |
> |
dimensions: cardinal; bounds: TArrayBounds): IArrayMetaData; |
95 |
|
|
96 |
|
|
97 |
|
{Database Information} |
98 |
|
function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData; |
99 |
|
function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; |
96 |
– |
function GetDBInformation(Requests: array of byte): IDBInformation; overload; override; |
97 |
– |
function GetDBInformation(Request: byte): IDBInformation; overload; override; |
100 |
|
end; |
101 |
|
|
102 |
|
implementation |
112 |
|
IBError(ibxeDatabaseClosed,[nil]); |
113 |
|
end; |
114 |
|
|
115 |
< |
constructor TFB30Attachment.Create(DatabaseName: AnsiString; aDPB: IDPB; |
115 |
> |
constructor TFB30Attachment.Create(api: TFB30ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; |
116 |
|
RaiseExceptionOnConnectError: boolean); |
117 |
|
begin |
118 |
+ |
FFirebird30ClientAPI := api; |
119 |
|
if aDPB = nil then |
120 |
|
begin |
121 |
|
if RaiseExceptionOnConnectError then |
122 |
|
IBError(ibxeNoDPB,[nil]); |
123 |
|
Exit; |
124 |
|
end; |
125 |
< |
inherited Create(DatabaseName,aDPB,RaiseExceptionOnConnectError); |
125 |
> |
inherited Create(api,DatabaseName,aDPB,RaiseExceptionOnConnectError); |
126 |
|
Connect; |
127 |
|
end; |
128 |
|
|
129 |
< |
constructor TFB30Attachment.CreateDatabase(DatabaseName: AnsiString; aDPB: IDPB; |
129 |
> |
constructor TFB30Attachment.CreateDatabase(api: TFB30ClientAPI; DatabaseName: AnsiString; aDPB: IDPB; |
130 |
|
RaiseExceptionOnError: boolean); |
131 |
|
var Param: IDPBItem; |
132 |
|
sql: AnsiString; |
133 |
|
IsCreateDB: boolean; |
134 |
|
begin |
135 |
< |
inherited Create(DatabaseName,aDPB,RaiseExceptionOnError); |
135 |
> |
inherited Create(api,DatabaseName,aDPB,RaiseExceptionOnError); |
136 |
> |
FFirebird30ClientAPI := api; |
137 |
|
IsCreateDB := true; |
138 |
|
if aDPB <> nil then |
139 |
|
begin |
142 |
|
FSQLDialect := Param.AsByte; |
143 |
|
end; |
144 |
|
sql := GenerateCreateDatabaseSQL(DatabaseName,aDPB); |
145 |
< |
with Firebird30ClientAPI do |
145 |
> |
with FFirebird30ClientAPI do |
146 |
|
begin |
147 |
|
FAttachmentIntf := UtilIntf.executeCreateDatabase(StatusIntf,Length(sql), |
148 |
|
PAnsiChar(sql),FSQLDialect,@IsCreateDB); |
161 |
|
end; |
162 |
|
end; |
163 |
|
|
164 |
< |
constructor TFB30Attachment.CreateDatabase(sql: AnsiString; aSQLDialect: integer; |
164 |
> |
constructor TFB30Attachment.CreateDatabase(api: TFB30ClientAPI; sql: AnsiString; aSQLDialect: integer; |
165 |
|
RaiseExceptionOnError: boolean); |
166 |
|
var IsCreateDB: boolean; |
167 |
|
begin |
168 |
< |
inherited Create('',nil,RaiseExceptionOnError); |
168 |
> |
inherited Create(api,'',nil,RaiseExceptionOnError); |
169 |
> |
FFirebird30ClientAPI := api; |
170 |
|
FSQLDialect := aSQLDialect; |
171 |
< |
with Firebird30ClientAPI do |
171 |
> |
with FFirebird30ClientAPI do |
172 |
|
begin |
173 |
|
FAttachmentIntf := UtilIntf.executeCreateDatabase(StatusIntf,Length(sql), |
174 |
|
PAnsiChar(sql),aSQLDialect,@IsCreateDB); |
188 |
|
FAttachmentIntf.release; |
189 |
|
end; |
190 |
|
|
191 |
+ |
function TFB30Attachment.GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; |
192 |
+ |
begin |
193 |
+ |
Result := TDBInformation.Create(Firebird30ClientAPI); |
194 |
+ |
with FFirebird30ClientAPI, Result as TDBInformation do |
195 |
+ |
begin |
196 |
+ |
FAttachmentIntf.getInfo(StatusIntf, ReqBufLen, BytePtr(ReqBuffer), |
197 |
+ |
getBufSize, BytePtr(Buffer)); |
198 |
+ |
Check4DataBaseError; |
199 |
+ |
end |
200 |
+ |
end; |
201 |
+ |
|
202 |
|
procedure TFB30Attachment.Connect; |
203 |
|
begin |
204 |
< |
with Firebird30ClientAPI do |
204 |
> |
with FFirebird30ClientAPI do |
205 |
|
begin |
206 |
|
FAttachmentIntf := ProviderIntf.attachDatabase(StatusIntf,PAnsiChar(FDatabaseName), |
207 |
|
(DPB as TDPB).getDataLength, |
217 |
|
procedure TFB30Attachment.Disconnect(Force: boolean); |
218 |
|
begin |
219 |
|
if IsConnected then |
220 |
< |
with Firebird30ClientAPI do |
220 |
> |
with FFirebird30ClientAPI do |
221 |
|
begin |
222 |
|
EndAllTransactions; |
223 |
|
FAttachmentIntf.Detach(StatusIntf); |
238 |
|
procedure TFB30Attachment.DropDatabase; |
239 |
|
begin |
240 |
|
if IsConnected then |
241 |
< |
with Firebird30ClientAPI do |
241 |
> |
with FFirebird30ClientAPI do |
242 |
|
begin |
243 |
|
EndAllTransactions; |
244 |
|
FAttachmentIntf.dropDatabase(StatusIntf); |
251 |
|
DefaultCompletion: TTransactionCompletion): ITransaction; |
252 |
|
begin |
253 |
|
CheckHandle; |
254 |
< |
Result := TFB30Transaction.Create(self,TPB,DefaultCompletion); |
254 |
> |
Result := TFB30Transaction.Create(FFirebird30ClientAPI,self,TPB,DefaultCompletion); |
255 |
|
end; |
256 |
|
|
257 |
|
function TFB30Attachment.StartTransaction(TPB: ITPB; |
258 |
|
DefaultCompletion: TTransactionCompletion): ITransaction; |
259 |
|
begin |
260 |
|
CheckHandle; |
261 |
< |
Result := TFB30Transaction.Create(self,TPB,DefaultCompletion); |
261 |
> |
Result := TFB30Transaction.Create(FFirebird30ClientAPI,self,TPB,DefaultCompletion); |
262 |
|
end; |
263 |
|
|
264 |
|
procedure TFB30Attachment.ExecImmediate(transaction: ITransaction; sql: AnsiString; |
265 |
|
aSQLDialect: integer); |
266 |
|
begin |
267 |
|
CheckHandle; |
268 |
< |
with Firebird30ClientAPI do |
268 |
> |
with FFirebird30ClientAPI do |
269 |
|
begin |
270 |
|
FAttachmentIntf.execute(StatusIntf,(transaction as TFB30Transaction).TransactionIntf, |
271 |
|
Length(sql),PAnsiChar(sql),aSQLDialect,nil,nil,nil,nil); |
376 |
|
Result := TFB30ArrayMetaData.Create(self,Transaction as TFB30Transaction,tableName,columnName); |
377 |
|
end; |
378 |
|
|
363 |
– |
function TFB30Attachment.GetDBInformation(Requests: array of byte |
364 |
– |
): IDBInformation; |
365 |
– |
var ReqBuffer: PByte; |
366 |
– |
i: integer; |
367 |
– |
begin |
368 |
– |
CheckHandle; |
369 |
– |
if Length(Requests) = 1 then |
370 |
– |
Result := GetDBInformation(Requests[0]) |
371 |
– |
else |
372 |
– |
begin |
373 |
– |
Result := TDBInformation.Create; |
374 |
– |
GetMem(ReqBuffer,Length(Requests)); |
375 |
– |
try |
376 |
– |
for i := 0 to Length(Requests) - 1 do |
377 |
– |
ReqBuffer[i] := Requests[i]; |
378 |
– |
|
379 |
– |
with Firebird30ClientAPI, Result as TDBInformation do |
380 |
– |
begin |
381 |
– |
FAttachmentIntf.getInfo(StatusIntf, Length(Requests), BytePtr(ReqBuffer), |
382 |
– |
getBufSize, BytePtr(Buffer)); |
383 |
– |
Check4DataBaseError; |
384 |
– |
end |
385 |
– |
|
386 |
– |
finally |
387 |
– |
FreeMem(ReqBuffer); |
388 |
– |
end; |
389 |
– |
end; |
390 |
– |
end; |
391 |
– |
|
392 |
– |
function TFB30Attachment.GetDBInformation(Request: byte): IDBInformation; |
393 |
– |
begin |
394 |
– |
CheckHandle; |
395 |
– |
Result := TDBInformation.Create; |
396 |
– |
with Firebird30ClientAPI, Result as TDBInformation do |
397 |
– |
begin |
398 |
– |
FAttachmentIntf.getInfo(StatusIntf, 1, BytePtr(@Request), |
399 |
– |
getBufSize, BytePtr(Buffer)); |
400 |
– |
Check4DataBaseError; |
401 |
– |
end; |
402 |
– |
end; |
403 |
– |
|
379 |
|
end. |
380 |
|
|