{************************************************************************}
{ }
{ Borland Delphi Visual Component Library }
{ InterBase Express core components }
{ }
{ Copyright (c) 1998-2001 Borland Software Corporation }
{ }
{ InterBase Express is based in part on the product }
{ Free IB Components, written by Gregory H. Deatz for }
{ Hoagland, Longo, Moran, Dunst & Doukas Company. }
{ Free IB Components is used under license. }
{ }
{ The contents of this file are subject to the InterBase }
{ Public License Version 1.0 (the "License"); you may not }
{ use this file except in compliance with the License. You may obtain }
{ a copy of the License at http://www.borland.com/interbase/IPL.html }
{ Software distributed under the License is distributed on }
{ an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either }
{ express or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ The Original Code was created by InterBase Software Corporation }
{ and its successors. }
{ Portions created by Borland Software Corporation are Copyright }
{ (C) Borland Software Corporation. All Rights Reserved. }
{ Contributor(s): Jeff Overcash }
{ }
{************************************************************************}
unit IBDatabase;
interface
uses
Windows, Dialogs, Controls, StdCtrls, SysUtils, Classes, Forms, ExtCtrls,
IBHeader, IBExternals, DB, IB;
const
DPBPrefix = 'isc_dpb_';
DPBConstantNames: array[1..isc_dpb_last_dpb_constant] of string = (
'cdd_pathname',
'allocation',
'journal',
'page_size',
'num_buffers',
'buffer_length',
'debug',
'garbage_collect',
'verify',
'sweep',
'enable_journal',
'disable_journal',
'dbkey_scope',
'number_of_users',
'trace',
'no_garbage_collect',
'damaged',
'license',
'sys_user_name',
'encrypt_key',
'activate_shadow',
'sweep_interval',
'delete_shadow',
'force_write',
'begin_log',
'quit_log',
'no_reserve',
'user_name',
'password',
'password_enc',
'sys_user_name_enc',
'interp',
'online_dump',
'old_file_size',
'old_num_files',
'old_file',
'old_start_page',
'old_start_seqno',
'old_start_file',
'drop_walfile',
'old_dump_id',
'wal_backup_dir',
'wal_chkptlen',
'wal_numbufs',
'wal_bufsize',
'wal_grp_cmt_wait',
'lc_messages',
'lc_ctype',
'cache_manager',
'shutdown',
'online',
'shutdown_delay',
'reserved',
'overwrite',
'sec_attach',
'disable_wal',
'connect_timeout',
'dummy_packet_interval',
'gbak_attach',
'sql_role_name',
'set_page_buffers',
'working_directory',
'sql_dialect',
'set_db_readonly',
'set_db_sql_dialect',
'gfix_attach',
'gstat_attach'
);
TPBPrefix = 'isc_tpb_';
TPBConstantNames: array[1..isc_tpb_last_tpb_constant] of string = (
'consistency',
'concurrency',
'shared',
'protected',
'exclusive',
'wait',
'nowait',
'read',
'write',
'lock_read',
'lock_write',
'verb_time',
'commit_time',
'ignore_limbo',
'read_committed',
'autocommit',
'rec_version',
'no_rec_version',
'restart_requests',
'no_auto_undo'
);
type
TIBDatabase = class;
TIBTransaction = class;
TIBBase = class;
TIBDatabaseLoginEvent = procedure(Database: TIBDatabase;
LoginParams: TStrings) of object;
IIBEventNotifier = interface
['{9427DE09-46F7-4E1D-8B92-C1F88B47BF6D}']
procedure RegisterEvents;
procedure UnRegisterEvents;
function GetAutoRegister: Boolean;
end;
TIBSchema = class(TObject)
public
procedure FreeNodes; virtual; abstract;
function Has_DEFAULT_VALUE(Relation, Field : String) : Boolean; virtual; abstract;
function Has_COMPUTED_BLR(Relation, Field : String) : Boolean; virtual; abstract;
end;
TIBFileName = type string;
{ TIBDatabase }
TIBDataBase = class(TCustomConnection)
private
FHiddenPassword: string;
FIBLoaded: Boolean;
FOnLogin: TIBDatabaseLoginEvent;
FTraceFlags: TTraceFlags;
FDBSQLDialect: Integer;
FSQLDialect: Integer;
FOnDialectDowngradeWarning: TNotifyEvent;
FCanTimeout: Boolean;
FSQLObjects: TList;
FTransactions: TList;
FDBName: TIBFileName;
FDBParams: TStrings;
FDBParamsChanged: Boolean;
FDPB: PChar;
FDPBLength: Short;
FHandle: TISC_DB_HANDLE;
FHandleIsShared: Boolean;
FOnIdleTimer: TNotifyEvent;
FDefaultTransaction: TIBTransaction;
FInternalTransaction: TIBTransaction;
FTimer: TTimer;
FUserNames: TStringList;
FEventNotifiers : TList;
FAllowStreamedConnected: Boolean;
FSchema : TIBSchema;
procedure EnsureInactive;
function GetDBSQLDialect: Integer;
function GetSQLDialect: Integer;
procedure SetSQLDialect(const Value: Integer);
procedure ValidateClientSQLDialect;
procedure DBParamsChange(Sender: TObject);
procedure DBParamsChanging(Sender: TObject);
function GetSQLObject(Index: Integer): TIBBase;
function GetSQLObjectCount: Integer;
function GetDBParamByDPB(const Idx: Integer): String;
function GetIdleTimer: Integer;
function GetTransaction(Index: Integer): TIBTransaction;
function GetTransactionCount: Integer;
function Login: Boolean;
procedure SetDatabaseName(const Value: TIBFileName);
procedure SetDBParamByDPB(const Idx: Integer; Value: String);
procedure SetDBParams(Value: TStrings);
procedure SetDefaultTransaction(Value: TIBTransaction);
procedure SetIdleTimer(Value: Integer);
procedure TimeoutConnection(Sender: TObject);
function GetIsReadOnly: