Mercurial > prosody-hg
comparison plugins/mod_storage_sql.lua @ 12599:5aafcf6a0730 0.12
mod_storage_sql: Fix summary API with Postgres (fixes #1766)
The ORDER BY and LIMIT clauses are not needed and don't even make much
sense. This part was most likely a leftover from the :find method.
Tested with sqlite and postgres 14
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 22 Jul 2022 19:09:50 +0200 |
| parents | d580e6a57cbb |
| children | 3d3a0c4e2662 dd6c35325241 |
comparison
equal
deleted
inserted
replaced
| 12598:a2624315d30e | 12599:5aafcf6a0730 |
|---|---|
| 542 local ok, result = engine:transaction(function() | 542 local ok, result = engine:transaction(function() |
| 543 local sql_query = [[ | 543 local sql_query = [[ |
| 544 SELECT DISTINCT "with", COUNT(*), MIN("when"), MAX("when") | 544 SELECT DISTINCT "with", COUNT(*), MIN("when"), MAX("when") |
| 545 FROM "prosodyarchive" | 545 FROM "prosodyarchive" |
| 546 WHERE %s | 546 WHERE %s |
| 547 GROUP BY "with" | 547 GROUP BY "with"; |
| 548 ORDER BY "sort_id" %s%s; | |
| 549 ]]; | 548 ]]; |
| 550 local args = { host, user or "", store, }; | 549 local args = { host, user or "", store, }; |
| 551 local where = { "\"host\" = ?", "\"user\" = ?", "\"store\" = ?", }; | 550 local where = { "\"host\" = ?", "\"user\" = ?", "\"store\" = ?", }; |
| 552 | 551 |
| 553 archive_where(query, args, where); | 552 archive_where(query, args, where); |
| 556 | 555 |
| 557 if query.limit then | 556 if query.limit then |
| 558 args[#args+1] = query.limit; | 557 args[#args+1] = query.limit; |
| 559 end | 558 end |
| 560 | 559 |
| 561 sql_query = sql_query:format(t_concat(where, " AND "), query.reverse | 560 sql_query = sql_query:format(t_concat(where, " AND ")); |
| 562 and "DESC" or "ASC", query.limit and " LIMIT ?" or ""); | |
| 563 return engine:select(sql_query, unpack(args)); | 561 return engine:select(sql_query, unpack(args)); |
| 564 end); | 562 end); |
| 565 if not ok then return ok, result end | 563 if not ok then return ok, result end |
| 566 local counts = {}; | 564 local counts = {}; |
| 567 local earliest, latest = {}, {}; | 565 local earliest, latest = {}, {}; |
