38 |
|
interface |
39 |
|
|
40 |
|
uses |
41 |
< |
Classes, SysUtils, {$IFDEF WINDOWS} windows, {$ENDIF} IB, FBParamBlock, FBActivityMonitor; |
41 |
> |
Classes, SysUtils, {$IFDEF WINDOWS} windows, {$ENDIF} IB, FBParamBlock, |
42 |
> |
FBActivityMonitor, FBClientAPI; |
43 |
|
|
44 |
|
type |
45 |
|
TCharsetMap = record |
59 |
|
FODSMajorVersion: integer; |
60 |
|
FODSMinorVersion: integer; |
61 |
|
FUserCharSetMap: array of TCharSetMap; |
62 |
+ |
FSecDatabase: AnsiString; |
63 |
|
protected |
64 |
|
FDatabaseName: AnsiString; |
65 |
|
FRaiseExceptionOnConnectError: boolean; |
69 |
|
FCodePage: TSystemCodePage; |
70 |
|
FRemoteProtocol: AnsiString; |
71 |
|
FAuthMethod: AnsiString; |
72 |
< |
constructor Create(DatabaseName: AnsiString; DPB: IDPB; |
72 |
> |
constructor Create(api: TFBClientAPI; DatabaseName: AnsiString; DPB: IDPB; |
73 |
|
RaiseExceptionOnConnectError: boolean); |
74 |
|
procedure CheckHandle; virtual; abstract; |
75 |
|
function GenerateCreateDatabaseSQL(DatabaseName: AnsiString; aDPB: IDPB): AnsiString; |
81 |
|
procedure SetParameters(SQLParams: ISQLParams; params: array of const); |
82 |
|
public |
83 |
|
destructor Destroy; override; |
84 |
+ |
function getFirebirdAPI: IFirebirdAPI; |
85 |
|
function getDPB: IDPB; |
86 |
|
function AllocateBPB: IBPB; |
87 |
|
function AllocateDIRB: IDIRB; |
132 |
|
function GetConnectString: AnsiString; |
133 |
|
function GetRemoteProtocol: AnsiString; |
134 |
|
function GetAuthenticationMethod: AnsiString; |
135 |
+ |
function GetSecurityDatabase: AnsiString; |
136 |
|
function GetODSMajorVersion: integer; |
137 |
|
function GetODSMinorVersion: integer; |
138 |
|
{Character Sets} |
256 |
|
FCharSetID := 0; |
257 |
|
FRemoteProtocol := ''; |
258 |
|
FAuthMethod := 'Legacy_Auth'; |
259 |
+ |
FSecDatabase := 'Default'; |
260 |
|
if FODSMajorVersion > 11 then |
261 |
|
begin |
262 |
|
Stmt := Prepare(StartTransaction([isc_tpb_read,isc_tpb_nowait,isc_tpb_concurrency],taCommit), |
263 |
< |
'Select MON$CHARACTER_SET_ID, MON$REMOTE_PROTOCOL, MON$AUTH_METHOD From MON$ATTACHMENTS '+ |
263 |
> |
'Select MON$CHARACTER_SET_ID, MON$REMOTE_PROTOCOL, MON$AUTH_METHOD, MON$SEC_DATABASE From MON$ATTACHMENTS, MON$DATABASE '+ |
264 |
|
'Where MON$ATTACHMENT_ID = CURRENT_CONNECTION'); |
265 |
|
ResultSet := Stmt.OpenCursor; |
266 |
|
if ResultSet.FetchNext then |
267 |
|
begin |
268 |
|
FCharSetID := ResultSet[0].AsInteger; |
269 |
< |
FRemoteProtocol := ResultSet[1].AsString; |
270 |
< |
FAuthMethod := ResultSet[2].AsString; |
269 |
> |
FRemoteProtocol := Trim(ResultSet[1].AsString); |
270 |
> |
FAuthMethod := Trim(ResultSet[2].AsString); |
271 |
> |
FSecDatabase := Trim(ResultSet[3].AsString); |
272 |
|
end |
273 |
|
end |
274 |
|
else |
281 |
|
if ResultSet.FetchNext then |
282 |
|
begin |
283 |
|
FCharSetID := ResultSet[0].AsInteger; |
284 |
< |
FRemoteProtocol := ResultSet[1].AsString; |
284 |
> |
FRemoteProtocol := Trim(ResultSet[1].AsString); |
285 |
|
end |
286 |
|
end |
287 |
|
else |
300 |
|
FHasDefaultCharSet := CharSetID2CodePage(FCharSetID,FCodePage) and (FCharSetID > 1); |
301 |
|
end; |
302 |
|
|
303 |
< |
constructor TFBAttachment.Create(DatabaseName: AnsiString; DPB: IDPB; |
304 |
< |
RaiseExceptionOnConnectError: boolean); |
303 |
> |
constructor TFBAttachment.Create(api: TFBClientAPI; DatabaseName: AnsiString; |
304 |
> |
DPB: IDPB; RaiseExceptionOnConnectError: boolean); |
305 |
|
begin |
306 |
|
inherited Create; |
307 |
< |
FFirebirdAPI := FirebirdAPI; {Keep reference to interface} |
307 |
> |
FFirebirdAPI := api.GetAPI; {Keep reference to interface} |
308 |
|
FSQLDialect := 3; |
309 |
|
FDatabaseName := DatabaseName; |
310 |
|
FDPB := DPB; |
451 |
|
inherited Destroy; |
452 |
|
end; |
453 |
|
|
454 |
+ |
function TFBAttachment.getFirebirdAPI: IFirebirdAPI; |
455 |
+ |
begin |
456 |
+ |
Result := FFirebirdAPI; |
457 |
+ |
end; |
458 |
+ |
|
459 |
|
function TFBAttachment.getDPB: IDPB; |
460 |
|
begin |
461 |
|
Result := FDPB; |
463 |
|
|
464 |
|
function TFBAttachment.AllocateBPB: IBPB; |
465 |
|
begin |
466 |
< |
Result := TBPB.Create; |
466 |
> |
Result := TBPB.Create(FFirebirdAPI as TFBClientAPI); |
467 |
|
end; |
468 |
|
|
469 |
|
function TFBAttachment.AllocateDIRB: IDIRB; |
470 |
|
begin |
471 |
< |
Result := TDIRB.Create; |
471 |
> |
Result := TDIRB.Create(FFirebirdAPI as TFBClientAPI); |
472 |
|
end; |
473 |
|
|
474 |
|
procedure TFBAttachment.ExecImmediate(TPB: array of byte; sql: AnsiString; |
670 |
|
Result := FAuthMethod; |
671 |
|
end; |
672 |
|
|
673 |
+ |
function TFBAttachment.GetSecurityDatabase: AnsiString; |
674 |
+ |
begin |
675 |
+ |
Result := FSecDatabase; |
676 |
+ |
end; |
677 |
+ |
|
678 |
|
function TFBAttachment.GetODSMajorVersion: integer; |
679 |
|
begin |
680 |
|
Result := FODSMajorVersion; |
764 |
|
begin |
765 |
|
Result := false; |
766 |
|
for i := Low(CharSetMap) to High(CharSetMap) do |
767 |
< |
if AnsiCompareStr(CharSetMap[i].CharSetName, CharSetName) = 0 then |
767 |
> |
if AnsiCompareText(CharSetMap[i].CharSetName, CharSetName) = 0 then |
768 |
|
begin |
769 |
|
CharSetID := CharSetMap[i].CharSetID; |
770 |
|
Result := true; |
772 |
|
end; |
773 |
|
|
774 |
|
for i := 0 to Length(FUserCharSetMap) - 1 do |
775 |
< |
if AnsiCompareStr(FUserCharSetMap[i].CharSetName, CharSetName) = 0 then |
775 |
> |
if AnsiCompareText(FUserCharSetMap[i].CharSetName, CharSetName) = 0 then |
776 |
|
begin |
777 |
|
CharSetID := FUserCharSetMap[i].CharSetID; |
778 |
|
Result := true; |