forked from madorin/fibplus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FIBDatabase.pas
4840 lines (4317 loc) · 140 KB
/
FIBDatabase.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{***************************************************************}
{ FIBPlus - component library for direct access to Firebird and }
{ InterBase databases }
{ }
{ FIBPlus is based in part on the product }
{ Free IB Components, written by Gregory H. Deatz for }
{ Hoagland, Longo, Moran, Dunst & Doukas Company. }
{ mailto:[email protected] }
{ }
{ Copyright (c) 1998-2013 Devrace Ltd. }
{ Written by Serge Buzadzhy ([email protected]) }
{ }
{ ------------------------------------------------------------- }
{ FIBPlus home page: http://www.fibplus.com/ }
{ FIBPlus support : http://www.devrace.com/support/ }
{ ------------------------------------------------------------- }
{ }
{ Please see the file License.txt for full license information }
{***************************************************************}
unit FIBDatabase;
interface
{$I FIBPlus.inc}
{$IFDEF D_XE2}
{$UNDEF NO_GUI}
{$UNDEF DIRECT_USE_DB_LOGIN_FORM}
{$ENDIF}
uses
SysUtils, SyncObjs,Classes,ibase, IB_Intf, IB_Externals,
pFIBProps,IBBlobFilter, fib, pFIBEventLists,StdFuncs,
pFIBInterfaces, FIBMDTInterface,FIBPlatforms
{$IFDEF D6+} ,Variants{$ENDIF}
{$IFDEF D_XE2}
,System.UITypes
{$ENDIF}
{$IFDEF FIBPLUS_TRIAL}
,Windows
{$IFDEF D_XE2}
,VCL.Dialogs
{$ELSE}
,Dialogs
{$ENDIF}
{$ENDIF}
{$IFDEF DIRECT_USE_DB_LOGIN_FORM}
,FIBDBLoginDlg //IS GUI
{$ENDIF}
;
type
TFIBDatabase = class;
TFIBTransaction = class;
TFIBBase = class;
TDesignDBOption=(ddoIsDefaultDatabase,ddoStoreConnected,ddoNotSavePassword);
TDesignDBOptions = set of TDesignDBOption;
TpFIBDBEventType =(detOnConnect,detBeforeDisconnect,detBeforeDestroy);
TFIBUseRepository=(urFieldsInfo,urDataSetInfo,urErrorMessagesInfo);
TFIBUseRepositories=set of TFIBUseRepository;
TFBContextSpace=(csSystem,csSession,csTransaction);
TDatabaseRunStateValues=(drsInCloseLostConnect,drsInRestoreLostConnect);
TDatabaseRunState= set of TDatabaseRunStateValues;
TBeforeSaveBlobToSwap=procedure(const TableName,FieldName:string;
{ const } RecordKeyValues:array of variant;Stream:TStream;var FileName:string; var CanSave:boolean) of object;
TAfterSaveLoadBlobSwap=procedure(const TableName,FieldName:string;
{const }RecordKeyValues:array of variant;const FileName:string) of object;
TBeforeLoadBlobFromSwap=procedure(const TableName,FieldName:string;
{ const } RecordKeyValues:array of variant;var FileName:string; var CanLoad:boolean) of object;
TActionOnIdle=(aiCloseConnect,aiKeepLiveConnect);
TOnIdleConnect=procedure (Sender:TFIBDatabase; IdleTicks:Cardinal; var Action:TActionOnIdle) of object;
TIBCharSets=set of byte;
(* TFIBDatabase *)
{$IFDEF D_XE2}
TDoChangeScreenCursor = procedure(NewCursor:Integer; var OldCursor:Integer) of object ;
{$ENDIF}
TFIBDatabase = class(TComponent,IIbClientLibrary,IFIBConnect,IMDTMasterObject)
private
FSQLLogger:ISQLLogger;
FSQLStatMaker:ISQLStatMaker;
FUseRepositories :TFIBUseRepositories;
FLibraryName :string;
FUseBlrToTextFilter :boolean;
FClientLibLoaded :boolean;
FBlobSwapSupport :TBlobSwapSupport;
FBeforeSaveBlobToSwap:TBeforeSaveBlobToSwap;
FAfterSaveBlobToSwap :TAfterSaveLoadBlobSwap;
FAfterLoadBlobFromSwap :TAfterSaveLoadBlobSwap;
FBeforeLoadBlobFromSwap:TBeforeLoadBlobFromSwap;
FOnIdleConnect:TOnIdleConnect;
FAutoReconnect:boolean;
FGenerators :TGeneratorsCache;
FMemoSubtypes : TMemoSubtypes;
{$IFDEF D_XE2}
FLibraryName64 :string;
FDoChangeScreenCursor: TDoChangeScreenCursor ;
{$ENDIF}
function GetMemoSubtypes :string;
procedure SetMemoSubtypes(const Value:string);
procedure SetGenerators(Value:TGeneratorsCache);
procedure SetLibraryName(const LibName:string);
function StoredLibraryName:boolean;
{$IFDEF D_XE2}
function StoredLibraryName64:boolean;
{$ENDIF}
procedure LoadLibrary;
procedure SetBlobSwapSupport(const Value: TBlobSwapSupport);
procedure SetSQLLogger(const Value: ISQLLogger);
procedure SetSQLStatMaker(const Value: ISQLStatMaker);
function GetBusy: boolean;
protected
FClientLibrary :IIBClientLibrary;
FFIBBases : TList; // TFIBBases attached.
FTransactions : TList; // TFIBTransactions attached.
FDBName : Ansistring; // DB's name
FDBParams : TDBParams; // "Pretty" Parameters to database
FDBParamsChanged : Boolean; // Flag to determine if DPB must be regenerated
FDPB : PAnsiChar; // Parameters to DB as passed to IB.
FDPBLength : Short; // Length of parameter buffer
FHandle : TISC_DB_HANDLE; // DB's handle
FHandleIsShared : Boolean; // Is the handle shared with another DB?
FUseLoginPrompt : Boolean; // Show a default login prompt?
FOnConnect : TNotifyEvent; // Upon successful connection...
FOnTimeout : TNotifyEvent; // Upon timing out...
FDefaultTransaction : TFIBTransaction; // Many transaction components can be specified, but this is the primary, or default one to use.
FDefaultUpdateTransaction : TFIBTransaction; //
FStreamedConnected : Boolean; // Used for delaying the opening of the database.
FTimer : TFIBTimer; // The timer ID.
FUserNames : TStringList; // For use only with GetUserNames
FActiveTransactions : TStringList; // For use only with GetActiveTransactions
FBackoutCount: TStringList; // isc_info_backout_count
FDeleteCount: TStringList; // isc_info_delete_count
FExpungeCount: TStringList; // isc_info_expunge_count
FInsertCount: TStringList; // isc_info_insert_count
FPurgeCount: TStringList; // isc_info_purge_count
FReadIdxCount: TStringList; // isc_info_read_idx_count
FReadSeqCount: TStringList; // isc_info_read_seq_count
FUpdateCount: TStringList; // isc_info_update_count
//IB6
FSQLDialect:integer;
FUpperOldNames : boolean; // compatibility with IB4..5 field names conventions
FConnectParams:TConnectParams;
FDesignDBOptions:TDesignDBOptions;
FBeforeDisconnect:TNotifyEvent;
FAfterDisconnect:TNotifyEvent;
FDifferenceTime : double;
FSynchronizeTime:boolean;
vInternalTransaction:TFIBTransaction;
vOnConnected :TNotifyEventList;
vBeforeDisconnect :TNotifyEventList;
vOnDestroy :TNotifyEventList;
vAttachmentID :Long;
FBlobFilters :TIBBlobFilters;
FDBFileName :string;
FConnectType :ShortInt;
FNeedUnicodeFieldsTranslation:boolean;
FIsUnicodeConnect:boolean;
FIsKOI8Connect:boolean;
FIsNoneConnect:boolean;
FDatabaseRunState :TDatabaseRunState;
FLastActiveTime:Cardinal;
FStreammedConnectFail:boolean;
procedure DBParamsChange(Sender: TObject);
procedure DBParamsChanging(Sender: TObject);
function GetConnected: Boolean; // Is DB connected?
function GetDatabaseName: string;
function GetFIBBase(Index: Integer): TFIBBase; // Get the indexed FIBBase.
function GetFIBBasesCount: Integer; // Get the number of FIBBase connected.
function GetDBParamByDPB(const Idx: Integer): string;
function GetTimeout: Cardinal; // Get the timeout
function GetTransaction(Index: Integer): TFIBTransaction;
function GetFirstActiveTransaction: TFIBTransaction;
function GetTransactionCount: Integer;
function GetActiveTransactionCount: Integer;
function Login: Boolean; // Show login prompt
procedure SetConnected(Value: Boolean);
procedure SetDatabaseName(const Value: string);
procedure SetDBParamByDPB(const Idx: Integer; Value: string);
procedure SetDBParamByName(const ParName,Value: string);
procedure SetDBParams(Value: TDBParams);
procedure SetDefaultTransaction(Value: TFIBTransaction);
procedure SetDefaultUpdateTransaction(Value: TFIBTransaction);
procedure CreateTimeoutTimer;
procedure SetHandle(Value: TISC_DB_HANDLE);
procedure SetTimeout(Value: Cardinal);
procedure SetDesignDBOptions(Value:TDesignDBOptions);
procedure TimeoutConnection(Sender: TObject);
(* Database Info procedures -- Advanced stuff (translated from isc_database_info) *)
function GetAllocation: Long; // isc_info_allocation
function GetBaseLevel: Long; // isc_info_base_level
function GetDBFileName: Ansistring; // isc_info_db_id
function GetDBSiteName: Ansistring; // isc_info_db_id
function GetIsRemoteConnect: boolean; // isc_info_db_id
function GetDBImplementationNo: Long; // isc_info_implementation
function GetDBImplementationClass: Long;
function GetNoReserve: Long; // isc_info_no_reserve
function GetODSMinorVersion: Long; // isc_info_ods_minor_version
function GetODSMajorVersion: Long; // isc_info_ods_version
function GetPageSize: Long; // isc_info_page_size
function GetVersion: string; // isc_info_info_version
function GetCurrentMemory: Long; // isc_info_current_memory
function GetForcedWrites: Long; // isc_info_forced_writes
function GetMaxMemory: Long; // isc_info_max_memory
function GetNumBuffers: Long; // isc_info_num_buffers
function GetSweepInterval: Long; // isc_info_sweep_interval
function GetUserNames: TStringList;// isc_info_user_names
function GetFetches: Long;// isc_info_fetches
function GetMarks: Long; // isc_info_marks
function GetReads: Long; // isc_info_reads
function GetWrites: Long; // isc_info_writes
function GetBackoutCount: TStringList;// isc_info_backout_count
function GetDeleteCount: TStringList; // isc_info_delete_count
function GetExpungeCount: TStringList;// isc_info_expunge_count
function GetInsertCount: TStringList; // isc_info_insert_count
function GetPurgeCount: TStringList; // isc_info_purge_count
function GetReadIdxCount: TStringList;// isc_info_read_idx_count
function GetReadSeqCount: TStringList;// isc_info_read_seq_count
function GetUpdateCount: TStringList; // isc_info_update_count
function GetTableOperationInfo(const TableName:string; FromStrs:TStrings):integer;
function GetIndexedReadCount(const TableName:string):integer;
function GetNonIndexedReadCount(const TableName:string):integer;
function GetInsertsCount(const TableName:string):integer;
function GetUpdatesCount(const TableName:string):integer;
function GetDeletesCount(const TableName:string):integer;
function GetOperationCounts(DBInfoCommand: Integer; var FOperation: TStringList): TStringList;
function GetAllModifications:integer;
function GetLogFile: Long; // isc_info_log_file
function GetCurLogFileName: string; // isc_info_cur_logfile_name
function GetCurLogPartitionOffset: Long; // isc_info_cur_log_part_offset
function GetNumWALBuffers: Long; // isc_info_num_wal_buffers
function GetWALBufferSize: Long; // isc_info_wal_buffer_size
function GetWALCheckpointLength: Long; // isc_info_wal_ckpt_length
function GetWALCurCheckpointInterval: Long; // isc_info_wal_cur_ckpt_interval
function GetWALPrvCheckpointFilename: string;// isc_info_wal_prv_ckpt_fname
function GetWALPrvCheckpointPartOffset: Long;// isc_info_wal_prv_ckpt_poffset
function GetWALGroupCommitWaitUSecs: Long; // isc_info_wal_grpc_wait_usecs
function GetWALNumIO: Long; // isc_info_wal_num_id
function GetWALAverageIOSize: Long; // isc_info_wal_avg_io_size
function GetWALNumCommits: Long; // isc_info_wal_num_commits
function GetWALAverageGroupCommitSize: Long; // isc_info_wal_avg_grpc_size
function GetProtectLongDBInfo(DBInfoCommand: Integer;var Success:boolean): Long;
function GetStringDBInfo(DBInfoCommand: Integer): string;
function GetLongDBInfo(DBInfoCommand: Integer): Long;
function GetAttachmentID :Long;
//Firebird Info
function GetActiveTransactions: TStringList; // frb_info_active_transactions
function GetOldestTransaction: Long; // frb_info_oldest_transaction
function GetOldestActive: Long; // frb_info_oldest_active
function GetOldestSnapshot: Long; // frb_info_oldest_snapshot
function GetFBVersion: string; // frb_info_firebird_version
function GetAttachCharset: integer; // frb_info_att_charset
private
// Versions
FServerMajorVersion:integer;
FServerMinorVersion:integer;
FServerRelease:integer;
FServerBuild:integer;
FNeedUTFDecodeDDL:boolean;
FIsFB21OrMore :boolean;
procedure FillServerVersions;
function GetServerMajorVersion: integer;
function GetServerMinorVersion: integer;
function GetServerRelease: integer;
function GetServerBuild: integer;
protected
function GetInternalTransaction:TFIBTransaction; // friend for pFIBDataInfo
property StreammedConnectFail:boolean read FStreammedConnectFail;
protected
//IB6
function GetDBSQLDialect:Word;
function GetSQLDialect:Integer;
procedure SetSQLDialect(const Value: Integer);
function GetReadOnly: Long;
function GetStoreConnected:boolean;
{$IFDEF CSMonitor}
private
FCSMonitorSupport: TCSMonitorSupport;
procedure SetCSMonitorSupport(Value:TCSMonitorSupport);
{$ENDIF}
protected
FIsFireBirdConnect:boolean;
FIsIB2007Connect:boolean;
function GetIsFirebirdConnect :boolean;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation);override;
procedure InternalClose(Force: Boolean;DBinShutDown:boolean=False); virtual ;
procedure DoOnConnect;
procedure DoBeforeDisconnect;
procedure DoAfterDisconnect;
{$IFDEF USE_DEPRECATE_METHODS1}
procedure RemoveDataSet(Idx: Integer); deprecated;
procedure RemoveDataSets; deprecated;
function AddDataSet(ds: TFIBBase): Integer; deprecated;
{$ENDIF}
procedure RemoveFIBBase(Idx: Integer);
procedure RemoveFIBBases;
function AddFIBBase(ds: TFIBBase): Integer;
procedure RemoveTransaction(Idx: Integer);
procedure RemoveTransactions;
function AddTransaction(TR: TFIBTransaction): Integer;
procedure IBFilterBuffer(var BlobBuffer:PAnsiChar;var BlobSize:longint;
BlobSubType:integer;ForEncode: boolean);
//IFIBObject
procedure SaveAlias; virtual;
public
procedure AddEvent(Event:TNotifyEvent;EventType:TpFIBDBEventType);
procedure RemoveEvent(Event:TNotifyEvent;EventType:TpFIBDBEventType);
procedure RegisterBlobFilter(BlobSubType:integer;
EncodeProc,DecodeProc:PIBBlobFilterProc);
procedure RemoveBlobFilter(BlobSubType:integer);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Call(ErrCode: ISC_STATUS; RaiseError: Boolean): ISC_STATUS;
procedure CheckActive(TryReconnect:boolean=False); // Raise error if DB is inactive
procedure CheckInactive; // Raise error if DB is active
procedure CheckDatabaseName; // Raise error if DBName is empty
procedure Close;
procedure CreateDatabase;
property DBParamByDPB[const Idx: Integer]: string read GetDBParamByDPB
write SetDBParamByDPB;
procedure DropDatabase;
function FindTransaction(TR: TFIBTransaction): Integer;
procedure ForceClose;
function IndexOfDBConst(const st: string): Integer; // Get the index of a given constant in DBParams
procedure Open(RaiseExcept:boolean = True); virtual;
function TestConnected: Boolean;
function GetServerTime:TDateTime;
//FB
procedure ShutDown(const ShutParams:array of integer;Delay:integer=0);
procedure Online;
public
function ClientVersion:string;
function ClientMajorVersion:integer;
function ClientMinorVersion:integer;
function IsFirebirdConnect :boolean;
function IsUnicodeConnect :boolean;
function IsIB2007Connect :boolean;
function NeedUTFEncodeDDL :boolean;
function NeedUnicodeFieldsTranslation :boolean;
function NeedUnicodeFieldTranslation(FieldCharacterSet:integer) :boolean;
{$IFDEF SUPPORT_KOI8_CHARSET}
function IsKOI8Connect :boolean;
{$ENDIF}
{FB2 features}
function GetContextVariable(ContextSpace:TFBContextSpace;const VarName:string
;aTransaction:TFIBTransaction=nil
):Variant;
procedure SetContextVariable( ContextSpace:TFBContextSpace;const VarName,VarValue:string
;aTransaction:TFIBTransaction=nil
);
function CanCancelOperationFB21:boolean;
procedure CancelOperationFB21(ConnectForCancel:TFIBDatabase=nil);
procedure RaiseCancelOperations;
procedure EnableCancelOperations;
procedure DisableCancelOperations;
//
function UnicodeCharSets:TIBCharSets;
function BytesInUnicodeChar(CharSetId:integer):Byte;
function ReturnDeclaredFieldSize:boolean;
function MemoSubTypesActive:boolean;
function IsMemoSubtype(aSubtype: ShortInt):boolean;
function LibraryFilePath:string;
(* Properties*)
{$IFDEF USE_DEPRECATE_METHODS1}
property DataSetCount : Integer read GetFIBBasesCount; // deprecated;
property DataSets[Index: Integer]: TFIBBase read GetFIBBase; // deprecated;
{$ENDIF}
property FIBBaseCount: Integer read GetFIBBasesCount;
property FIBBases[Index: Integer]: TFIBBase read GetFIBBase;
property Handle: TISC_DB_HANDLE read FHandle write SetHandle;
property HandleIsShared: Boolean read FHandleIsShared;
property TransactionCount: Integer read GetTransactionCount;
property FirstActiveTransaction:TFIBTransaction read GetFirstActiveTransaction;
property ActiveTransactionCount: Integer read GetActiveTransactionCount;
property Transactions[Index: Integer]: TFIBTransaction read GetTransaction;
property IsFB21OrMore :boolean read FIsFB21OrMore;
(* Database Info properties -- Advanced stuff (translated from isc_database_info) *)
property AttachmentID: Long read GetAttachmentID; // isc_info_attachment_id
property Allocation: Long read GetAllocation; // isc_info_allocation
property BaseLevel: Long read GetBaseLevel; // isc_info_base_level
property DBFileName: Ansistring read GetDBFileName; // isc_info_db_id
property DBSiteName: Ansistring read GetDBSiteName;
property IsRemoteConnect: boolean read GetIsRemoteConnect;
property DBImplementationNo: Long read GetDBImplementationNo; // isc_info_implementation
property DBImplementationClass: Long read GetDBImplementationClass;
property NoReserve: Long read GetNoReserve; // isc_info_no_reserve
property ODSMinorVersion: Long read GetODSMinorVersion; // isc_info_ods_minor_version
property ODSMajorVersion: Long read GetODSMajorVersion; // isc_info_ods_version
property PageSize: Long read GetPageSize; // isc_info_page_size
property Version: string read GetVersion; // isc_info_info_version
property FBVersion:string read GetFBVersion;
property FBAttachCharsetID:Integer read GetAttachCharset;
property ServerMajorVersion:integer read GetServerMajorVersion;
property ServerMinorVersion:integer read GetServerMinorVersion;
property ServerBuild:integer read GetServerBuild;
property ServerRelease:integer read GetServerRelease;
property CurrentMemory: Long read GetCurrentMemory; // isc_info_current_memory
property ForcedWrites: Long read GetForcedWrites; // isc_info_forced_writes
property MaxMemory: Long read GetMaxMemory; // isc_info_max_memory
property NumBuffers: Long read GetNumBuffers; // isc_info_num_buffers
property SweepInterval: Long read GetSweepInterval; // isc_info_sweep_interval
property UserNames: TStringList read GetUserNames; // isc_info_user_names
property Fetches: Long read GetFetches; // isc_info_fetches
property Marks: Long read GetMarks; // isc_info_marks
property Reads: Long read GetReads; // isc_info_reads
property Writes: Long read GetWrites; // isc_info_writes
property BackoutCount: TStringList read GetBackoutCount; // isc_info_backout_count
property DeleteCount: TStringList read GetDeleteCount; // isc_info_delete_count
property ExpungeCount: TStringList read GetExpungeCount; // isc_info_expunge_count
property InsertCount: TStringList read GetInsertCount; // isc_info_insert_count
property PurgeCount: TStringList read GetPurgeCount; // isc_info_purge_count
property ReadIdxCount: TStringList read GetReadIdxCount; // isc_info_read_idx_count
property ReadSeqCount: TStringList read GetReadSeqCount; // isc_info_read_seq_count
property UpdateCount: TStringList read GetUpdateCount; // isc_info_update_count
property IndexedReadCount[const TableName:string]:integer read GetIndexedReadCount;
property NonIndexedReadCount[const TableName:string]:integer read GetNonIndexedReadCount;
property InsertsCount[const TableName:string]:integer read GetInsertsCount;
property UpdatesCount[const TableName:string]:integer read GetUpdatesCount;
property DeletesCount[const TableName:string]:integer read GetDeletesCount;
property AllModifications:integer read GetAllModifications;
property LogFile: Long read GetLogFile; // isc_info_log_file
property CurLogFileName: string read GetCurLogFileName; // isc_info_cur_logfile_name
property CurLogPartitionOffset: Long read GetCurLogPartitionOffset; // isc_info_cur_log_part_offset
property NumWALBuffers: Long read GetNumWALBuffers; // isc_info_num_wal_buffers
property WALBufferSize: Long read GetWALBufferSize; // isc_info_wal_buffer_size
property WALCheckpointLength: Long read GetWALCheckpointLength; // isc_info_wal_ckpt_length
property WALCurCheckpointInterval: Long read GetWALCurCheckpointInterval; // isc_info_wal_cur_ckpt_interval
property WALPrvCheckpointFilename: string read GetWALPrvCheckpointFilename; // isc_info_wal_prv_ckpt_fname
property WALPrvCheckpointPartOffset: Long read GetWALPrvCheckpointPartOffset; // isc_info_wal_prv_ckpt_poffset
property WALGroupCommitWaitUSecs: Long read GetWALGroupCommitWaitUSecs; // isc_info_wal_grpc_wait_usecs
property WALNumIO: Long read GetWALNumIO; // isc_info_wal_num_id
property WALAverageIOSize: Long read GetWALAverageIOSize; // isc_info_wal_avg_io_size
property WALNumCommits: Long read GetWALNumCommits; // isc_info_wal_num_commits
property WALAverageGroupCommitSize: Long read GetWALAverageGroupCommitSize; // isc_info_wal_avg_grpc_size
//IB6
property DBSQLDialect:Word read GetDBSQLDialect;
property ReadOnly :Long read GetReadOnly ;
property DatabaseName: string read GetDatabaseName write SetDatabaseName;
property DifferenceTime : double read FDifferenceTime ;
//Firebird
property ServerActiveTransactions :TStringList read GetActiveTransactions;
property OldestTransactionID :Long read GetOldestTransaction;
property OldestActiveTransactionID :Long read GetOldestActive;
property Busy:boolean read GetBusy;
public
procedure StartTransaction;
procedure Commit;
procedure Rollback;
procedure CommitRetaining;
procedure RollbackRetaining;
function Gen_Id(const GeneratorName: string; Step: Int64;aTransaction:TFIBTransaction =nil): Int64;
function Execute(const SQL: string; AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal): boolean;
procedure CreateGUIDDomain;
function InternalQueryValue(const aSQL: string;FieldNo:integer;
ParamValues:array of variant; aTransaction:TFIBTransaction; aCacheQuery:boolean;
AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal
):Variant;
function QueryValue(const aSQL: string;FieldNo:integer;aTransaction:TFIBTransaction=nil;
aCacheQuery:boolean=True; AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal
):Variant; overload;
function QueryValue(const aSQL: string;FieldNo:integer;
ParamValues:array of variant;aTransaction:TFIBTransaction=nil;aCacheQuery:boolean=True;
AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal
):Variant; overload;
function QueryValues(const aSQL: string;aTransaction:TFIBTransaction=nil
;aCacheQuery:boolean=True; AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal
):Variant; overload;
function QueryValues(const aSQL: string; ParamValues:array of variant;aTransaction:TFIBTransaction=nil ;
aCacheQuery:boolean=True; AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal):Variant; overload;
function QueryValueAsStr(const aSQL: string;FieldNo:integer;
AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal):string;overload;
function QueryValueAsStr(const aSQL: string;FieldNo:integer;
ParamValues:array of variant;
AMDTSQLExecutor: TMDTSQLExecutor = se_ServerAfterLocal):string; overload;
procedure ClearQueryCacheList;
function EasyFormatsStr :boolean;
property StoreConnected :boolean read GetStoreConnected;
property ClientLibrary:IIbClientLibrary read FClientLibrary implements IIbClientLibrary;
property SQLStatisticsMaker:ISQLStatMaker read FSQLStatMaker write SetSQLStatMaker;
published
property AutoReconnect:boolean read FAutoReconnect write FAutoReconnect default False;
property Connected: Boolean read GetConnected write SetConnected stored GetStoreConnected;
property BlobSwapSupport :TBlobSwapSupport read FBlobSwapSupport write SetBlobSwapSupport;
property DBName: string read GetDatabaseName write SetDatabaseName;
property DBParams: TDBParams read FDBParams write SetDBParams;
property DefaultTransaction: TFIBTransaction read FDefaultTransaction
write SetDefaultTransaction;
property DefaultUpdateTransaction: TFIBTransaction read FDefaultUpdateTransaction
write SetDefaultUpdateTransaction;
//IB6
property SQLDialect : Integer read FSQLDialect write SetSQLDialect;
property Timeout: Cardinal read GetTimeout write SetTimeout;
property UseLoginPrompt: Boolean read FUseLoginPrompt write FUseLoginPrompt default False;
// Events
property OnTimeout: TNotifyEvent read FOnTimeout write FOnTimeout;
property UpperOldNames: boolean read FUpperOldNames write FUpperOldNames
default False; // compatibility with IB4..5 field names conventions
property BeforeDisconnect:TNotifyEvent read FBeforeDisconnect write FBeforeDisconnect;
property AfterDisconnect :TNotifyEvent read FAfterDisconnect write FAfterDisconnect ;
property ConnectParams :TConnectParams read FConnectParams write FConnectParams stored False;
property SynchronizeTime:boolean read FSynchronizeTime write FSynchronizeTime default True;
property DesignDBOptions:TDesignDBOptions read FDesignDBOptions write SetDesignDBOptions default
[ddoStoreConnected]
;
property OnConnect: TNotifyEvent read FOnConnect write FOnConnect stored False; // obsolete
property BeforeSaveBlobToSwap:TBeforeSaveBlobToSwap read FBeforeSaveBlobToSwap write FBeforeSaveBlobToSwap;
property AfterSaveBlobToSwap:TAfterSaveLoadBlobSwap read FAfterSaveBlobToSwap write FAfterSaveBlobToSwap;
property AfterLoadBlobFromSwap :TAfterSaveLoadBlobSwap read FAfterLoadBlobFromSwap write FAfterLoadBlobFromSwap;
property BeforeLoadBlobFromSwap:TBeforeLoadBlobFromSwap read FBeforeLoadBlobFromSwap write FBeforeLoadBlobFromSwap;
property OnIdleConnect:TOnIdleConnect read FOnIdleConnect write FOnIdleConnect;
property UseRepositories:TFIBUseRepositories read FUseRepositories write FUseRepositories
default [urFieldsInfo,urDataSetInfo,urErrorMessagesInfo] ;
property LibraryName:string read FLibraryName write SetLibraryName stored StoredLibraryName;
//libfbclient.so MACOS
{$IFDEF D_XE2}
property LibraryName64:string read FLibraryName64 write FLibraryName64 stored StoredLibraryName64;
{$ENDIF}
property SQLLogger:ISQLLogger read FSQLLogger write SetSQLLogger;
property UseBlrToTextFilter :boolean read FUseBlrToTextFilter write FUseBlrToTextFilter default False;
property GeneratorsCache :TGeneratorsCache read FGenerators write SetGenerators;
{$IFDEF CSMonitor}
property CSMonitorSupport: TCSMonitorSupport read FCSMonitorSupport write SetCSMonitorSupport;
{$ENDIF}
{$IFDEF D_XE2}
property DoChangeScreenCursor: TDoChangeScreenCursor read FDoChangeScreenCursor write FDoChangeScreenCursor;
{$ENDIF}
//MDT
protected
FIMDTDatabase:IMDTDatabase;
FIMDTIBRealDBCanal:IMDTIBRealDBCanal;
FMDTConnectMode: integer;
procedure SetMDTDatabase(AIDatabase :IMDTDatabase);
function GetIsUsingMDT:boolean;
//IMDTMasterObject
procedure LinkedChieldDestroy(AIChield:IUnknown); virtual; stdcall;
procedure LinkedChieldBeforeConnect(AIChield:IUnknown); virtual; stdcall;
procedure LinkedChieldAfterConnect(AIChield:IUnknown); virtual; stdcall;
procedure LinkedChieldBeforeDisconnect(AIChield:IUnknown); virtual; stdcall;
procedure LinkedChieldAfterDisconnect(AIChield:IUnknown); virtual; stdcall;
public
property IsUsingMDT:boolean read GetIsUsingMDT;
published
property MemoSubtypes : string read GetMemoSubtypes write SetMemoSubtypes;
property MDTDatabase: IMDTDatabase read FIMDTDatabase write SetMDTDatabase;
//MDT_End;
end;
(* TFIBTransaction *)
TTransactionAction =
(TARollback, TARollbackRetaining,TACommit, TACommitRetaining);
TTransactionState =
(tsActive,tsClosed,tsDoRollback,tsDoRollbackRetaining,tsDoCommit, tsDoCommitRetaining);
TTransactionRunState=(trsInLoaded);
TTransactionRunStates=set of TTransactionRunState;
TpFIBTrEventType =(tetBeforeStartTransaction,tetAfterStartTransaction,
tetBeforeEndTransaction,tetAfterEndTransaction,tetBeforeDestroy);
TEndTrEvent=procedure(EndingTR:TFIBTransaction;
Action: TTransactionAction; Force: Boolean)of object;
TFIBMDTTransactionRole=(
mtrNone,
mtrSeparateTransaction,
mtrAutoDefine);
TFIBTransaction = class(TComponent,IFIBTransaction)
protected
FCanTimeout : Boolean; // Can the transaction timeout now?
FDatabases : TList; // TDatabases in transaction.
FFIBBases : TList; // TFIBBases attached.
FDefaultDatabase : TFIBDatabase; // just like DefaultTransaction in FIBDatabase
FHandle : TISC_TR_HANDLE; // TR's handle
FHandleIsShared : Boolean;
FOnTimeout : TNotifyEvent; // When the transaction times out...
FStreamedActive : Boolean;
FTPB : PAnsiChar; // Parameters to TR as passed to IB.
FTPBLength : Short; // Length of parameter buffer
FTimer : TFIBTimer; // Timer for timing out transactions.
FTimeoutAction : TTransactionAction; // Rollback or commit at end of timeout?
FTRParams : TStrings; // Parameters to Transactions.
FTRParamsChanged : Boolean;
FState : TTransactionState;
FTransactionID : integer;
vOnDestroy : TNotifyEventList;
vBeforeStartTransaction : TNotifyEventList;
vAfterStartTransaction : TNotifyEventList;
vBeforeEndTransaction : TCallBackList;
vAfterEndTransaction : TCallBackList;
vTRParams : array of Ansistring;
vTPBArray : array of Ansistring;
FTransactionRunStates :TTransactionRunStates;
FHasUncommitedUpdates :boolean;
FWatchUpdates :boolean;
{$IFDEF CSMonitor}
FCSMonitorSupport: TCSMonitorSupport;
procedure SetCSMonitorSupport(Value:TCSMonitorSupport);
{$ENDIF}
function GetTransactionID: integer;
function DoStoreActive:boolean;
procedure EndTransaction(Action: TTransactionAction; Force: Boolean); virtual;
// End the transaction using specified method...
function GetDatabase(Index: Integer): TFIBDatabase; // Get the indexed database
function GetDatabaseCount: Integer; // Get the number of databases in transaction
function GetFIBBase(Index: Integer): TFIBBase; // Get the indexed Dataset.
function GetFIBBasesCount: Integer; // Get the number of Datasets connected.
function GetInTransaction: Boolean; // Is there an active trans?
function GetTimeout: Cardinal;
procedure Loaded; override;
procedure SetActive(Value: Boolean);
procedure SetDefaultDatabase(Value: TFIBDatabase);
procedure SetHandle(Value: TISC_TR_HANDLE);
procedure SetTimeout(Value: Cardinal); // Set the timeout
procedure SetTRParams(Value: TStrings);
procedure TimeoutTransaction(Sender: TObject);
procedure TRParamsChange(Sender: TObject);
procedure TRParamsChanging(Sender: TObject);
procedure RemoveDatabases;
{$IFDEF USE_DEPRECATE_METHODS1}
procedure RemoveDataSet(Idx: Integer); deprecated;
procedure RemoveDataSets; deprecated;
function AddDataSet(ds: TFIBBase): Integer; deprecated;
{$ENDIF}
procedure RemoveFIBBase(Idx: Integer);
procedure RemoveFIBBases;
function AddFIBBase(ds: TFIBBase): Integer;
procedure CreateTimeoutTimer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function MainDatabase:TFIBDatabase;
function FindDatabase(db: TFIBDatabase): Integer;
procedure AddEvent(Event:TNotifyEvent;EventType:TpFIBTrEventType);
procedure RemoveEvent(Event:TNotifyEvent;EventType:TpFIBTrEventType);
procedure AddEndEvent(Event:TEndTrEvent;EventType:TpFIBTrEventType);
procedure RemoveEndEvent(Event:TEndTrEvent;EventType:TpFIBTrEventType);
procedure DoOnSQLExec(Query:TComponent;Kind:TKindOnOperation); virtual;
function AddDatabase(db: TFIBDatabase): Integer; overload;
function AddDatabase(db: TFIBDatabase; const aTRParams: string): Integer; overload;
procedure RemoveDatabase(Idx: Integer);
procedure ReplaceDatabase(dbOld,dbNew: TFIBDatabase);
procedure OnDatabaseDisconnecting(DB: TFIBDatabase);
function Call(ErrCode: ISC_STATUS; RaiseError: Boolean): ISC_STATUS;
procedure CheckDatabasesInList; // Raise error if no databases in list.
procedure CheckInTransaction; // Raise error if not in transaction
procedure CheckNotInTransaction; // Raise error if in transaction
procedure StartTransaction; virtual;
procedure Commit; virtual;
procedure CommitRetaining; virtual;
procedure Rollback; virtual;
procedure RollbackRetaining;virtual;
procedure ExecSQLImmediate(const SQLText:Widestring);
procedure SetSavePoint(const SavePointName:string);
procedure MDTEndSavePoint(AName:string; ACommit:boolean);
procedure RollBackToSavePoint(const SavePointName:string);
procedure ReleaseSavePoint(const SavePointName:string);
procedure CloseAllQueryHandles;
function IsReadCommitedTransaction:boolean;
function IsReadOnly:boolean;
property DatabaseCount: Integer read GetDatabaseCount;
property Databases[Index: Integer]: TFIBDatabase read GetDatabase;
{$IFDEF USE_DEPRECATE_METHODS1}
property DataSetCount: Integer read GetFIBBasesCount; //deprecated;
property DataSets[Index: Integer]: TFIBBase read GetFIBBase; //deprecated;
{$ENDIF}
property FIBBaseCount: Integer read GetFIBBasesCount;
property FIBBases[Index: Integer]: TFIBBase read GetFIBBase;
property Handle: TISC_TR_HANDLE read FHandle write SetHandle;
property HandleIsShared: Boolean read FHandleIsShared;
property InTransaction: Boolean read GetInTransaction;
// property TPB: PChar read FTPB;
// property TPBLength: Short read FTPBLength;
property State: TTransactionState read FState;
property TransactionID: integer read GetTransactionID;
property HasUncommitedUpdates :boolean read FHasUncommitedUpdates ;
published
property Active: Boolean read GetInTransaction write SetActive stored DoStoreActive;
property DefaultDatabase: TFIBDatabase read FDefaultDatabase
write SetDefaultDatabase;
property Timeout: Cardinal read GetTimeout write SetTimeout default 0;
property TimeoutAction: TTransactionAction read FTimeoutAction write FTimeoutAction default TARollback;
property TRParams: TStrings read FTRParams write SetTRParams;
// Events
property OnTimeout: TNotifyEvent read FOnTimeout write FOnTimeout;
property WatchUncommitedUpdates :boolean read FWatchUpdates write FWatchUpdates default false;
{$IFDEF CSMonitor}
property CSMonitorSupport: TCSMonitorSupport read FCSMonitorSupport write SetCSMonitorSupport;
{$ENDIF}
protected
FMDTTransactionRole: TFIBMDTTransactionRole;
FMDTDeferredStart: boolean;
FMDTIBRealDBTransaction: IMDTIBRealDBTransaction;
procedure SetMDTTransactionRole(AValue: TFIBMDTTransactionRole);
function GetIMDTDatabase: IMDTDatabase;
function GetIMDTIBRealDBCanal: IMDTIBRealDBCanal;
public
procedure MDTDataChange;
function GetIsUsingMDT: boolean;
property MDTDatabase: IMDTDatabase read GetIMDTDatabase;
property MDTIBRealDBCanal: IMDTIBRealDBCanal read GetIMDTIBRealDBCanal;
property IsUsingMDT:boolean read GetIsUsingMDT;
property MDTDeferredStart: boolean
read FMDTDeferredStart;// write FMDTDeferredStart;
published
property MDTTransactionRole: TFIBMDTTransactionRole
read FMDTTransactionRole write SetMDTTransactionRole default mtrAutoDefine;
end;
(* TFIBBase *)
(* Virtually all components in FIB are "descendents" of TFIBBase. *)
(* It is to more easily manage the database and transaction *)
(* connections. *)
TFIBBase = class(TObject)
protected
FDatabase: TFIBDatabase;
FIndexInDatabase: Integer;
FTransaction: TFIBTransaction;
FIndexInTransaction: Integer;
FOwner: TObject;
procedure FOnDatabaseConnecting;
procedure FOnDatabaseConnected;
procedure FOnDatabaseDisconnecting;
procedure FOnDatabaseDisconnected;
procedure FOnTransactionStarting;
procedure FOnTransactionStarted;
procedure FOnDatabaseFree;
procedure FOnTransactionEnding;
procedure FOnTransactionEnded;
procedure FOnTransactionFree;
function GetDBHandle: PISC_DB_HANDLE;
function GetTRHandle: PISC_TR_HANDLE;
procedure SetDatabase(Value: TFIBDatabase);
procedure SetTransaction(Value: TFIBTransaction);
public
constructor Create(AOwner: TObject);
destructor Destroy; override;
procedure CheckDatabase; virtual;
procedure CheckTransaction; virtual;
public // properties
OnDatabaseConnecting: TNotifyEvent;
OnDatabaseConnected: TNotifyEvent;
OnDatabaseDisconnecting: TNotifyEvent;
OnDatabaseDisconnected: TNotifyEvent;
OnDatabaseFree: TNotifyEvent;
OnTransactionEnding: TNotifyEvent;
OnTransactionEnded: TNotifyEvent;
OnTransactionStarting: TNotifyEvent;
OnTransactionStarted: TNotifyEvent;
OnTransactionFree: TNotifyEvent;
property Database: TFIBDatabase read FDatabase
write SetDatabase;
property DBHandle: PISC_DB_HANDLE read GetDBHandle;
property Owner: TObject read FOwner;
property TRHandle: PISC_TR_HANDLE read GetTRHandle;
property Transaction: TFIBTransaction read FTransaction
write SetTransaction;
end;
procedure SaveSchemaToFile(const FileName:string);
function LoadSchemaFromFile(const FileName:string; const NeedValidate:boolean=True;
DB:TFIBDatabase=nil
):boolean;
procedure IBFilterBuffer(DataBase:TFIBDataBase;
var BlobBuffer:PAnsiChar;var BlobSize:longint; BlobSubType:integer;ForEncode: boolean
);
function ExistBlobFilter(DataBase:TFIBDataBase;BlobSubType:integer):boolean;
function GetConnectedDataBase(const DBName:string ):TFIBDatabase;
procedure CloseAllDatabases;
procedure AssignSQLObjectParams(Dest: ISQLObject; ParamSources : array of ISQLObject);
const
OCTETS_CHARSET_ID=1;
var DefDataBase :TFIBDatabase;
DatabaseList :TThreadList;
FIBHideGrantError :boolean = False;
implementation
uses
{$IFNDEF NO_MONITOR}
FIBSQLMonitor,
{$ENDIF}
{$IFDEF D_XE3}
System.Types, // for inline funcs
{$ENDIF}
FIBMiscellaneous,pFIBDataInfo,FIBQuery, StrUtil,pFIBCacheQueries, FIBConsts;
var
vConnectCS: TCriticalSection;
procedure AssignSQLObjectParams(Dest: ISQLObject; ParamSources : array of ISQLObject);
var
i: Integer;
j: Integer;
k: Integer;
c: Integer;
pName:string;
OldValue:boolean;
begin
if Dest=nil then
Exit;
c:=Pred(Dest.ParamCount);
for i := 0 to c do
begin
pName:=Dest.ParamName(i);
OldValue:=False;
if IsNewParamName(pName) then
pName:=FastCopy(pName,5,MaxInt)
else
if IsOldParamName(pName) then
begin
pName:=FastCopy(pName,5,MaxInt);
OldValue:=True;
end;
for j := Low(ParamSources) to High(ParamSources) do
if Assigned(ParamSources[j]) then
if ParamSources[j].FieldExist(pName,k) then
begin
Dest.SetParamValue(i,ParamSources[j].FieldValue(k,OldValue))
end
else
if ParamSources[j].ParamExist(Dest.ParamName(i),k) then
begin
Dest.SetParamValue(i,ParamSources[j].ParamValue(k))
end;
end;
end;
function GetConnectedDataBase(const DBName:string ):TFIBDatabase;
var i:integer;
begin
Result:=nil;
with DatabaseList.LockList do
try
for I := 0 to Count - 1 do
if (TFIBDatabase(Items[i]).DBName=DBName)and (TFIBDatabase(Items[i]).Connected)
then
begin
Result:=TFIBDatabase(Items[i]);
Break;
end;
finally
DatabaseList.UnLockList
end;
end;
procedure CloseAllDatabases;
var i:integer;
begin
with DatabaseList.LockList do
try
for i:=0 to Count-1 do
begin
if TFIBDatabase(Items[i]).Connected then
TFIBDatabase(Items[i]).ForceClose
end;
finally
DatabaseList.UnLockList
end;
end;
procedure IBFilterBuffer(DataBase:TFIBDataBase;
var BlobBuffer:PAnsiChar;var BlobSize:longint;
BlobSubType:integer;ForEncode: boolean);
begin
if DataBase.FBlobFilters=nil then
Exit;
DataBase.FBlobFilters.IBFilterBuffer(BlobBuffer,BlobSize,BlobSubType,ForEncode);
end;
function ExistBlobFilter(DataBase:TFIBDataBase;BlobSubType:integer):boolean;
var
anIndex:integer;
begin
if Assigned(DataBase.FBlobFilters) then
Result:=DataBase.FBlobFilters.Find(BlobSubType,anIndex)
else
Result:=False
end;
procedure SaveSchemaToFile(const FileName:string);
begin
ListTableInfo.SaveToFile(FileName);
ListDataSetInfo.SaveToFile(ChangeFileExt(FileName,'.dt'));
ListErrorMessages.SaveToFile(ChangeFileExt(FileName,'.err'));
end;
function LoadSchemaFromFile(const FileName:string; const NeedValidate:boolean=True;
DB:TFIBDatabase=nil
):boolean;
begin
Result:=ListTableInfo.LoadFromFile(FileName,DB);
ListTableInfo.NeedValidate:=NeedValidate;
ListDataSetInfo.LoadFromFile(ChangeFileExt(FileName,'.dt'));
ListDataSetInfo.NeedValidate:=NeedValidate;
ListErrorMessages.LoadFromFile(ChangeFileExt(FileName,'.err'));