Browse Source

update for OTP-22, fix compiler warnings

Yuriy Zhloba 4 years ago
parent
commit
36b1c2a479
4 changed files with 16 additions and 7 deletions
  1. 2 2
      src/epgsql_pool.app.src
  2. 4 4
      src/epgsql_pool.erl
  3. 1 1
      src/epgsql_pool_worker.erl
  4. 9 0
      src/epgsql_test.erl

+ 2 - 2
src/epgsql_pool.app.src

@@ -3,9 +3,9 @@
 {application, epgsql_pool,
 {application, epgsql_pool,
  [
  [
   {description, "Connection pool for PostgreSQL"},
   {description, "Connection pool for PostgreSQL"},
-  {vsn, "1.3.0"},
+  {vsn, "1.4.2"},
   {registered, []},
   {registered, []},
-  {applications, [epgsql, pooler]},
+  {applications, [stdlib, kernel, epgsql, pooler]},
   {env, [
   {env, [
          {connection_timeout, 10000},
          {connection_timeout, 10000},
          {query_timeout, 10000},
          {query_timeout, 10000},

+ 4 - 4
src/epgsql_pool.erl

@@ -145,9 +145,9 @@ transaction(PoolName0, Fun) ->
                   gen_server:call(Worker, {squery, "COMMIT"}, Timeout),
                   gen_server:call(Worker, {squery, "COMMIT"}, Timeout),
                   Result
                   Result
               catch
               catch
-                  Err:Reason ->
+                  Err:Reason:ST ->
                       gen_server:call(Worker, {squery, "ROLLBACK"}, Timeout),
                       gen_server:call(Worker, {squery, "ROLLBACK"}, Timeout),
-                      erlang:raise(Err, Reason, erlang:get_stacktrace())
+                      erlang:raise(Err, Reason, ST)
               end
               end
       end).
       end).
 
 
@@ -195,9 +195,9 @@ with_worker(PoolName, Fun) ->
                 try
                 try
                     Fun(Worker)
                     Fun(Worker)
                 catch
                 catch
-                    Err:Reason ->
+                    Err:Reason:ST ->
                         pooler:return_member(PoolName, Worker, fail),
                         pooler:return_member(PoolName, Worker, fail),
-                        erlang:raise(Err, Reason, erlang:get_stacktrace())
+                        erlang:raise(Err, Reason, ST)
                 end,
                 end,
             pooler:return_member(PoolName, Worker, ok),
             pooler:return_member(PoolName, Worker, ok),
             Response;
             Response;

+ 1 - 1
src/epgsql_pool_worker.erl

@@ -111,7 +111,7 @@ handle_info(open_connection, #state{pool_name = PoolName, connection = Connectio
             {noreply, State#state{connection = Connection4}}
             {noreply, State#state{connection = Connection4}}
     end;
     end;
 
 
-handle_info(on_connect, #state{pool_name = PoolName, connection = Connection} = State) ->
+handle_info(on_connect, #state{pool_name = PoolName} = State) ->
     case application:get_env(epgsql_pool, connect_listener) of
     case application:get_env(epgsql_pool, connect_listener) of
         undefined -> ignore;
         undefined -> ignore;
         {ok, undefined} -> ignore;
         {ok, undefined} -> ignore;

+ 9 - 0
src/epgsql_test.erl

@@ -4,12 +4,16 @@
 -export([test_run/0]).
 -export([test_run/0]).
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
 -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
 
 
+-include("otp_types.hrl").
 
 
+
+-spec test_run() -> gs_start_link_reply().
 test_run() ->
 test_run() ->
     application:ensure_all_started(epgsql_pool),
     application:ensure_all_started(epgsql_pool),
     gen_server:start_link({local, ?MODULE}, ?MODULE, no_args, []).
     gen_server:start_link({local, ?MODULE}, ?MODULE, no_args, []).
 
 
 
 
+-spec init(gs_args()) -> gs_init_reply().
 init(no_args) ->
 init(no_args) ->
     application:set_env(epgsql_pool, connect_listener, self()),
     application:set_env(epgsql_pool, connect_listener, self()),
     application:set_env(epgsql_pool, disconnect_listener, ?MODULE),
     application:set_env(epgsql_pool, disconnect_listener, ?MODULE),
@@ -17,14 +21,17 @@ init(no_args) ->
     {ok, no_state}.
     {ok, no_state}.
 
 
 
 
+-spec handle_call(gs_request(), gs_from(), gs_reply()) -> gs_call_reply().
 handle_call(_Request, _From, State) ->
 handle_call(_Request, _From, State) ->
     {reply, ok, State}.
     {reply, ok, State}.
 
 
 
 
+-spec handle_cast(gs_request(), gs_state()) -> gs_cast_reply().
 handle_cast(_Request, State) ->
 handle_cast(_Request, State) ->
     {noreply, State}.
     {noreply, State}.
 
 
 
 
+-spec handle_info(gs_request(), gs_state()) -> gs_info_reply().
 handle_info(start_pool, State) ->
 handle_info(start_pool, State) ->
     error_logger:info_msg("Start Pool"),
     error_logger:info_msg("Start Pool"),
     Params = #{
     Params = #{
@@ -69,10 +76,12 @@ handle_info(_Info, State) ->
     {noreply, State}.
     {noreply, State}.
 
 
 
 
+-spec terminate(terminate_reason(), gs_state()) -> ok.
 terminate(_Reason, _State) ->
 terminate(_Reason, _State) ->
     ok.
     ok.
 
 
 
 
+-spec code_change(term(), term(), term()) -> gs_code_change_reply().
 code_change(_OldVsn, State, _Extra) ->
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
     {ok, State}.