mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Do not run set_last request inside a transaction
This commit is contained in:
parent
bd3889b6ec
commit
ab80513755
@ -121,6 +121,23 @@ update_t(Table, Fields, Vals, Where) ->
|
|||||||
") values ('", join(Vals, "', '"), "');"])
|
") values ('", join(Vals, "', '"), "');"])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
update(LServer, Table, Fields, Vals, Where) ->
|
||||||
|
UPairs = lists:zipwith(fun(A, B) -> A ++ "='" ++ B ++ "'" end,
|
||||||
|
Fields, Vals),
|
||||||
|
case ejabberd_odbc:sql_query(
|
||||||
|
LServer,
|
||||||
|
["update ", Table, " set ",
|
||||||
|
join(UPairs, ", "),
|
||||||
|
" where ", Where, ";"]) of
|
||||||
|
{updated, 1} ->
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
ejabberd_odbc:sql_query(
|
||||||
|
LServer,
|
||||||
|
["insert into ", Table, "(", join(Fields, ", "),
|
||||||
|
") values ('", join(Vals, "', '"), "');"])
|
||||||
|
end.
|
||||||
|
|
||||||
%% F can be either a fun or a list of queries
|
%% F can be either a fun or a list of queries
|
||||||
%% TODO: We should probably move the list of queries transaction
|
%% TODO: We should probably move the list of queries transaction
|
||||||
%% wrapper from the ejabberd_odbc module to this one (odbc_queries)
|
%% wrapper from the ejabberd_odbc module to this one (odbc_queries)
|
||||||
@ -134,14 +151,9 @@ get_last(LServer, Username) ->
|
|||||||
"where username='", Username, "'"]).
|
"where username='", Username, "'"]).
|
||||||
|
|
||||||
set_last_t(LServer, Username, Seconds, State) ->
|
set_last_t(LServer, Username, Seconds, State) ->
|
||||||
%% MREMOND: I think this should be turn into a non transactional behaviour
|
update(LServer, "last", ["username", "seconds", "state"],
|
||||||
ejabberd_odbc:sql_transaction(
|
|
||||||
LServer,
|
|
||||||
fun() ->
|
|
||||||
update_t("last", ["username", "seconds", "state"],
|
|
||||||
[Username, Seconds, State],
|
[Username, Seconds, State],
|
||||||
["username='", Username, "'"])
|
["username='", Username, "'"]).
|
||||||
end).
|
|
||||||
|
|
||||||
del_last(LServer, Username) ->
|
del_last(LServer, Username) ->
|
||||||
ejabberd_odbc:sql_query(
|
ejabberd_odbc:sql_query(
|
||||||
|
Loading…
Reference in New Issue
Block a user