]> granicus.if.org Git - ejabberd/commitdiff
Make return type of sql_transaction() consistent
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Thu, 4 Jul 2019 06:27:51 +0000 (09:27 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Thu, 4 Jul 2019 06:27:51 +0000 (09:27 +0300)
src/ejabberd_sql.erl

index 3620f94208d6d3c4c99abfe9552ad77e623cc7ea..029c22602912950dd2ff6b15a5fddd3f31895b67 100644 (file)
@@ -118,7 +118,7 @@ start_link(Host, StartInterval) ->
 -type sql_query() :: sql_query_simple() |
                     [{atom() | {atom(), any()}, sql_query_simple()}].
 -type sql_query_result() :: {updated, non_neg_integer()} |
-                            {error, binary()} |
+                            {error, binary() | atom()} |
                             {selected, [binary()], [[binary()]]} |
                             {selected, [any()]} |
                            ok.
@@ -143,7 +143,11 @@ sql_transaction(Host, Queries)
     sql_transaction(Host, F);
 %% SQL transaction, based on a erlang anonymous function (F = fun)
 sql_transaction(Host, F) when is_function(F) ->
-    sql_call(Host, {sql_transaction, F}).
+    case sql_call(Host, {sql_transaction, F}) of
+       {atomic, _} = Ret -> Ret;
+       {aborted, _} = Ret -> Ret;
+       Err -> {aborted, Err}
+    end.
 
 %% SQL bloc, based on a erlang anonymous function (F = fun)
 sql_bloc(Host, F) -> sql_call(Host, {sql_bloc, F}).