}
rspamd_file_unlock (fd, FALSE);
-
+ unlink (lock);
close (fd);
return TRUE;
return NULL;
}
- if (create) {
+ if (create && has_lock) {
if (sqlite3_exec (sqlite, sqlite_wal, NULL, NULL, NULL) != SQLITE_OK) {
msg_warn_pool_check ("WAL mode is not supported (%s), locking issues might occur",
sqlite3_errmsg (sqlite));
sqlite3_errmsg (sqlite));
}
- if (sqlite3_exec (sqlite, create_sql, NULL, NULL, NULL) != SQLITE_OK) {
- g_set_error (err, rspamd_sqlite3_quark (),
- -1, "cannot execute create sql `%s`: %s",
- create_sql, sqlite3_errmsg (sqlite));
- sqlite3_close (sqlite);
- rspamd_file_unlock (lock_fd, FALSE);
- unlink (lock_path);
- close (lock_fd);
-
- return NULL;
+ if (create_sql) {
+ if (sqlite3_exec (sqlite, create_sql, NULL, NULL, NULL) != SQLITE_OK) {
+ g_set_error (err, rspamd_sqlite3_quark (),
+ -1, "cannot execute create sql `%s`: %s",
+ create_sql, sqlite3_errmsg (sqlite));
+ sqlite3_close (sqlite);
+ rspamd_file_unlock (lock_fd, FALSE);
+ unlink (lock_path);
+ close (lock_fd);
+
+ return NULL;
+ }
}
sqlite3_close (sqlite);
-
/* Reopen in normal mode */
msg_debug_pool_check ("reopening %s in normal mode", path);
flags &= ~SQLITE_OPEN_CREATE;
static const struct luaL_reg sqlitelib_m[] = {
LUA_INTERFACE_DEF (sqlite3, sql),
+ {"query", lua_sqlite3_sql},
+ {"exec", lua_sqlite3_sql},
LUA_INTERFACE_DEF (sqlite3, rows),
{"__tostring", rspamd_lua_class_tostring},
{"__gc", lua_sqlite3_close},