From 91b41656897ad4daa8627e6cb4eda68a8c44733a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Feb 2016 19:01:26 +0100 Subject: mod_storage_sql: Lower message about new engine creation to debug level --- plugins/mod_storage_sql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_storage_sql.lua') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 50d34a23..a11523d0 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -453,7 +453,7 @@ function module.load() local params = normalize_params(module:get_option("sql", default_params)); engine = engines[sql.db2uri(params)]; if not engine then - module:log("info", "Creating new engine"); + module:log("debug", "Creating new engine"); engine = sql:create_engine(params, function (engine) if module:get_option("sql_manage_tables", true) then -- Automatically create table, ignore failure (table probably already exists) -- cgit v1.2.3 From 70c1c2a643db61dbc65b4bf77996e8337d8612ed Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Feb 2016 19:29:00 +0100 Subject: mod_storage_sql: Remove debug logging of archive queries --- plugins/mod_storage_sql.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins/mod_storage_sql.lua') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index a11523d0..af2bcef4 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -275,7 +275,6 @@ function archive_store:find(username, query) end sql_query = sql_query:format(t_concat(where, " AND "), query.reverse and "DESC" or "ASC", query.limit and " LIMIT ?" or ""); - module:log("debug", sql_query); return engine:select(sql_query, unpack(args)); end); if not ok then return ok, result end @@ -301,7 +300,6 @@ function archive_store:delete(username, query) archive_where(query, args, where); archive_where_id_range(query, args, where); sql_query = sql_query:format(t_concat(where, " AND ")); - module:log("debug", sql_query); return engine:delete(sql_query, unpack(args)); end); end -- cgit v1.2.3 From a1bba9eeab3263061a2b1e1634847b3ed4002e20 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 22 Feb 2016 15:23:27 +0100 Subject: mod_storage_sql: Treat non-existent archive IDs as beyound the end of the archive (fixes #624) (tested on sqlite3 only) --- plugins/mod_storage_sql.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mod_storage_sql.lua') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index af2bcef4..bf3c1c7b 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -235,12 +235,12 @@ local function archive_where_id_range(query, args, where) local args_len = #args -- Before or after specific item, exclusive if query.after then -- keys better be unique! - where[#where+1] = "`sort_id` > (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ? AND `user` = ? AND `store` = ? LIMIT 1)" + where[#where+1] = "`sort_id` > COALESCE((SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ? AND `user` = ? AND `store` = ? LIMIT 1), 0)" args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.after, args[1], args[2], args[3]; args_len = args_len + 4 end if query.before then - where[#where+1] = "`sort_id` < (SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ? AND `user` = ? AND `store` = ? LIMIT 1)" + where[#where+1] = "`sort_id` < COALESCE((SELECT `sort_id` FROM `prosodyarchive` WHERE `key` = ? AND `host` = ? AND `user` = ? AND `store` = ? LIMIT 1), (SELECT MAX(`sort_id`)+1 FROM `prosodyarchive`))" args[args_len+1], args[args_len+2], args[args_len+3], args[args_len+4] = query.before, args[1], args[2], args[3]; end end -- cgit v1.2.3