diff options
author | Adam Chlipala <adamc@csail.mit.edu> | 2018-03-11 13:27:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-11 13:27:26 -0400 |
commit | e2d548c69e2a83ace5123ade21262aa27336fb6b (patch) | |
tree | a0ce3c3178e2e26e6aae7327259a9e80e73def77 | |
parent | 458c671a9d5fb352aafebe4b9e1b00670e8e706f (diff) | |
parent | e6567eca7c5567b8bd4a93ba516170aed9e30662 (diff) |
Merge pull request #119 from steinuil/sqlite-fix
Automatically enable foreign keys and WAL in SQLite
-rw-r--r-- | src/sqlite.sml | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/sqlite.sml b/src/sqlite.sml index a9b6389d..0acd866b 100644 --- a/src/sqlite.sml +++ b/src/sqlite.sml @@ -273,6 +273,11 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = string "\"Can't open SQLite database.\");", newline, newline, + string "if (sqlite3_exec(sqlite, \"PRAGMA foreign_keys = ON\", NULL, NULL, NULL) != SQLITE_OK)", + newline, + box [string "uw_error(ctx, FATAL, \"Can't enable foreign_keys for SQLite database\");", + newline], + newline, string "if (uw_database_max < SIZE_MAX) {", newline, box [string "char buf[100];", @@ -843,7 +848,7 @@ val () = addDbms {name = "sqlite", textKeysNeedLengths = false, supportsNextval = false, supportsNestedPrepared = false, - sqlPrefix = "", + sqlPrefix = "PRAGMA foreign_keys = ON;\nPRAGMA journal_mode = WAL;\n\n", supportsOctetLength = false, trueString = "1", falseString = "0", |