Skip to content

Commit

Permalink
Fix query that creates inbox delete domain statement
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jan 9, 2023
1 parent 759b64a commit 95dc3b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/inbox/mod_inbox_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ init(HostType, Opts) ->
UniqueKeyFields, <<"timestamp">>),
ok.

prepare_remove_domain(Opts) ->
{MaybeLimitSQL, MaybeLimitMSSQL} = mod_mam_utils:batch_delete_limits(Opts),
prepare_remove_domain(#{delete_domain_limit := infinity}) ->
mongoose_rdbms:prepare(
inbox_delete_domain, inbox, [lserver],
<<"DELETE ", MaybeLimitMSSQL/binary, "FROM inbox WHERE lserver = ? ", MaybeLimitSQL/binary>>).
inbox_delete_domain, inbox, [lserver], <<"DELETE FROM inbox WHERE lserver = ?">>);
prepare_remove_domain(#{delete_domain_limit := Limit}) ->
{MaybeLimitSQL, MaybeLimitMSSQL} = rdbms_queries:get_db_specific_limits_binaries(Limit),
ServerTable = <<"(SELECT ", MaybeLimitMSSQL/binary,
" lserver FROM inbox WHERE lserver = ? ", MaybeLimitSQL/binary, ")">>,
mongoose_rdbms:prepare(
inbox_incr_delete_domain, inbox, [lserver],
<<"DELETE ", MaybeLimitMSSQL/binary, "FROM inbox WHERE lserver IN ", ServerTable/binary>>).

-spec get_inbox(HostType :: mongooseim:host_type(),
LUser :: jid:luser(),
Expand Down Expand Up @@ -481,7 +486,7 @@ execute_delete(HostType, LUser, LServer) ->
execute_delete_domain(HostType, LServer, infinity) ->
mongoose_rdbms:execute_successfully(HostType, inbox_delete_domain, [LServer]);
execute_delete_domain(HostType, LServer, Limit) ->
mod_mam_utils:incremental_delete_domain(HostType, LServer, Limit, [inbox_delete_domain], 0).
mod_mam_utils:incremental_delete_domain(HostType, LServer, Limit, [inbox_incr_delete_domain], 0).

%% DB result processing
-type db_return() :: {RemBareJID :: jid:luser(),
Expand Down

0 comments on commit 95dc3b2

Please sign in to comment.