mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Make delete_old_mam_messages_batch work with sqlite
This commit is contained in:
parent
ef754939c4
commit
45e7d8426d
1 changed files with 31 additions and 15 deletions
|
@ -217,16 +217,32 @@ delete_old_messages_batch(ServerHost, TimeStamp, Type, Batch) ->
|
||||||
all ->
|
all ->
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
ServerHost,
|
ServerHost,
|
||||||
|
fun(sqlite, _) ->
|
||||||
|
ejabberd_sql:sql_query_t(
|
||||||
|
?SQL("delete from archive where rowid in "
|
||||||
|
"(select rowid from archive where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d)"));
|
||||||
|
(_, _) ->
|
||||||
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from archive"
|
?SQL("delete from archive"
|
||||||
" where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d"));
|
" where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d"))
|
||||||
|
end);
|
||||||
_ ->
|
_ ->
|
||||||
SType = misc:atom_to_binary(Type),
|
SType = misc:atom_to_binary(Type),
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
ServerHost,
|
ServerHost,
|
||||||
|
fun(sqlire,_)->
|
||||||
|
ejabberd_sql:sql_query_t(
|
||||||
|
?SQL("delete from archive where rowid in ("
|
||||||
|
" select rowid from archive where timestamp < %(TS)d"
|
||||||
|
" and kind=%(SType)s"
|
||||||
|
" and %(ServerHost)H limit %(Batch)d)"));
|
||||||
|
(_,_)->
|
||||||
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from archive"
|
?SQL("delete from archive"
|
||||||
" where timestamp < %(TS)d"
|
" where timestamp < %(TS)d"
|
||||||
" and kind=%(SType)s"
|
" and kind=%(SType)s"
|
||||||
" and %(ServerHost)H limit %(Batch)d"))
|
" and %(ServerHost)H limit %(Batch)d"))
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
case Res of
|
case Res of
|
||||||
{updated, Count} ->
|
{updated, Count} ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue