55 |
|
constructor CreateDatabase(sql: AnsiString; aSQLDialect: integer; |
56 |
|
RaiseExceptionOnError: boolean); overload; |
57 |
|
destructor Destroy; override; |
58 |
+ |
function GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; |
59 |
+ |
override; |
60 |
|
property AttachmentIntf: Firebird.IAttachment read FAttachmentIntf; |
61 |
|
|
62 |
|
public |
63 |
|
{IAttachment} |
64 |
|
procedure Connect; |
65 |
|
procedure Disconnect(Force: boolean=false); override; |
66 |
< |
function IsConnected: boolean; |
66 |
> |
function IsConnected: boolean; override; |
67 |
|
procedure DropDatabase; |
68 |
|
function StartTransaction(TPB: array of byte; DefaultCompletion: TTransactionCompletion): ITransaction; override; |
69 |
|
function StartTransaction(TPB: ITPB; DefaultCompletion: TTransactionCompletion): ITransaction; override; |
95 |
|
{Database Information} |
96 |
|
function GetBlobMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IBlobMetaData; |
97 |
|
function GetArrayMetaData(Transaction: ITransaction; tableName, columnName: AnsiString): IArrayMetaData; |
96 |
– |
function GetDBInformation(Requests: array of byte): IDBInformation; overload; |
97 |
– |
function GetDBInformation(Request: byte): IDBInformation; overload; |
98 |
|
end; |
99 |
|
|
100 |
|
implementation |
101 |
|
|
102 |
|
uses FB30Transaction, FB30Statement, FB30Array, FB30Blob, FBMessages, |
103 |
< |
FBOutputBlock, FB30Events; |
103 |
> |
FBOutputBlock, FB30Events, IBUtils; |
104 |
|
|
105 |
|
{ TFB30Attachment } |
106 |
|
|
151 |
|
begin |
152 |
|
Disconnect; |
153 |
|
Connect; |
154 |
< |
end; |
154 |
> |
end |
155 |
> |
else |
156 |
> |
GetODSAndConnectionInfo; |
157 |
|
end; |
158 |
|
end; |
159 |
|
|
160 |
|
constructor TFB30Attachment.CreateDatabase(sql: AnsiString; aSQLDialect: integer; |
161 |
|
RaiseExceptionOnError: boolean); |
162 |
|
var IsCreateDB: boolean; |
161 |
– |
info: IDBInformation; |
162 |
– |
ConnectionType: integer; |
163 |
– |
SiteName: AnsiString; |
163 |
|
begin |
164 |
|
inherited Create('',nil,RaiseExceptionOnError); |
165 |
|
FSQLDialect := aSQLDialect; |
170 |
|
if FRaiseExceptionOnConnectError then Check4DataBaseError; |
171 |
|
if InErrorState then |
172 |
|
FAttachmentIntf := nil; |
174 |
– |
FCharSetID := 0; |
175 |
– |
FCodePage := CP_NONE; |
176 |
– |
FHasDefaultCharSet := false; |
177 |
– |
info := GetDBInformation(isc_info_db_id); |
178 |
– |
info[0].DecodeIDCluster(ConnectionType,FDatabaseName,SiteName); |
173 |
|
end; |
174 |
+ |
GetODSAndConnectionInfo; |
175 |
+ |
ExtractConnectString(sql,FDatabaseName); |
176 |
+ |
DPBFromCreateSQL(sql); |
177 |
|
end; |
178 |
|
|
179 |
|
destructor TFB30Attachment.Destroy; |
183 |
|
FAttachmentIntf.release; |
184 |
|
end; |
185 |
|
|
186 |
+ |
function TFB30Attachment.GetDBInfo(ReqBuffer: PByte; ReqBufLen: integer): IDBInformation; |
187 |
+ |
begin |
188 |
+ |
Result := TDBInformation.Create; |
189 |
+ |
with Firebird30ClientAPI, Result as TDBInformation do |
190 |
+ |
begin |
191 |
+ |
FAttachmentIntf.getInfo(StatusIntf, ReqBufLen, BytePtr(ReqBuffer), |
192 |
+ |
getBufSize, BytePtr(Buffer)); |
193 |
+ |
Check4DataBaseError; |
194 |
+ |
end |
195 |
+ |
end; |
196 |
+ |
|
197 |
|
procedure TFB30Attachment.Connect; |
190 |
– |
var Param: IDPBItem; |
198 |
|
begin |
199 |
|
with Firebird30ClientAPI do |
200 |
|
begin |
205 |
|
if InErrorState then |
206 |
|
FAttachmentIntf := nil |
207 |
|
else |
208 |
< |
begin |
202 |
< |
Param := DPB.Find(isc_dpb_set_db_SQL_dialect); |
203 |
< |
if Param <> nil then |
204 |
< |
FSQLDialect := Param.AsByte; |
205 |
< |
Param := DPB.Find(isc_dpb_lc_ctype); |
206 |
< |
FHasDefaultCharSet := (Param <> nil) and |
207 |
< |
CharSetName2CharSetID(Param.AsString,FCharSetID) and |
208 |
< |
CharSetID2CodePage(FCharSetID,FCodePage) and |
209 |
< |
(FCharSetID > 1); |
210 |
< |
end; |
208 |
> |
GetODSAndConnectionInfo; |
209 |
|
end; |
210 |
|
end; |
211 |
|
|
354 |
|
Scale: integer; size: cardinal; aCharSetID: cardinal; dimensions: cardinal; |
355 |
|
bounds: TArrayBounds): IArrayMetaData; |
356 |
|
begin |
357 |
< |
Result := TFB30ArrayMetaData.Create(SQLType,tableName,ColumnName,Scale,size,aCharSetID, dimensions,bounds); |
357 |
> |
Result := TFB30ArrayMetaData.Create(self,SQLType,tableName,ColumnName,Scale,size,aCharSetID, dimensions,bounds); |
358 |
|
end; |
359 |
|
|
360 |
|
function TFB30Attachment.GetBlobMetaData(Transaction: ITransaction; tableName, |
371 |
|
Result := TFB30ArrayMetaData.Create(self,Transaction as TFB30Transaction,tableName,columnName); |
372 |
|
end; |
373 |
|
|
376 |
– |
function TFB30Attachment.GetDBInformation(Requests: array of byte |
377 |
– |
): IDBInformation; |
378 |
– |
var ReqBuffer: PByte; |
379 |
– |
i: integer; |
380 |
– |
begin |
381 |
– |
CheckHandle; |
382 |
– |
if Length(Requests) = 1 then |
383 |
– |
Result := GetDBInformation(Requests[0]) |
384 |
– |
else |
385 |
– |
begin |
386 |
– |
Result := TDBInformation.Create; |
387 |
– |
GetMem(ReqBuffer,Length(Requests)); |
388 |
– |
try |
389 |
– |
for i := 0 to Length(Requests) - 1 do |
390 |
– |
ReqBuffer[i] := Requests[i]; |
391 |
– |
|
392 |
– |
with Firebird30ClientAPI, Result as TDBInformation do |
393 |
– |
begin |
394 |
– |
FAttachmentIntf.getInfo(StatusIntf, Length(Requests), BytePtr(ReqBuffer), |
395 |
– |
getBufSize, BytePtr(Buffer)); |
396 |
– |
Check4DataBaseError; |
397 |
– |
end |
398 |
– |
|
399 |
– |
finally |
400 |
– |
FreeMem(ReqBuffer); |
401 |
– |
end; |
402 |
– |
end; |
403 |
– |
end; |
404 |
– |
|
405 |
– |
function TFB30Attachment.GetDBInformation(Request: byte): IDBInformation; |
406 |
– |
begin |
407 |
– |
CheckHandle; |
408 |
– |
Result := TDBInformation.Create; |
409 |
– |
with Firebird30ClientAPI, Result as TDBInformation do |
410 |
– |
begin |
411 |
– |
FAttachmentIntf.getInfo(StatusIntf, 1, BytePtr(@Request), |
412 |
– |
getBufSize, BytePtr(Buffer)); |
413 |
– |
Check4DataBaseError; |
414 |
– |
end; |
415 |
– |
end; |
416 |
– |
|
374 |
|
end. |
375 |
|
|