diff options
Diffstat (limited to 'pseudo_db.c')
-rw-r--r-- | pseudo_db.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/pseudo_db.c b/pseudo_db.c index d7b28f1..14bafcb 100644 --- a/pseudo_db.c +++ b/pseudo_db.c @@ -3,18 +3,7 @@ * * Copyright (c) 2008-2010,2013 Wind River Systems, Inc. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the Lesser GNU General Public License version 2.1 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the Lesser GNU General Public License for more details. - * - * You should have received a copy of the Lesser GNU General Public License - * version 2.1 along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * SPDX-License-Identifier: LGPL-2.1-only * */ #include <stdio.h> @@ -169,11 +158,24 @@ static struct sql_index { static char *file_pragmas[] = { "PRAGMA legacy_file_format = OFF;", - "PRAGMA journal_mode = OFF;", +#ifdef USE_MEMORY_DB /* the default page size produces painfully bad behavior * for memory databases with some versions of sqlite. */ "PRAGMA page_size = 8192;", + "PRAGMA journal_mode = OFF;", +#else + /* Use WAL mode when using the on-disk database. If user care about + * performance, they can use the in-memory database, but if they care + * more about resilience, they can disable it and WAL mode will prevent + * corruption of the on-disk database (for a slight performance + * penalty). Note that the database still keeps synchronous to OFF, + * meaning its resilient to the pseudo process crashing or being killed + * unexpectedly, but not to the OS crashing and losing buffered disk + * state + */ + "PRAGMA journal_mode = WAL;", +#endif "PRAGMA locking_mode = EXCLUSIVE;", /* Setting this to NORMAL makes pseudo noticably slower * than fakeroot, but is perhaps more secure. However, @@ -397,7 +399,7 @@ signed_ino(ino_t ino) { #ifdef USE_MEMORY_DB -static void +void pdb_backup() { sqlite3_backup *pBackup; /* no point in doing this if we don't have a database to back up, @@ -2018,8 +2020,8 @@ int pdb_rename_file(const char *oldpath, pseudo_msg_t *msg) { static sqlite3_stmt *update_exact, *update_sub; int rc; - char *sql_update_exact = "UPDATE files SET path = ? WHERE path = ?;"; - char *sql_update_sub = "UPDATE files SET path = replace(path, ?, ?) " + char *sql_update_exact = "UPDATE files SET path = ?, deleting = 0 WHERE path = ?;"; + char *sql_update_sub = "UPDATE files SET path = replace(path, ?, ?), deleting = 0 " "WHERE (path > (? || '/') AND path < (? || '0'));"; if (!file_db && get_dbs()) { |