/soc/2015/igor.gajowiak/chatlog: 6399e55787c2: SQLite log: move ...

Igor Gajowiak igor.gajowiak at gmail.com
Tue Jul 21 15:57:43 EDT 2015


Changeset: 6399e55787c2c04c76da3730b691fde5c1e1975d
Author:	 Igor Gajowiak <igor.gajowiak at gmail.com>
Date:	 2015-07-21 21:57 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/6399e55787c2

Description:

SQLite log: move pragmas execution from table creation query to the db initialization function.

diffstat:

 libpurple/plugins/log/logsqlite.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (31 lines):

diff --git a/libpurple/plugins/log/logsqlite.c b/libpurple/plugins/log/logsqlite.c
--- a/libpurple/plugins/log/logsqlite.c
+++ b/libpurple/plugins/log/logsqlite.c
@@ -203,11 +203,6 @@ static int
 sqlitelog_create_tables(sqlite3 *db_handle)
 {
 	const char *query =
-		// These pragmas are needed to achieve a reasonable performance,
-		// without them updates are ~3k times slower
-		"PRAGMA synchronous=OFF; "
-		"PRAGMA journal_mode=MEMORY; "
-
 		"CREATE TABLE Accounts("
 		"Id INTEGER PRIMARY KEY AUTOINCREMENT,"
 		"Username TEXT NOT NULL,"
@@ -264,6 +259,15 @@ sqlitelog_init_db(const gchar *db_path, 
 		return FALSE;
 	}
 
+	// These pragmas are needed to achieve a reasonable performance,
+	// without them updates are ~3k times slower
+	char *query = "PRAGMA synchronous=OFF; "
+		"PRAGMA journal_mode=MEMORY; ";
+	if(sqlite3_exec(handle, query, NULL, NULL, NULL) != SQLITE_OK) {
+		sqlitelog_close_db_if_notnull(handle);
+		return FALSE;
+	}
+
 	*db_handle = handle;
 	return TRUE;
 }



More information about the Commits mailing list