mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Override "main" database name with custom one. Closes #948
This commit is contained in:
@@ -633,6 +633,7 @@ type
|
||||
FHandle: Psqlite3;
|
||||
FLib: TSQLiteLib;
|
||||
FLastRawResults: TSQLiteRawResults;
|
||||
FMainDbName: UTF8String;
|
||||
procedure SetActive(Value: Boolean); override;
|
||||
procedure DoBeforeConnect; override;
|
||||
function GetThreadId: Int64; override;
|
||||
@@ -2464,6 +2465,11 @@ begin
|
||||
Log(lcInfo, f_('Connected. Thread-ID: %d', [ThreadId]));
|
||||
FIsUnicode := True;
|
||||
Query('PRAGMA busy_timeout='+(Parameters.QueryTimeout*1000).ToString);
|
||||
// Override "main" database name with custom one
|
||||
FMainDbName := UTF8Encode(TPath.GetFileNameWithoutExtension(MainFile));
|
||||
if FLib.sqlite3_db_config(FHandle, SQLITE_DBCONFIG_MAINDBNAME, PAnsiChar(FMainDbName)) <> SQLITE_OK then begin
|
||||
Log(lcError, 'Could not set custom name of "main" database to "' + UTF8ToString(FMainDbName) + '"');
|
||||
end;
|
||||
// Attach additional databases
|
||||
for i:=1 to FileNames.Count-1 do begin
|
||||
DbAlias := TPath.GetFileNameWithoutExtension(FileNames[i]);
|
||||
|
||||
@@ -141,6 +141,29 @@ const
|
||||
SQLITE_FLOAT = 2;
|
||||
SQLITE_BLOB = 4;
|
||||
SQLITE_NULL = 5;
|
||||
SQLITE_TEXT = 3;
|
||||
SQLITE3_TEXT = 3;
|
||||
|
||||
{ CAPI3REF: Database Connection Configuration Options
|
||||
These constants are the available integer configuration options that
|
||||
can be passed as the second argument to the [sqlite3_db_config()] interface.
|
||||
}
|
||||
SQLITE_DBCONFIG_MAINDBNAME = 1000; // const char*
|
||||
SQLITE_DBCONFIG_LOOKASIDE = 1001; // void* int int
|
||||
SQLITE_DBCONFIG_ENABLE_FKEY = 1002; // int int*
|
||||
SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; // int int*
|
||||
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004; // int int*
|
||||
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005; // int int*
|
||||
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006; // int int*
|
||||
SQLITE_DBCONFIG_ENABLE_QPSG = 1007; // int int*
|
||||
SQLITE_DBCONFIG_TRIGGER_EQP = 1008; // int int*
|
||||
SQLITE_DBCONFIG_RESET_DATABASE = 1009; // int int*
|
||||
SQLITE_DBCONFIG_DEFENSIVE = 1010; // int int*
|
||||
SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011; // int int*
|
||||
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012; // int int*
|
||||
SQLITE_DBCONFIG_DQS_DML = 1013; // int int*
|
||||
SQLITE_DBCONFIG_DQS_DDL = 1014; // int int*
|
||||
SQLITE_DBCONFIG_ENABLE_VIEW = 1015; // int int*
|
||||
SQLITE_DBCONFIG_MAX = 1015; // Largest DBCONFIG
|
||||
|
||||
|
||||
@@ -537,6 +560,7 @@ const
|
||||
private
|
||||
procedure AssignProcedures; override;
|
||||
end;
|
||||
TSQLiteLib = class(TDbLib)
|
||||
sqlite3_open: function(const filename: PAnsiChar; var ppDb: Psqlite3): Integer; cdecl;
|
||||
sqlite3_libversion: function(): PAnsiChar; cdecl;
|
||||
sqlite3_close: function(ppDb: Psqlite3): Integer; cdecl;
|
||||
@@ -7904,6 +7928,7 @@ begin
|
||||
|
||||
|
||||
procedure TSQLiteLib.AssignProcedures;
|
||||
begin
|
||||
AssignProc(@sqlite3_open, 'sqlite3_open');
|
||||
AssignProc(@sqlite3_libversion, 'sqlite3_libversion');
|
||||
AssignProc(@sqlite3_close, 'sqlite3_close');
|
||||
|
||||
Reference in New Issue
Block a user