diff options
author | steinuil <steenuil.owl@gmail.com> | 2018-02-26 15:54:56 +0100 |
---|---|---|
committer | steinuil <steenuil.owl@gmail.com> | 2018-02-26 16:34:44 +0100 |
commit | e6567eca7c5567b8bd4a93ba516170aed9e30662 (patch) | |
tree | a0ce3c3178e2e26e6aae7327259a9e80e73def77 | |
parent | 458c671a9d5fb352aafebe4b9e1b00670e8e706f (diff) |
automatically enable foreign keys and WAL for 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", |