221 |
|
function GetRemoteProtocol: string; |
222 |
|
function GetSQLObjectsCount: Integer; |
223 |
|
function GetWireCompression: boolean; |
224 |
+ |
procedure SetAttachment(AValue: IAttachment); |
225 |
|
procedure SetConfigOverrides(AValue: TStrings); |
226 |
|
procedure SetFirebirdLibraryPathName(AValue: TIBFileName); |
227 |
|
procedure SetSQLDialect(const Value: Integer); |
247 |
|
procedure RemoveSQLObject(Idx: Integer); |
248 |
|
procedure RemoveSQLObjects; |
249 |
|
procedure InternalClose; |
250 |
+ |
procedure InternalBeforeClose; |
251 |
+ |
procedure InternalAfterClose; |
252 |
+ |
procedure InternalBeforeConnect(aDBParams: TStrings; var aDBName: string; |
253 |
+ |
var aCreateIfNotExists: boolean); |
254 |
+ |
procedure InternalAfterConnect; |
255 |
|
procedure DoOnCreateDatabase; |
256 |
|
|
257 |
|
protected |
288 |
|
procedure RemoveTransaction(Idx: Integer); |
289 |
|
procedure RemoveTransactions; |
290 |
|
|
291 |
< |
property Attachment: IAttachment read FAttachment; |
291 |
> |
property Attachment: IAttachment read FAttachment write SetAttachment; |
292 |
|
property FirebirdAPI: IFirebirdAPI read GetFirebirdAPI; |
293 |
|
property DBSQLDialect : Integer read GetDBSQLDialect; |
294 |
|
property IsReadOnly: Boolean read GetIsReadOnly; |
522 |
|
implementation |
523 |
|
|
524 |
|
uses IBSQLMonitor, IBCustomDataSet, IBDatabaseInfo, IBSQL, IBUtils, |
525 |
< |
typInfo, FBMessages, IBErrorCodes {$IFDEF WINDOWS}, Windirs {$ENDIF}; |
525 |
> |
typInfo, IBMessages, IBErrorCodes {$IFDEF WINDOWS}, Windirs {$ENDIF}; |
526 |
|
|
527 |
|
{ TIBDatabase } |
528 |
|
|
816 |
|
end; |
817 |
|
|
818 |
|
procedure TIBDataBase.InternalClose; |
819 |
+ |
begin |
820 |
+ |
CheckActive; |
821 |
+ |
InternalBeforeClose; |
822 |
+ |
case FCloseAction of |
823 |
+ |
caNormal: |
824 |
+ |
FAttachment.Disconnect(false); |
825 |
+ |
caForce: |
826 |
+ |
FAttachment.Disconnect(true); |
827 |
+ |
caDropDatabase: |
828 |
+ |
FAttachment.DropDatabase; |
829 |
+ |
end; |
830 |
+ |
FAttachment := nil; |
831 |
+ |
FHiddenPassword := ''; |
832 |
+ |
FCloseAction := caNormal; |
833 |
+ |
|
834 |
+ |
if not (csDesigning in ComponentState) then |
835 |
+ |
MonitorHook.DBDisconnect(Self); |
836 |
+ |
|
837 |
+ |
InternalAfterClose; |
838 |
+ |
end; |
839 |
+ |
|
840 |
+ |
procedure TIBDataBase.InternalBeforeClose; |
841 |
|
var |
842 |
|
i: Integer; |
843 |
|
begin |
816 |
– |
CheckActive; |
844 |
|
{ Tell all connected transactions that we're disconnecting. |
845 |
|
This is so transactions can commit/rollback, accordingly |
846 |
|
} |
865 |
|
end; |
866 |
|
end; |
867 |
|
|
868 |
< |
case FCloseAction of |
842 |
< |
caNormal: |
843 |
< |
FAttachment.Disconnect(false); |
844 |
< |
caForce: |
845 |
< |
FAttachment.Disconnect(true); |
846 |
< |
caDropDatabase: |
847 |
< |
FAttachment.DropDatabase; |
848 |
< |
end; |
849 |
< |
FAttachment := nil; |
850 |
< |
FHiddenPassword := ''; |
851 |
< |
FCloseAction := caNormal; |
852 |
< |
|
853 |
< |
if not (csDesigning in ComponentState) then |
854 |
< |
MonitorHook.DBDisconnect(Self); |
868 |
> |
end; |
869 |
|
|
870 |
+ |
procedure TIBDataBase.InternalAfterClose; |
871 |
+ |
var |
872 |
+ |
i: Integer; |
873 |
+ |
begin |
874 |
|
for i := 0 to FSQLObjects.Count - 1 do |
875 |
|
if FSQLObjects[i] <> nil then |
876 |
|
SQLObjects[i].DoAfterDatabaseDisconnect; |
877 |
|
end; |
878 |
|
|
879 |
+ |
procedure TIBDataBase.InternalBeforeConnect(aDBParams: TStrings; var aDBName: string; |
880 |
+ |
var aCreateIfNotExists: boolean); |
881 |
+ |
var i: integer; |
882 |
+ |
begin |
883 |
+ |
{Opportunity to override defaults} |
884 |
+ |
for i := 0 to FSQLObjects.Count - 1 do |
885 |
+ |
begin |
886 |
+ |
if FSQLObjects[i] <> nil then |
887 |
+ |
SQLObjects[i].DoBeforeDatabaseConnect(aDBParams,aDBName, aCreateIfNotExists); |
888 |
+ |
end; |
889 |
+ |
end; |
890 |
+ |
|
891 |
+ |
procedure TIBDataBase.InternalAfterConnect; |
892 |
+ |
var i: integer; |
893 |
+ |
begin |
894 |
+ |
for i := 0 to FSQLObjects.Count - 1 do |
895 |
+ |
begin |
896 |
+ |
if FSQLObjects[i] <> nil then |
897 |
+ |
SQLObjects[i].DoAfterDatabaseConnect; |
898 |
+ |
end; |
899 |
+ |
end; |
900 |
+ |
|
901 |
|
procedure TIBDataBase.DoOnCreateDatabase; |
902 |
|
var i: integer; |
903 |
|
begin |
1091 |
|
|
1092 |
|
var |
1093 |
|
TempDBParams: TStrings; |
1054 |
– |
I: integer; |
1094 |
|
aDBName, oldDBName: string; |
1095 |
|
Status: IStatus; |
1096 |
|
CharSetID: integer; |
1128 |
|
if UseDefaultSystemCodePage then |
1129 |
|
TempDBParams.Values['lc_ctype'] :='UTF8'; |
1130 |
|
{$endif} |
1131 |
< |
{Opportunity to override defaults} |
1093 |
< |
for i := 0 to FSQLObjects.Count - 1 do |
1094 |
< |
begin |
1095 |
< |
if FSQLObjects[i] <> nil then |
1096 |
< |
SQLObjects[i].DoBeforeDatabaseConnect(TempDBParams,aDBName, aCreateIfNotExists); |
1097 |
< |
end; |
1131 |
> |
InternalBeforeConnect(TempDBParams,aDBName,aCreateIfNotExists); |
1132 |
|
|
1133 |
|
repeat |
1134 |
|
{ Generate a new DPB if necessary } |
1150 |
|
DPB.Add(isc_dpb_set_db_SQL_dialect).AsByte := SQLDialect; {create with this SQL Dialect} |
1151 |
|
FAttachment := FirebirdAPI.CreateDatabase(aDBName,DPB, false); |
1152 |
|
if FAttachment = nil then |
1153 |
< |
DPB := nil; |
1154 |
< |
DoOnCreateDatabase; |
1153 |
> |
DPB := nil |
1154 |
> |
else |
1155 |
> |
DoOnCreateDatabase; |
1156 |
|
end |
1157 |
|
else |
1158 |
|
FAttachment := FirebirdAPI.OpenDatabase(aDBName,DPB,false); |
1215 |
|
if not (csDesigning in ComponentState) then |
1216 |
|
FDBName := aDBName; {Synchronise at run time} |
1217 |
|
ValidateClientSQLDialect; |
1218 |
< |
for i := 0 to FSQLObjects.Count - 1 do |
1184 |
< |
begin |
1185 |
< |
if FSQLObjects[i] <> nil then |
1186 |
< |
SQLObjects[i].DoAfterDatabaseConnect; |
1187 |
< |
end; |
1218 |
> |
InternalAfterConnect; |
1219 |
|
if not (csDesigning in ComponentState) then |
1220 |
|
MonitorHook.DBConnect(Self); |
1221 |
|
end; |
1477 |
|
Result := CompareText(FConfigOverrides.Values['WireCompression'],'true') = 0; |
1478 |
|
end; |
1479 |
|
|
1480 |
+ |
procedure TIBDataBase.SetAttachment(AValue: IAttachment); |
1481 |
+ |
begin |
1482 |
+ |
if FAttachment = AValue then Exit; |
1483 |
+ |
if FAttachment <> nil then |
1484 |
+ |
begin |
1485 |
+ |
if Assigned(BeforeDisconnect) then |
1486 |
+ |
BeforeDisconnect(self); |
1487 |
+ |
InternalBeforeClose; |
1488 |
+ |
FAttachment := nil; |
1489 |
+ |
FFirebirdAPI := nil; |
1490 |
+ |
InternalAfterClose; |
1491 |
+ |
if Assigned(AfterDisconnect) then |
1492 |
+ |
AfterDisconnect(self); |
1493 |
+ |
end; |
1494 |
+ |
if Assigned(BeforeConnect) then |
1495 |
+ |
BeforeConnect(self); |
1496 |
+ |
FAttachment := AValue; |
1497 |
+ |
if FAttachment <> nil then |
1498 |
+ |
begin |
1499 |
+ |
ValidateClientSQLDialect; |
1500 |
+ |
FDBName := FAttachment.GetConnectString; |
1501 |
+ |
if FFirebirdLibraryPathName <> '' then |
1502 |
+ |
FFirebirdLibraryPathName := FAttachment.getFirebirdAPI.GetFBLibrary.GetLibraryFilePath; |
1503 |
+ |
InternalAfterConnect; |
1504 |
+ |
if Assigned(AfterConnect) then |
1505 |
+ |
AfterConnect(self); |
1506 |
+ |
end; |
1507 |
+ |
end; |
1508 |
+ |
|
1509 |
|
procedure TIBDataBase.SetConfigOverrides(AValue: TStrings); |
1510 |
|
begin |
1511 |
|
if FConfigOverrides = AValue then Exit; |
2408 |
|
parameter buffer, and return it and its length |
2409 |
|
in DPB and DPBLength, respectively. } |
2410 |
|
|
2411 |
< |
function TIBDatabase.GenerateDPB(FirebirdAPI: IFirebirdAPI; sl: TStrings): IDPB; |
2411 |
> |
function TIBDataBase.GenerateDPB(FirebirdAPI: IFirebirdAPI; sl: TStrings): IDPB; |
2412 |
|
var |
2413 |
|
i, j: Integer; |
2414 |
|
DPBVal: UShort; |