Diff

plugins/mod_storage_sql2.lua @ 6060:de4c83feb064

mod_storage_sql2: Build counter query without ORDER BY clause
author Kim Alvefur <zash@zash.se>
date Tue, 08 Apr 2014 19:23:11 +0200
parent 6013:918ab89cb68d
child 6165:6a184b16b717
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua	Thu Apr 03 23:48:12 2014 +0200
+++ b/plugins/mod_storage_sql2.lua	Tue Apr 08 19:23:11 2014 +0200
@@ -289,7 +289,7 @@
 
 		-- Total matching
 		if query.total then
-			local stats = engine:select(sql_query:gsub("^(SELECT).-(FROM)", "%1 COUNT(*) %2"):format(t_concat(where, " AND "), "DESC", ""), unpack(args));
+			local stats = engine:select("SELECT COUNT(*) FROM `prosodyarchive` WHERE " .. t_concat(where, " AND "), unpack(args));
 			if stats then
 				local _total = stats()
 				total = _total and _total[1];