ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBDatabase.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBDatabase.pas (file contents):
Revision 17 by tony, Sat Dec 28 19:22:24 2013 UTC vs.
Revision 27 by tony, Tue Apr 14 13:10:23 2015 UTC

# Line 159 | Line 159 | type
159      FHiddenPassword: string;
160      FIBLoaded: Boolean;
161      FOnLogin: TIBDatabaseLoginEvent;
162 +    FSQLHourGlass: Boolean;
163      FTraceFlags: TTraceFlags;
164      FDBSQLDialect: Integer;
165      FSQLDialect: Integer;
# Line 181 | Line 182 | type
182      FUserNames: TStringList;
183      FDataSets: TList;
184      FLoginCalled: boolean;
185 +    FCharSetSizes: array of integer;
186      procedure EnsureInactive;
187      function GetDBSQLDialect: Integer;
188      function GetSQLDialect: Integer;
# Line 195 | Line 197 | type
197      function GetTransaction(Index: Integer): TIBTransaction;
198      function GetTransactionCount: Integer;
199      function Login: Boolean;
200 +    procedure LoadCharSetInfo;
201      procedure SetDatabaseName(const Value: TIBFileName);
202      procedure SetDBParamByDPB(const Idx: Integer; Value: String);
203      procedure SetDBParams(Value: TStrings);
# Line 262 | Line 265 | type
265                                                   write SetDefaultTransaction;
266      property IdleTimer: Integer read GetIdleTimer write SetIdleTimer;
267      property SQLDialect : Integer read GetSQLDialect write SetSQLDialect default 3;
268 +    property SQLHourGlass: Boolean read FSQLHourGlass write FSQLHourGlass default true;
269      property DBSQLDialect : Integer read FDBSQLDialect;
270      property TraceFlags: TTraceFlags read FTraceFlags write FTraceFlags;
271      property AfterConnect;
# Line 279 | Line 283 | type
283  
284    TIBTransaction = class(TComponent)
285    private
286 +    FAfterDelete: TNotifyEvent;
287 +    FAfterEdit: TNotifyEvent;
288 +    FAfterExecQuery: TNotifyEvent;
289 +    FAfterInsert: TNotifyEvent;
290 +    FAfterPost: TNotifyEvent;
291 +    FAfterTransactionEnd: TNotifyEvent;
292 +    FBeforeTransactionEnd: TNotifyEvent;
293      FIBLoaded: Boolean;
294      FCanTimeout         : Boolean;
295      FDatabases          : TList;
296 +    FOnStartTransaction: TNotifyEvent;
297      FSQLObjects         : TList;
298      FDefaultDatabase    : TIBDatabase;
299      FHandle             : TISC_TR_HANDLE;
# Line 295 | Line 307 | type
307      FTRParams           : TStrings;
308      FTRParamsChanged    : Boolean;
309      FInEndTransaction   : boolean;
310 +    FEndAction          : TTransactionAction;
311 +    procedure DoBeforeTransactionEnd;
312 +    procedure DoAfterTransactionEnd;
313 +    procedure DoOnStartTransaction;
314 +    procedure DoAfterExecQuery(Sender: TObject);
315 +    procedure DoAfterEdit(Sender: TObject);
316 +    procedure DoAfterDelete(Sender: TObject);
317 +    procedure DoAfterInsert(Sender: TObject);
318 +    procedure DoAfterPost(Sender: TObject);
319      procedure EnsureNotInTransaction;
320      procedure EndTransaction(Action: TTransactionAction; Force: Boolean);
321      function GetDatabase(Index: Integer): TIBDatabase;
# Line 336 | Line 357 | type
357      function AddDatabase(db: TIBDatabase): Integer;
358      function FindDatabase(db: TIBDatabase): Integer;
359      function FindDefaultDatabase: TIBDatabase;
360 +    function GetEndAction: TTransactionAction;
361      procedure RemoveDatabase(Idx: Integer);
362      procedure RemoveDatabases;
363      procedure CheckDatabasesInList;
# Line 357 | Line 379 | type
379      property DefaultAction: TTransactionAction read FDefaultAction write SetDefaultAction default taCommit;
380      property Params: TStrings read FTRParams write SetTRParams;
381      property OnIdleTimer: TNotifyEvent read FOnIdleTimer write FOnIdleTimer;
382 +    property BeforeTransactionEnd: TNotifyEvent read FBeforeTransactionEnd
383 +                                             write FBeforeTransactionEnd;
384 +    property AfterTransactionEnd: TNotifyEvent read FAfterTransactionEnd
385 +                                            write FAfterTransactionEnd;
386 +    property OnStartTransaction: TNotifyEvent read FOnStartTransaction
387 +                                              write FOnStartTransaction;
388 +    property AfterExecQuery: TNotifyEvent read FAfterExecQuery
389 +                                              write FAfterExecQuery;
390 +    property AfterEdit: TNotifyEvent read FAfterEdit write FAfterEdit;
391 +    property AfterDelete: TNotifyEvent read FAfterDelete write FAfterDelete;
392 +    property AfterInsert: TNotifyEvent read FAfterInsert write FAfterInsert;
393 +    property AfterPost: TNotifyEvent read FAfterPost write FAfterPost;
394    end;
395  
396 +  TTransactionEndEvent = procedure(Sender:TObject; Action: TTransactionAction) of object;
397 +
398    { TIBBase }
399  
400    { Virtually all components in IB are "descendents" of TIBBase.
# Line 375 | Line 411 | type
411      FAfterDatabaseDisconnect: TNotifyEvent;
412      FAfterDatabaseConnect: TNotifyEvent;
413      FOnDatabaseFree: TNotifyEvent;
414 <    FBeforeTransactionEnd: TNotifyEvent;
414 >    FBeforeTransactionEnd: TTransactionEndEvent;
415      FAfterTransactionEnd: TNotifyEvent;
416      FOnTransactionFree: TNotifyEvent;
417  
# Line 383 | Line 419 | type
419      procedure DoBeforeDatabaseDisconnect; virtual;
420      procedure DoAfterDatabaseDisconnect; virtual;
421      procedure DoDatabaseFree; virtual;
422 <    procedure DoBeforeTransactionEnd; virtual;
422 >    procedure DoBeforeTransactionEnd(Action: TTransactionAction); virtual;
423      procedure DoAfterTransactionEnd; virtual;
424      procedure DoTransactionFree; virtual;
425      function GetDBHandle: PISC_DB_HANDLE; virtual;
# Line 395 | Line 431 | type
431      destructor Destroy; override;
432      procedure CheckDatabase; virtual;
433      procedure CheckTransaction; virtual;
434 +    procedure DoAfterExecQuery(Sender: TObject); virtual;
435 +    procedure DoAfterEdit(Sender: TObject); virtual;
436 +    procedure DoAfterDelete(Sender: TObject); virtual;
437 +    procedure DoAfterInsert(Sender: TObject); virtual;
438 +    procedure DoAfterPost(Sender: TObject); virtual;
439 +    function GetCharSetSize(CharSetID: integer): integer;
440    public
441      property AfterDatabaseConnect: TNotifyEvent read FAfterDatabaseConnect
442                                                  write FAfterDatabaseConnect;
# Line 403 | Line 445 | type
445      property AfterDatabaseDisconnect: TNotifyEvent read FAfterDatabaseDisconnect
446                                                    write FAfterDatabaseDisconnect;
447      property OnDatabaseFree: TNotifyEvent read FOnDatabaseFree write FOnDatabaseFree;
448 <    property BeforeTransactionEnd: TNotifyEvent read FBeforeTransactionEnd write FBeforeTransactionEnd;
448 >    property BeforeTransactionEnd: TTransactionEndEvent read FBeforeTransactionEnd write FBeforeTransactionEnd;
449      property AfterTransactionEnd: TNotifyEvent read FAfterTransactionEnd write FAfterTransactionEnd;
450      property OnTransactionFree: TNotifyEvent read FOnTransactionFree write FOnTransactionFree;
451      property Database: TIBDatabase read FDatabase
# Line 426 | Line 468 | uses IBIntf, IBSQLMonitor, IBCustomDataS
468  
469   { TIBDatabase }
470  
471 < constructor TIBDatabase.Create(AOwner: TComponent);
471 > constructor TIBDataBase.Create(AOwner: TComponent);
472   {$ifdef WINDOWS}
473   var acp: uint;
474   {$endif}
# Line 440 | Line 482 | begin
482    FTransactions := TList.Create;
483    FDBName := '';
484    FDBParams := TStringList.Create;
485 +  FSQLHourGlass := true;
486    {$ifdef UNIX}
487    if csDesigning in ComponentState then
488      FDBParams.Add('lc_ctype=UTF-8');
# Line 472 | Line 515 | begin
515    CheckStreamConnect;
516   end;
517  
518 < destructor TIBDatabase.Destroy;
518 > destructor TIBDataBase.Destroy;
519   var
520    i: Integer;
521   begin
# Line 498 | Line 541 | begin
541    inherited Destroy;
542   end;
543  
544 < function TIBDatabase.Call(ErrCode: ISC_STATUS;
545 <  RaiseError: Boolean): ISC_STATUS;
544 > function TIBDataBase.Call(ErrCode: ISC_STATUS; RaiseError: Boolean
545 >   ): ISC_STATUS;
546   begin
547    result := ErrCode;
548    FCanTimeout := False;
# Line 507 | Line 550 | begin
550      IBDataBaseError;
551   end;
552  
553 < procedure TIBDatabase.CheckActive;
553 > procedure TIBDataBase.CheckActive;
554   begin
555    if StreamedConnected and (not Connected) then
556      Loaded;
# Line 515 | Line 558 | begin
558      IBError(ibxeDatabaseClosed, [nil]);
559   end;
560  
561 < procedure TIBDatabase.EnsureInactive;
561 > procedure TIBDataBase.EnsureInactive;
562   begin
563    if csDesigning in ComponentState then
564    begin
# Line 524 | Line 567 | begin
567    end
568   end;
569  
570 < procedure TIBDatabase.CheckInactive;
570 > procedure TIBDataBase.CheckInactive;
571   begin
572    if FHandle <> nil then
573      IBError(ibxeDatabaseOpen, [nil]);
574   end;
575  
576 < procedure TIBDatabase.CheckDatabaseName;
576 > procedure TIBDataBase.CheckDatabaseName;
577   begin
578    if (FDBName = '') then
579      IBError(ibxeDatabaseNameMissing, [nil]);
580   end;
581  
582 < function TIBDatabase.AddSQLObject(ds: TIBBase): Integer;
582 > function TIBDataBase.AddSQLObject(ds: TIBBase): Integer;
583   begin
584    result := 0;
585    if (ds.Owner is TIBCustomDataSet) then
# Line 549 | Line 592 | begin
592      FSQLObjects[result] := ds;
593   end;
594  
595 < function TIBDatabase.AddTransaction(TR: TIBTransaction): Integer;
595 > function TIBDataBase.AddTransaction(TR: TIBTransaction): Integer;
596   begin
597    result := FindTransaction(TR);
598    if result <> -1 then
# Line 566 | Line 609 | begin
609      FTransactions[result] := TR;
610   end;
611  
612 < procedure TIBDatabase.DoDisconnect;
612 > procedure TIBDataBase.DoDisconnect;
613   begin
614    if Connected then
615      InternalClose(False);
616    FDBSQLDialect := 1;
617 +  SetLength(FCharSetSizes,0);
618   end;
619  
620 < procedure TIBDatabase.CreateDatabase;
620 > procedure TIBDataBase.CreateDatabase;
621   var
622    tr_handle: TISC_TR_HANDLE;
623   begin
# Line 586 | Line 630 | begin
630      True);
631   end;
632  
633 < procedure TIBDatabase.DropDatabase;
633 > procedure TIBDataBase.DropDatabase;
634   begin
635    CheckActive;
636    Call(isc_drop_database(StatusVector, @FHandle), True);
637   end;
638  
639 < procedure TIBDatabase.DBParamsChange(Sender: TObject);
639 > procedure TIBDataBase.DBParamsChange(Sender: TObject);
640   begin
641    FDBParamsChanged := True;
642   end;
643  
644 < procedure TIBDatabase.DBParamsChanging(Sender: TObject);
644 > procedure TIBDataBase.DBParamsChanging(Sender: TObject);
645   begin
646    EnsureInactive;
647    CheckInactive;
648   end;
649  
650 < function TIBDatabase.FindTransaction(TR: TIBTransaction): Integer;
650 > function TIBDataBase.FindTransaction(TR: TIBTransaction): Integer;
651   var
652    i: Integer;
653   begin
# Line 616 | Line 660 | begin
660      end;
661   end;
662  
663 < function TIBDatabase.FindDefaultTransaction(): TIBTransaction;
663 > function TIBDataBase.FindDefaultTransaction: TIBTransaction;
664   var
665    i: Integer;
666   begin
# Line 634 | Line 678 | begin
678    end;
679   end;
680  
681 < procedure TIBDatabase.ForceClose;
681 > procedure TIBDataBase.ForceClose;
682   begin
683    if Connected then
684      InternalClose(True);
685   end;
686  
687 < function TIBDatabase.GetConnected: Boolean;
687 > function TIBDataBase.GetConnected: Boolean;
688   begin
689    result := FHandle <> nil;
690   end;
691  
692 < function TIBDatabase.GetSQLObject(Index: Integer): TIBBase;
692 > function TIBDataBase.GetSQLObject(Index: Integer): TIBBase;
693   begin
694    result := FSQLObjects[Index];
695   end;
696  
697 < function TIBDatabase.GetSQLObjectCount: Integer;
697 > function TIBDataBase.GetSQLObjectCount: Integer;
698   var
699    i: Integer;
700   begin
# Line 659 | Line 703 | begin
703      Inc(result);
704   end;
705  
706 < function TIBDatabase.GetDBParamByDPB(const Idx: Integer): String;
706 > function TIBDataBase.GetDBParamByDPB( const Idx: Integer): String;
707   var
708    ConstIdx, EqualsIdx: Integer;
709   begin
# Line 682 | Line 726 | begin
726      result := '';
727   end;
728  
729 < function TIBDatabase.GetIdleTimer: Integer;
729 > function TIBDataBase.GetIdleTimer: Integer;
730   begin
731    result := FTimer.Interval;
732   end;
733  
734 < function TIBDatabase.GetTransaction(Index: Integer): TIBTransaction;
734 > function TIBDataBase.GetTransaction(Index: Integer): TIBTransaction;
735   begin
736    result := FTransactions[Index];
737   end;
738  
739 < function TIBDatabase.GetTransactionCount: Integer;
739 > function TIBDataBase.GetTransactionCount: Integer;
740   var
741    i: Integer;
742   begin
# Line 702 | Line 746 | begin
746        Inc(result);
747   end;
748  
749 < function TIBDatabase.IndexOfDBConst(st: String): Integer;
749 > function TIBDataBase.IndexOfDBConst(st: String): Integer;
750   var
751    i, pos_of_str: Integer;
752   begin
# Line 718 | Line 762 | begin
762    end;
763   end;
764  
765 < procedure TIBDatabase.InternalClose(Force: Boolean);
765 > procedure TIBDataBase.InternalClose(Force: Boolean);
766   var
767    i: Integer;
768   begin
# Line 765 | Line 809 | begin
809        SQLObjects[i].DoAfterDatabaseDisconnect;
810   end;
811  
812 + procedure TIBDataBase.LoadCharSetInfo;
813 + var Query: TIBSQL;
814 +    i: integer;
815 + begin
816 +  if not FInternalTransaction.Active then
817 +    FInternalTransaction.StartTransaction;
818 +  Query := TIBSQL.Create(self);
819 +  try
820 +    Query.Database := Self;
821 +    Query.Transaction := FInternalTransaction;
822 +    Query.SQL.Text := 'Select RDB$CHARACTER_SET_ID, RDB$BYTES_PER_CHARACTER ' +
823 +                      'From RDB$CHARACTER_SETS Order by 1 DESC'; {do not localize}
824 +    Query.Prepare;
825 +    Query.ExecQuery;
826 +    if not Query.EOF then
827 +    begin
828 +      SetLength(FCharSetSizes,Query.FieldByName('RDB$CHARACTER_SET_ID').AsInteger + 1);
829 +      for i := 0 to Length(FCharSetSizes) - 1 do FCharSetSizes[i] := 1;
830 +      repeat
831 +        FCharSetSizes[Query.FieldByName('RDB$CHARACTER_SET_ID').AsInteger] :=
832 +                 Query.FieldByName('RDB$BYTES_PER_CHARACTER').AsInteger;
833 +        Query.Next;
834 +      until Query.EOF;
835 +    end;
836 +  finally
837 +    Query.free;
838 +    FInternalTransaction.Commit;
839 +  end;
840 + end;
841 +
842   procedure TIBDataBase.CheckStreamConnect;
843   var
844    i: integer;
# Line 797 | Line 871 | begin
871    end;
872   end;
873  
874 < procedure TIBDatabase.Notification( AComponent: TComponent;
875 <                                        Operation: TOperation);
874 > procedure TIBDataBase.Notification(AComponent: TComponent;
875 >   Operation: TOperation);
876   var
877    i: Integer;
878   begin
# Line 812 | Line 886 | begin
886    end;
887   end;
888  
889 < function TIBDatabase.Login: Boolean;
889 > function TIBDataBase.Login: Boolean;
890   var
891    IndexOfUser, IndexOfPassword: Integer;
892    Username, Password, OldPassword: String;
# Line 891 | Line 965 | begin
965    end;
966   end;
967  
968 < procedure TIBDatabase.DoConnect;
968 > procedure TIBDataBase.DoConnect;
969   var
970    DPB: String;
971    TempDBParams: TStrings;
# Line 944 | Line 1018 | begin
1018    end;
1019    if not (csDesigning in ComponentState) then
1020      MonitorHook.DBConnect(Self);
1021 +  LoadCharSetInfo;
1022   end;
1023  
1024 < procedure TIBDatabase.RemoveSQLObject(Idx: Integer);
1024 > procedure TIBDataBase.RemoveSQLObject(Idx: Integer);
1025   var
1026    ds: TIBBase;
1027   begin
# Line 960 | Line 1035 | begin
1035    end;
1036   end;
1037  
1038 < procedure TIBDatabase.RemoveSQLObjects;
1038 > procedure TIBDataBase.RemoveSQLObjects;
1039   var
1040    i: Integer;
1041   begin
# Line 972 | Line 1047 | begin
1047    end;
1048   end;
1049  
1050 < procedure TIBDatabase.RemoveTransaction(Idx: Integer);
1050 > procedure TIBDataBase.RemoveTransaction(Idx: Integer);
1051   var
1052    TR: TIBTransaction;
1053   begin
# Line 986 | Line 1061 | begin
1061    end;
1062   end;
1063  
1064 < procedure TIBDatabase.RemoveTransactions;
1064 > procedure TIBDataBase.RemoveTransactions;
1065   var
1066    i: Integer;
1067   begin
# Line 994 | Line 1069 | begin
1069      RemoveTransaction(i);
1070   end;
1071  
1072 < procedure TIBDatabase.SetDatabaseName(const Value: TIBFileName);
1072 > procedure TIBDataBase.SetDatabaseName( const Value: TIBFileName);
1073   begin
1074    if FDBName <> Value then
1075    begin
# Line 1004 | Line 1079 | begin
1079    end;
1080   end;
1081  
1082 < procedure TIBDatabase.SetDBParamByDPB(const Idx: Integer; Value: String);
1082 > procedure TIBDataBase.SetDBParamByDPB( const Idx: Integer; Value: String);
1083   var
1084    ConstIdx: Integer;
1085   begin
# Line 1023 | Line 1098 | begin
1098    end;
1099   end;
1100  
1101 < procedure TIBDatabase.SetDBParams(Value: TStrings);
1101 > procedure TIBDataBase.SetDBParams(Value: TStrings);
1102   begin
1103    FDBParams.Assign(Value);
1104   end;
1105  
1106 < procedure TIBDatabase.SetDefaultTransaction(Value: TIBTransaction);
1106 > procedure TIBDataBase.SetDefaultTransaction(Value: TIBTransaction);
1107   var
1108    i: Integer;
1109   begin
# Line 1046 | Line 1121 | begin
1121    FDefaultTransaction := Value;
1122   end;
1123  
1124 < procedure TIBDatabase.SetHandle(Value: TISC_DB_HANDLE);
1124 > procedure TIBDataBase.SetHandle(Value: TISC_DB_HANDLE);
1125   begin
1126    if HandleIsShared then
1127      Close
# Line 1056 | Line 1131 | begin
1131    FHandleIsShared := (Value <> nil);
1132   end;
1133  
1134 < procedure TIBDatabase.SetIdleTimer(Value: Integer);
1134 > procedure TIBDataBase.SetIdleTimer(Value: Integer);
1135   begin
1136    if Value < 0 then
1137      IBError(ibxeTimeoutNegative, [nil])
# Line 1075 | Line 1150 | begin
1150        end;
1151   end;
1152  
1153 < function TIBDatabase.TestConnected: Boolean;
1153 > function TIBDataBase.TestConnected: Boolean;
1154   var
1155    DatabaseInfo: TIBDatabaseInfo;
1156   begin
# Line 1096 | Line 1171 | begin
1171    end;
1172   end;
1173  
1174 < procedure TIBDatabase.TimeoutConnection(Sender: TObject);
1174 > procedure TIBDataBase.TimeoutConnection(Sender: TObject);
1175   begin
1176    if Connected then
1177    begin
# Line 1111 | Line 1186 | begin
1186    end;
1187   end;
1188  
1189 < function TIBDatabase.GetIsReadOnly: Boolean;
1189 > function TIBDataBase.GetIsReadOnly: Boolean;
1190   var
1191    DatabaseInfo: TIBDatabaseInfo;
1192   begin
# Line 1129 | Line 1204 | begin
1204    DatabaseInfo.Free;
1205   end;
1206  
1207 < function TIBDatabase.GetSQLDialect: Integer;
1207 > function TIBDataBase.GetSQLDialect: Integer;
1208   begin
1209    Result := FSQLDialect;
1210   end;
1211  
1212  
1213 < procedure TIBDatabase.SetSQLDialect(const Value: Integer);
1213 > procedure TIBDataBase.SetSQLDialect( const Value: Integer);
1214   begin
1215    if (Value < 1) then IBError(ibxeSQLDialectInvalid, [nil]);
1216    if ((FHandle = nil) or (Value <= FDBSQLDialect))  then
# Line 1144 | Line 1219 | begin
1219      IBError(ibxeSQLDialectInvalid, [nil]);
1220   end;
1221  
1222 < function TIBDatabase.GetDBSQLDialect: Integer;
1222 > function TIBDataBase.GetDBSQLDialect: Integer;
1223   var
1224    DatabaseInfo: TIBDatabaseInfo;
1225   begin
# Line 1154 | Line 1229 | begin
1229    DatabaseInfo.Free;
1230   end;
1231  
1232 < procedure TIBDatabase.ValidateClientSQLDialect;
1232 > procedure TIBDataBase.ValidateClientSQLDialect;
1233   begin
1234    if (FDBSQLDialect < FSQLDialect) then
1235    begin
# Line 1164 | Line 1239 | begin
1239    end;
1240   end;
1241  
1242 < procedure TIBDatabase.ApplyUpdates(const DataSets: array of TDataSet);
1242 > procedure TIBDataBase.ApplyUpdates( const DataSets: array of TDataSet);
1243   var
1244    I: Integer;
1245    DS: TIBCustomDataSet;
# Line 1190 | Line 1265 | begin
1265    TR.CommitRetaining;
1266   end;
1267  
1268 < procedure TIBDatabase.CloseDataSets;
1268 > procedure TIBDataBase.CloseDataSets;
1269   var
1270    i: Integer;
1271   begin
# Line 1199 | Line 1274 | begin
1274        DataSets[i].close;
1275   end;
1276  
1277 < function TIBDatabase.GetDataset(Index : longint) : TDataset;
1277 > function TIBDataBase.GetDataset(Index: longint): TDataset;
1278   begin
1279    if (Index >= 0) and (Index < FDataSets.Count) then
1280      Result := TDataSet(FDataSets[Index])
# Line 1207 | Line 1282 | begin
1282      raise Exception.Create('Invalid Index to DataSets');
1283   end;
1284  
1285 < function TIBDatabase.GetDataSetCount : Longint;
1285 > function TIBDataBase.GetDataSetCount: Longint;
1286   begin
1287    Result := FDataSets.Count;
1288   end;
# Line 1228 | Line 1303 | begin
1303    inherited SetConnected(Value);
1304   end;
1305  
1306 < procedure TIBDatabase.GetFieldNames(const TableName: string; List: TStrings);
1306 > procedure TIBDataBase.GetFieldNames( const TableName: string; List: TStrings);
1307   var
1308    Query: TIBSQL;
1309   begin
# Line 1269 | Line 1344 | begin
1344    end;
1345   end;
1346  
1347 < procedure TIBDatabase.GetTableNames(List: TStrings; SystemTables: Boolean);
1347 > procedure TIBDataBase.GetTableNames(List: TStrings; SystemTables: Boolean);
1348   var
1349    Query : TIBSQL;
1350   begin
# Line 1384 | Line 1459 | begin
1459      IBError(ibxeNotInTransaction, [nil]);
1460   end;
1461  
1462 + procedure TIBTransaction.DoBeforeTransactionEnd;
1463 + begin
1464 +  if Assigned(FBeforeTransactionEnd) then
1465 +    FBeforeTransactionEnd(self);
1466 + end;
1467 +
1468 + procedure TIBTransaction.DoAfterTransactionEnd;
1469 + begin
1470 +  if Assigned(FAfterTransactionEnd) then
1471 +    FAfterTransactionEnd(self);
1472 + end;
1473 +
1474 + procedure TIBTransaction.DoOnStartTransaction;
1475 + begin
1476 +  if assigned(FOnStartTransaction) then
1477 +    OnStartTransaction(self);
1478 + end;
1479 +
1480 + procedure TIBTransaction.DoAfterExecQuery(Sender: TObject);
1481 + begin
1482 +  if assigned(FAfterExecQuery) then
1483 +    AfterExecQuery(Sender);
1484 + end;
1485 +
1486 + procedure TIBTransaction.DoAfterEdit(Sender: TObject);
1487 + begin
1488 +  if assigned(FAfterEdit) then
1489 +    AfterEdit(Sender);
1490 + end;
1491 +
1492 + procedure TIBTransaction.DoAfterDelete(Sender: TObject);
1493 + begin
1494 +  if assigned(FAfterDelete) then
1495 +    AfterDelete(Sender);
1496 + end;
1497 +
1498 + procedure TIBTransaction.DoAfterInsert(Sender: TObject);
1499 + begin
1500 +  if assigned(FAfterInsert) then
1501 +    AfterInsert(Sender);
1502 + end;
1503 +
1504 + procedure TIBTransaction.DoAfterPost(Sender: TObject);
1505 + begin
1506 +  if assigned(FAfterPost) then
1507 +    AfterPost(Sender);
1508 + end;
1509 +
1510   procedure TIBTransaction.EnsureNotInTransaction;
1511   begin
1512    if csDesigning in ComponentState then
# Line 1460 | Line 1583 | begin
1583    CheckInTransaction;
1584    if FInEndTransaction then Exit;
1585    FInEndTransaction := true;
1586 +  FEndAction := Action;
1587    try
1588    case Action of
1589      TARollback, TACommit:
# Line 1468 | Line 1592 | begin
1592           (Action <> FDefaultAction) and
1593           (not Force) then
1594          IBError(ibxeCantEndSharedTransaction, [nil]);
1595 +      DoBeforeTransactionEnd;
1596        for i := 0 to FSQLObjects.Count - 1 do if FSQLObjects[i] <> nil then
1597 <        SQLObjects[i].DoBeforeTransactionEnd;
1597 >        SQLObjects[i].DoBeforeTransactionEnd(Action);
1598        if InTransaction then
1599        begin
1600          if HandleIsShared then
# Line 1492 | Line 1617 | begin
1617              IBDataBaseError;
1618          for i := 0 to FSQLObjects.Count - 1 do if FSQLObjects[i] <> nil then
1619            SQLObjects[i].DoAfterTransactionEnd;
1620 +        DoAfterTransactionEnd;
1621        end;
1622      end;
1623      TACommitRetaining:
# Line 1582 | Line 1708 | begin
1708    end;
1709   end;
1710  
1711 + function TIBTransaction.GetEndAction: TTransactionAction;
1712 + begin
1713 +  if FInEndTransaction then
1714 +     Result := FEndAction
1715 +  else
1716 +     IBError(ibxeIB60feature, [nil])
1717 + end;
1718 +
1719  
1720   function TIBTransaction.GetIdleTimer: Integer;
1721   begin
# Line 1687 | Line 1821 | begin
1821      for i := 0 to FSQLObjects.Count - 1 do
1822        if (FSQLObjects[i] <> nil) and
1823           (TIBBase(FSQLObjects[i]).Database = nil) then
1824 <        SetOrdProp(TIBBase(FSQLObjects[i]).Owner, 'Database', Integer(Value));
1824 >         SetObjectProp(TIBBase(FSQLObjects[i]).Owner, 'Database', Value);
1825    end;
1826    FDefaultDatabase := Value;
1827   end;
# Line 1793 | Line 1927 | begin
1927    finally
1928      FreeMem(pteb);
1929    end;
1930 +  DoOnStartTransaction;
1931   end;
1932  
1933   procedure TIBTransaction.TimeoutTransaction(Sender: TObject);
# Line 1834 | Line 1969 | begin
1969    inherited Destroy;
1970   end;
1971  
1972 + function TIBBase.GetCharSetSize(CharSetID: integer): integer;
1973 + begin
1974 +  if (CharSetID >= 0) and (CharSetID < Length(Database.FCharSetSizes)) then
1975 +    Result := Database.FCharSetSizes[CharSetID]
1976 +  else
1977 +    Result := 1; {Unknown character set}
1978 + end;
1979 +
1980   procedure TIBBase.CheckDatabase;
1981   begin
1982    if (FDatabase = nil) then
# Line 1886 | Line 2029 | begin
2029    SetTransaction(nil);
2030   end;
2031  
2032 < procedure TIBBase.DoBeforeTransactionEnd;
2032 > procedure TIBBase.DoBeforeTransactionEnd(Action: TTransactionAction);
2033   begin
2034    if Assigned(BeforeTransactionEnd) then
2035 <    BeforeTransactionEnd(Self);
2035 >    BeforeTransactionEnd(Self,Action);
2036   end;
2037  
2038   procedure TIBBase.DoAfterTransactionEnd;
# Line 1905 | Line 2048 | begin
2048    FTransaction := nil;
2049   end;
2050  
2051 + procedure TIBBase.DoAfterExecQuery(Sender: TObject);
2052 + begin
2053 +  if FTransaction <> nil then
2054 +    FTransaction.DoAfterExecQuery(Sender);
2055 + end;
2056 +
2057 + procedure TIBBase.DoAfterEdit(Sender: TObject);
2058 + begin
2059 +  if FTransaction <> nil then
2060 +    FTransaction.DoAfterEdit(Sender);
2061 + end;
2062 +
2063 + procedure TIBBase.DoAfterDelete(Sender: TObject);
2064 + begin
2065 +  if FTransaction <> nil then
2066 +    FTransaction.DoAfterDelete(Sender);
2067 + end;
2068 +
2069 + procedure TIBBase.DoAfterInsert(Sender: TObject);
2070 + begin
2071 +  if FTransaction <> nil then
2072 +    FTransaction.DoAfterInsert(Sender);
2073 + end;
2074 +
2075 + procedure TIBBase.DoAfterPost(Sender: TObject);
2076 + begin
2077 +  if FTransaction <> nil then
2078 +    FTransaction.DoAfterPost(Sender);
2079 + end;
2080 +
2081   procedure TIBBase.SetDatabase(Value: TIBDatabase);
2082   begin
2083    if (FDatabase <> nil) then

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines