mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Fix BEGIN/COMMIT/ROLLBACK syntax for MSSQL (#2978)
This commit is contained in:
parent
a8c6eec28c
commit
21aa344ed5
@ -523,15 +523,15 @@ outer_transaction(F, NRestarts, _Reason) ->
|
|||||||
[T]),
|
[T]),
|
||||||
erlang:exit(implementation_faulty)
|
erlang:exit(implementation_faulty)
|
||||||
end,
|
end,
|
||||||
sql_query_internal([<<"begin;">>]),
|
sql_begin(),
|
||||||
put(?NESTING_KEY, PreviousNestingLevel + 1),
|
put(?NESTING_KEY, PreviousNestingLevel + 1),
|
||||||
try F() of
|
try F() of
|
||||||
Res ->
|
Res ->
|
||||||
sql_query_internal([<<"commit;">>]),
|
sql_commit(),
|
||||||
{atomic, Res}
|
{atomic, Res}
|
||||||
catch
|
catch
|
||||||
?EX_RULE(throw, {aborted, Reason}, _) when NRestarts > 0 ->
|
?EX_RULE(throw, {aborted, Reason}, _) when NRestarts > 0 ->
|
||||||
sql_query_internal([<<"rollback;">>]),
|
sql_rollback(),
|
||||||
put(?NESTING_KEY, ?TOP_LEVEL_TXN),
|
put(?NESTING_KEY, ?TOP_LEVEL_TXN),
|
||||||
outer_transaction(F, NRestarts - 1, Reason);
|
outer_transaction(F, NRestarts - 1, Reason);
|
||||||
?EX_RULE(throw, {aborted, Reason}, Stack) when NRestarts =:= 0 ->
|
?EX_RULE(throw, {aborted, Reason}, Stack) when NRestarts =:= 0 ->
|
||||||
@ -542,10 +542,10 @@ outer_transaction(F, NRestarts, _Reason) ->
|
|||||||
"== ~p",
|
"== ~p",
|
||||||
[?MAX_TRANSACTION_RESTARTS, Reason,
|
[?MAX_TRANSACTION_RESTARTS, Reason,
|
||||||
StackTrace, get(?STATE_KEY)]),
|
StackTrace, get(?STATE_KEY)]),
|
||||||
sql_query_internal([<<"rollback;">>]),
|
sql_rollback(),
|
||||||
{aborted, Reason};
|
{aborted, Reason};
|
||||||
?EX_RULE(exit, Reason, _) ->
|
?EX_RULE(exit, Reason, _) ->
|
||||||
sql_query_internal([<<"rollback;">>]),
|
sql_rollback(),
|
||||||
{aborted, Reason}
|
{aborted, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -772,6 +772,22 @@ sql_query_format_res(Res, _SQLQuery) ->
|
|||||||
sql_query_to_iolist(SQLQuery) ->
|
sql_query_to_iolist(SQLQuery) ->
|
||||||
generic_sql_query_format(SQLQuery).
|
generic_sql_query_format(SQLQuery).
|
||||||
|
|
||||||
|
sql_begin() ->
|
||||||
|
sql_query_internal(
|
||||||
|
[{mssql, [<<"begin transaction;">>]},
|
||||||
|
{any, [<<"begin;">>]}]).
|
||||||
|
|
||||||
|
sql_commit() ->
|
||||||
|
sql_query_internal(
|
||||||
|
[{mssql, [<<"commit transaction;">>]},
|
||||||
|
{any, [<<"commit;">>]}]).
|
||||||
|
|
||||||
|
sql_rollback() ->
|
||||||
|
sql_query_internal(
|
||||||
|
[{mssql, [<<"rollback transaction;">>]},
|
||||||
|
{any, [<<"rollback;">>]}]).
|
||||||
|
|
||||||
|
|
||||||
%% Generate the OTP callback return tuple depending on the driver result.
|
%% Generate the OTP callback return tuple depending on the driver result.
|
||||||
abort_on_driver_error({error, <<"query timed out">>} = Reply, From, Timestamp) ->
|
abort_on_driver_error({error, <<"query timed out">>} = Reply, From, Timestamp) ->
|
||||||
reply(From, Reply, Timestamp),
|
reply(From, Reply, Timestamp),
|
||||||
|
Loading…
Reference in New Issue
Block a user