diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2013-06-03 22:51:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2013-06-03 22:51:14 +0000 |
commit | 38f6d7addec36d20d9119077b886c125c21451af (patch) | |
tree | 57df695749bd7f2695d2064addc26c26438be49c /mandocdb.c | |
parent | 9847d1de3925a9ddd98c0faa9ddcc9d5cd5a3ffe (diff) | |
download | mandoc-38f6d7addec36d20d9119077b886c125c21451af.tar.gz |
Changing existing SQLite databases was utterly broken:
1) SQL statements were only prepared when creating a new database.
2) We rely heavily on foreign_keys, but never enabled them.
Diffstat (limited to 'mandocdb.c')
-rw-r--r-- | mandocdb.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1933,7 +1933,7 @@ dbopen(const char *base, int real) rc = sqlite3_open_v2(file, &db, ofl, NULL); if (SQLITE_OK == rc) - return(1); + goto prepare_statements; if (SQLITE_CANTOPEN != rc) { perror(file); return(0); @@ -1971,6 +1971,8 @@ dbopen(const char *base, int real) return(0); } +prepare_statements: + SQL_EXEC("PRAGMA foreign_keys = ON"); sql = "DELETE FROM docs where file=?"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_DELETE], NULL); sql = "INSERT INTO docs " |