1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 09:49:18 +02:00

Make delete_old_mam_messages_batch work with sqlite

This commit is contained in:
Paweł Chmielowski 2025-04-17 14:21:25 +02:00
parent ef754939c4
commit 45e7d8426d

View file

@ -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} ->