mod_storage_sql: Call commit() after all SQL statements, including SELECT, to get SQLite to drop its locks.

Mon, 27 Dec 2010 06:10:35 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Mon, 27 Dec 2010 06:10:35 +0500
changeset 3975
aa5e93e61760
parent 3974
af40a7ce4f77
child 3976
16170a66e140

mod_storage_sql: Call commit() after all SQL statements, including SELECT, to get SQLite to drop its locks.

plugins/mod_storage_sql.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_storage_sql.lua	Mon Dec 27 06:10:35 2010 +0500
+++ b/plugins/mod_storage_sql.lua	Mon Dec 27 06:10:35 2010 +0500
@@ -55,9 +55,9 @@
 		if count == 0 then
 			local stmt = assert(connection:prepare("CREATE TABLE `Prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `subkey` TEXT, `type` TEXT, `value` TEXT);"));
 			assert(stmt:execute());
-			assert(connection:commit());
 			module:log("debug", "Initialized new SQLite3 database");
 		end
+		assert(connection:commit());
 		--print("===", json.stringify())
 	end
 end
@@ -132,7 +132,7 @@
 			end
 		end
 	end
-	return haveany and result or nil;
+	return commit(haveany and result or nil);
 end
 function keyval_store:set(username, data)
 	user,store = username,self.store;
@@ -182,7 +182,7 @@
 			end
 		end
 	end
-	return haveany and result or nil;
+	return commit(haveany and result or nil);
 end
 function map_store:set(username, key, data)
 	user,store = username,self.store;

mercurial