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:
parent
ef754939c4
commit
45e7d8426d
1 changed files with 31 additions and 15 deletions
|
@ -213,21 +213,37 @@ count_messages_to_delete(ServerHost, TimeStamp, Type) ->
|
||||||
delete_old_messages_batch(ServerHost, TimeStamp, Type, Batch) ->
|
delete_old_messages_batch(ServerHost, TimeStamp, Type, Batch) ->
|
||||||
TS = misc:now_to_usec(TimeStamp),
|
TS = misc:now_to_usec(TimeStamp),
|
||||||
Res =
|
Res =
|
||||||
case Type of
|
case Type of
|
||||||
all ->
|
all ->
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
ServerHost,
|
ServerHost,
|
||||||
?SQL("delete from archive"
|
fun(sqlite, _) ->
|
||||||
" where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d"));
|
ejabberd_sql:sql_query_t(
|
||||||
_ ->
|
?SQL("delete from archive where rowid in "
|
||||||
SType = misc:atom_to_binary(Type),
|
"(select rowid from archive where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d)"));
|
||||||
ejabberd_sql:sql_query(
|
(_, _) ->
|
||||||
ServerHost,
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("delete from archive"
|
?SQL("delete from archive"
|
||||||
" where timestamp < %(TS)d"
|
" where timestamp < %(TS)d and %(ServerHost)H limit %(Batch)d"))
|
||||||
" and kind=%(SType)s"
|
end);
|
||||||
" and %(ServerHost)H limit %(Batch)d"))
|
_ ->
|
||||||
end,
|
SType = misc:atom_to_binary(Type),
|
||||||
|
ejabberd_sql:sql_query(
|
||||||
|
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"
|
||||||
|
" where timestamp < %(TS)d"
|
||||||
|
" and kind=%(SType)s"
|
||||||
|
" and %(ServerHost)H limit %(Batch)d"))
|
||||||
|
end)
|
||||||
|
end,
|
||||||
case Res of
|
case Res of
|
||||||
{updated, Count} ->
|
{updated, Count} ->
|
||||||
{ok, Count};
|
{ok, Count};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue