summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-06-03 22:51:14 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-06-03 22:51:14 +0000
commit38f6d7addec36d20d9119077b886c125c21451af (patch)
tree57df695749bd7f2695d2064addc26c26438be49c /mandocdb.c
parent9847d1de3925a9ddd98c0faa9ddcc9d5cd5a3ffe (diff)
downloadmandoc-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.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 04ffaf19..8360fede 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -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 "