44% %%
55% %% Created : 4 Aug 2005 by Magnus Ahltorp <ahltorp@nada.kth.se>
66% %%
7- % %% Copyright (c) 2001-2004 Kungliga Tekniska Högskolan
7+ % %% Copyright (c) 2001-2004 Kungliga Tekniska Högskolan
88% %% See the file COPYING
99% %%
1010% %% Modified: 9/12/2006 by Yariv Sadan <yarivvv@gmail.com>
1616% %% provide a simpler, Mnesia-style transaction interface. Also,
1717% %% moved much of the prepared statement handling code to mysql_conn.erl
1818% %% and added versioning to prepared statements.
19- % %%
19+ % %%
2020% %%
2121% %% Usage:
2222% %%
6464% %% ErrSqlState = mysql:get_result_err_sql_state(MysqlRes)
6565% %% with Reason and ErrSqlState = string()
6666% %% and ErrCode = integer()
67- % %%
67+ % %%
6868% %% If you just want a single MySQL connection, or want to manage your
6969% %% connections yourself, you can use the mysql_conn module as a
7070% %% stand-alone single MySQL connection. See the comment at the top of
9797 fetch /1 ,
9898 fetch /2 ,
9999 fetch /3 ,
100-
100+
101101 prepare /2 ,
102102 execute /1 ,
103103 execute /2 ,
141141
142142-record (conn , {
143143 pool_id , % % atom(), the pool's id
144- pid , % % pid(), mysql_conn process
144+ pid , % % pid(), mysql_conn process
145145 reconnect , % % true | false, should mysql_dispatcher try
146146 % % to reconnect if this connection dies?
147147 host , % % string()
155155-record (state , {
156156 % % gb_tree mapping connection
157157 % % pool id to a connection pool tuple
158- conn_pools = gb_trees :empty (),
159-
158+ conn_pools = gb_trees :empty (),
159+
160160
161161 % % gb_tree mapping connection Pid
162162 % % to pool id
163- pids_pools = gb_trees :empty (),
164-
163+ pids_pools = gb_trees :empty (),
164+
165165 % % function for logging,
166- log_fun ,
166+ log_fun ,
167167
168168
169169 % % maps names to {Statement::binary(), Version::integer()} values
186186 LogFun (? MODULE ,? LINE ,Level ,fun ()-> {Msg ,[]} end )).
187187-define (Log2 (LogFun ,Level ,Msg ,Params ),
188188 LogFun (? MODULE ,? LINE ,Level ,fun ()-> {Msg ,Params } end )).
189-
189+
190190
191191log (Module , Line , _Level , FormatFun ) ->
192192 {Format , Arguments } = FormatFun (),
@@ -306,7 +306,7 @@ new_conn(PoolId, ConnPid, Reconnect, Host, Port, User, Password, Database,
306306 database = Database ,
307307 encoding = Encoding
308308 };
309- false ->
309+ false ->
310310 # conn {pool_id = PoolId ,
311311 pid = ConnPid ,
312312 reconnect = false }
@@ -332,7 +332,7 @@ fetch(Query) ->
332332fetch (PoolId , Query ) ->
333333 fetch (PoolId , Query , undefined ).
334334
335- fetch (PoolId , Query , Timeout ) ->
335+ fetch (PoolId , Query , Timeout ) ->
336336 case get (? STATE_VAR ) of
337337 undefined ->
338338 call_server ({fetch , PoolId , Query }, Timeout );
@@ -470,7 +470,7 @@ get_result_field_info(#mysql_result{fieldinfo = FieldInfo}) ->
470470 FieldInfo .
471471
472472% % @doc Extract the Rows from MySQL Result on data received
473- % %
473+ % %
474474% % @spec get_result_rows(MySQLRes::mysql_result()) -> [Row::list()]
475475get_result_rows (# mysql_result {rows = AllRows }) ->
476476 AllRows .
@@ -644,7 +644,7 @@ handle_info({'DOWN', _MonitorRef, process, Pid, Info}, State) ->
644644 " received 'DOWN' signal from pid ~p not in my list" , [Pid ]),
645645 {noreply , State }
646646 end .
647-
647+
648648terminate (Reason , State ) ->
649649 LogFun = State # state .log_fun ,
650650 LogLevel = case Reason of
@@ -671,7 +671,7 @@ fetch_queries(PoolId, From, State, QueryList) ->
671671
672672with_next_conn (PoolId , State , Fun ) ->
673673 case get_next_conn (PoolId , State ) of
674- {ok , Conn , NewState } ->
674+ {ok , Conn , NewState } ->
675675 Fun (Conn , NewState );
676676 error ->
677677 % % we have no active connection matching PoolId
@@ -690,7 +690,7 @@ add_conn(Conn, State) ->
690690 erlang :monitor (process , Conn # conn .pid ),
691691 PoolId = Conn # conn .pool_id ,
692692 ConnPools = State # state .conn_pools ,
693- NewPool =
693+ NewPool =
694694 case gb_trees :lookup (PoolId , ConnPools ) of
695695 none ->
696696 {[Conn ],[]};
@@ -723,7 +723,7 @@ remove_pid_from_lists(Pid, Conns1, Conns2) ->
723723 {NewConns1 , Conn } ->
724724 {Conn , {NewConns1 , Conns2 }}
725725 end .
726-
726+
727727remove_conn (Pid , State ) ->
728728 PidsPools = State # state .pids_pools ,
729729 case gb_trees :lookup (Pid , PidsPools ) of
0 commit comments