mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 04:52:17 +02:00
fcl-db: sqlite: add support for journal_mode pragma (beside foreign_keys pragma). This pragma must be set after connect before any transaction starts.
git-svn-id: trunk@47656 -
This commit is contained in:
parent
67d2ecc09f
commit
738959ce59
@ -19,7 +19,8 @@
|
||||
|
||||
TSQLite3Connection properties
|
||||
Params - "foreign_keys=ON" - enable foreign key support for this connection:
|
||||
http://www.sqlite.org/foreignkeys.html#fk_enable
|
||||
https://www.sqlite.org/foreignkeys.html#fk_enable
|
||||
"journal_mode=..." https://www.sqlite.org/pragma.html#pragma_journal_mode
|
||||
|
||||
}
|
||||
|
||||
@ -867,9 +868,12 @@ begin
|
||||
end;
|
||||
|
||||
procedure TSQLite3Connection.DoInternalConnect;
|
||||
const
|
||||
PRAGMAS:array[0..1] of string=('foreign_keys','journal_mode');
|
||||
var
|
||||
filename: ansistring;
|
||||
pvfs: PChar;
|
||||
i,j: integer;
|
||||
begin
|
||||
Inherited;
|
||||
if DatabaseName = '' then
|
||||
@ -883,8 +887,11 @@ begin
|
||||
checkerror(sqlite3_open_v2(PAnsiChar(filename),@fhandle,GetSQLiteOpenFlags,pvfs));
|
||||
if (Length(Password)>0) and assigned(sqlite3_key) then
|
||||
checkerror(sqlite3_key(fhandle,PChar(Password),StrLen(PChar(Password))));
|
||||
if Params.IndexOfName('foreign_keys') <> -1 then
|
||||
execsql('PRAGMA foreign_keys = '+Params.Values['foreign_keys']);
|
||||
for i:=Low(PRAGMAS) to High(PRAGMAS) do begin
|
||||
j:=Params.IndexOfName(PRAGMAS[i]);
|
||||
if j <> -1 then
|
||||
execsql('PRAGMA '+Params[j]);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSQLite3Connection.DoInternalDisconnect;
|
||||
|
Loading…
Reference in New Issue
Block a user