Skip to content

Commit 5fa11ec

Browse files
committed
Remove stray whitespace at the end of line / file
Same as: find src include test -type f -exec sed -i -e 's/\s*$//' {} \; -exec sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' {} \;
1 parent 051f22e commit 5fa11ec

File tree

4 files changed

+41
-44
lines changed

4 files changed

+41
-44
lines changed

src/mysql.app.src

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
mysql_recv]},
88
{registered, []},
99
{applications, [kernel, stdlib]}]}.
10-

src/mysql.erl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
%%% provide a simpler, Mnesia-style transaction interface. Also,
1818
%%% moved much of the prepared statement handling code to mysql_conn.erl
1919
%%% and added versioning to prepared statements.
20-
%%%
20+
%%%
2121
%%%
2222
%%% Usage:
2323
%%%
@@ -65,7 +65,7 @@
6565
%%% ErrSqlState = mysql:get_result_err_sql_state(MysqlRes)
6666
%%% with Reason and ErrSqlState = string()
6767
%%% and ErrCode = integer()
68-
%%%
68+
%%%
6969
%%% If you just want a single MySQL connection, or want to manage your
7070
%%% connections yourself, you can use the mysql_conn module as a
7171
%%% stand-alone single MySQL connection. See the comment at the top of
@@ -98,7 +98,7 @@
9898
fetch/1,
9999
fetch/2,
100100
fetch/3,
101-
101+
102102
prepare/2,
103103
execute/1,
104104
execute/2,
@@ -142,7 +142,7 @@
142142

143143
-record(conn, {
144144
pool_id, %% atom(), the pool's id
145-
pid, %% pid(), mysql_conn process
145+
pid, %% pid(), mysql_conn process
146146
reconnect, %% true | false, should mysql_dispatcher try
147147
%% to reconnect if this connection dies?
148148
host, %% string()
@@ -156,15 +156,15 @@
156156
-record(state, {
157157
%% gb_tree mapping connection
158158
%% pool id to a connection pool tuple
159-
conn_pools = gb_trees:empty(),
160-
159+
conn_pools = gb_trees:empty(),
160+
161161

162162
%% gb_tree mapping connection Pid
163163
%% to pool id
164-
pids_pools = gb_trees:empty(),
165-
164+
pids_pools = gb_trees:empty(),
165+
166166
%% function for logging,
167-
log_fun,
167+
log_fun,
168168

169169

170170
%% maps names to {Statement::binary(), Version::integer()} values
@@ -187,7 +187,7 @@
187187
LogFun(?MODULE,?LINE,Level,fun()-> {Msg,[]} end)).
188188
-define(Log2(LogFun,Level,Msg,Params),
189189
LogFun(?MODULE,?LINE,Level,fun()-> {Msg,Params} end)).
190-
190+
191191

192192
log(Module, Line, _Level, FormatFun) ->
193193
{Format, Arguments} = FormatFun(),
@@ -307,7 +307,7 @@ new_conn(PoolId, ConnPid, Reconnect, Host, Port, User, Password, Database,
307307
database = Database,
308308
encoding = Encoding
309309
};
310-
false ->
310+
false ->
311311
#conn{pool_id = PoolId,
312312
pid = ConnPid,
313313
reconnect = false}
@@ -333,7 +333,7 @@ fetch(Query) ->
333333
fetch(PoolId, Query) ->
334334
fetch(PoolId, Query, undefined).
335335

336-
fetch(PoolId, Query, Timeout) ->
336+
fetch(PoolId, Query, Timeout) ->
337337
case get(?STATE_VAR) of
338338
undefined ->
339339
call_server({fetch, PoolId, Query}, Timeout);
@@ -471,7 +471,7 @@ get_result_field_info(#mysql_result{fieldinfo = FieldInfo}) ->
471471
FieldInfo.
472472

473473
%% @doc Extract the Rows from MySQL Result on data received
474-
%%
474+
%%
475475
%% @spec get_result_rows(MySQLRes::mysql_result()) -> [Row::list()]
476476
get_result_rows(#mysql_result{rows=AllRows}) ->
477477
AllRows.
@@ -645,7 +645,7 @@ handle_info({'DOWN', _MonitorRef, process, Pid, Info}, State) ->
645645
"received 'DOWN' signal from pid ~p not in my list", [Pid]),
646646
{noreply, State}
647647
end.
648-
648+
649649
terminate(Reason, State) ->
650650
LogFun = State#state.log_fun,
651651
LogLevel = case Reason of
@@ -672,7 +672,7 @@ fetch_queries(PoolId, From, State, QueryList) ->
672672

673673
with_next_conn(PoolId, State, Fun) ->
674674
case get_next_conn(PoolId, State) of
675-
{ok, Conn, NewState} ->
675+
{ok, Conn, NewState} ->
676676
Fun(Conn, NewState);
677677
error ->
678678
%% we have no active connection matching PoolId
@@ -691,7 +691,7 @@ add_conn(Conn, State) ->
691691
erlang:monitor(process, Conn#conn.pid),
692692
PoolId = Conn#conn.pool_id,
693693
ConnPools = State#state.conn_pools,
694-
NewPool =
694+
NewPool =
695695
case gb_trees:lookup(PoolId, ConnPools) of
696696
none ->
697697
{[Conn],[]};
@@ -724,7 +724,7 @@ remove_pid_from_lists(Pid, Conns1, Conns2) ->
724724
{NewConns1, Conn} ->
725725
{Conn, {NewConns1, Conns2}}
726726
end.
727-
727+
728728
remove_conn(Pid, State) ->
729729
PidsPools = State#state.pids_pools,
730730
case gb_trees:lookup(Pid, PidsPools) of

src/mysql_conn.erl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ loop(State) ->
442442
%% GenSrvFrom is either a gen_server:call/3 From term(),
443443
%% or a pid if no gen_server was used to make the query
444444
send_reply(GenSrvFrom, Res) when is_pid(GenSrvFrom) ->
445-
%% The query was not sent using gen_server mechanisms
445+
%% The query was not sent using gen_server mechanisms
446446
GenSrvFrom ! {fetch_result, self(), Res};
447447
send_reply(GenSrvFrom, Res) ->
448448
gen_server:reply(GenSrvFrom, Res).
@@ -482,7 +482,7 @@ do_queries(State, Queries) ->
482482

483483
%% Execute a list of queries, returning the response for the last query.
484484
%% If a query returns an error before the last query is executed, the
485-
%% loop is aborted and the error is returned.
485+
%% loop is aborted and the error is returned.
486486
do_queries(Sock, RecvPid, LogFun, Queries, Version) ->
487487
catch
488488
lists:foldl(
@@ -495,7 +495,7 @@ do_queries(Sock, RecvPid, LogFun, Queries, Version) ->
495495

496496
do_transaction(State, Fun) ->
497497
case do_query(State, <<"BEGIN">>) of
498-
{error, _} = Err ->
498+
{error, _} = Err ->
499499
{aborted, Err};
500500
_ ->
501501
case catch Fun() of
@@ -566,7 +566,7 @@ make_statements_for_execute(Name, Params) ->
566566
ParamNums = lists:seq(1, NumParams),
567567

568568
NameBin = atom_to_binary(Name),
569-
569+
570570
ParamNames =
571571
lists:foldl(
572572
fun(Num, Acc) ->
@@ -699,12 +699,12 @@ get_query_response(LogFun, RecvPid, Version) ->
699699
{updated, #mysql_result{affectedrows=AffectedRows, insertid=InsertId}};
700700
255 ->
701701
case get_error_data(Rest, Version) of
702-
{Code, {SqlState, Message}} ->
702+
{Code, {SqlState, Message}} ->
703703
% MYSQL_4_1 error data
704-
{error, #mysql_result{error=Message,
704+
{error, #mysql_result{error=Message,
705705
errcode=Code,
706706
errsqlstate=SqlState}};
707-
{Code, Message} ->
707+
{Code, Message} ->
708708
% MYSQL_4_0 error data
709709
{error, #mysql_result{error=Message,
710710
errcode=Code}}
@@ -717,12 +717,12 @@ get_query_response(LogFun, RecvPid, Version) ->
717717
{ok, Rows} ->
718718
{data, #mysql_result{fieldinfo=Fields,
719719
rows=Rows}};
720-
{error, {Code, {SqlState, Message}}} ->
720+
{error, {Code, {SqlState, Message}}} ->
721721
% MYSQL_4_1 error data
722-
{error, #mysql_result{error=Message,
722+
{error, #mysql_result{error=Message,
723723
errcode=Code,
724724
errsqlstate=SqlState}};
725-
{error, {Code, Message}} ->
725+
{error, {Code, Message}} ->
726726
% MYSQL_4_0 error data
727727
{error, #mysql_result{error=Message,
728728
errcode=Code}}
@@ -767,7 +767,7 @@ get_fields(LogFun, RecvPid, Res, ?MYSQL_4_0) ->
767767
Field,
768768
Length,
769769
%% TODO: Check on MySQL 4.0 if types are specified
770-
%% using the same 4.1 formalism and could
770+
%% using the same 4.1 formalism and could
771771
%% be expanded to atoms:
772772
Type},
773773
get_fields(LogFun, RecvPid, [This | Res], ?MYSQL_4_0)
@@ -798,7 +798,7 @@ get_fields(LogFun, RecvPid, Res, ?MYSQL_4_1) ->
798798
Length:32/little, Type:8/little,
799799
_Flags:16/little, _Decimals:8/little,
800800
_Rest7/binary>> = Rest6,
801-
801+
802802
This = {Table,
803803
Field,
804804
Length,
@@ -827,7 +827,7 @@ get_rows(Fields, LogFun, RecvPid, Res, Version) ->
827827
<<254:8, Rest/binary>> when size(Rest) < 8 ->
828828
{ok, lists:reverse(Res)};
829829
<<255:8, Rest/binary>> ->
830-
{Code, ErrData} = get_error_data(Rest, Version),
830+
{Code, ErrData} = get_error_data(Rest, Version),
831831
{error, {Code, ErrData}};
832832
_ ->
833833
{ok, This} = get_row(Fields, Packet, []),
@@ -852,7 +852,7 @@ get_row([Field | OtherFields], Data, Res) ->
852852

853853
get_with_length(Bin) when is_binary(Bin) ->
854854
{Length, Rest} = get_lcb(Bin),
855-
case get_lcb(Bin) of
855+
case get_lcb(Bin) of
856856
{null, Rest} -> {null, Rest};
857857
_ -> split_binary(Rest, Length)
858858
end.
@@ -900,7 +900,7 @@ normalize_version([$4,$.,$1|_T], _LogFun) ->
900900
?MYSQL_4_1;
901901
normalize_version([$5|_T], _LogFun) ->
902902
%% MySQL version 5.x protocol is compliant with MySQL 4.1.x:
903-
?MYSQL_4_1;
903+
?MYSQL_4_1;
904904
normalize_version(_Other, LogFun) ->
905905
?Log(LogFun, error, "MySQL version not supported: MySQL Erlang module "
906906
"might not work correctly."),
@@ -982,7 +982,7 @@ convert_type(Val, ColType) ->
982982
_Other ->
983983
Val
984984
end.
985-
985+
986986
get_error_data(ErrPacket, ?MYSQL_4_0) ->
987987
<<Code:16/little, Message/binary>> = ErrPacket,
988988
{Code, binary_to_list(Message)};

test/mysql_test.erl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
test() ->
99
compile:file("/usr/local/lib/erlang/lib/mysql/mysql.erl"),
1010
compile:file("/usr/local/lib/erlang/lib/mysql/mysql_conn.erl"),
11-
11+
1212
%% Start the MySQL dispatcher and create the first connection
1313
%% to the database. 'p1' is the connection pool identifier.
1414
mysql:start_link(p1, "localhost", "root", "password", "test"),
@@ -18,7 +18,7 @@ test() ->
1818
true),
1919
mysql:connect(p1, "localhost", undefined, "root", "password", "test",
2020
true),
21-
21+
2222
mysql:fetch(p1, <<"DELETE FROM developer">>),
2323

2424
mysql:fetch(p1, <<"INSERT INTO developer(name, country) VALUES "
@@ -28,17 +28,17 @@ test() ->
2828
%% Execute a query (using a binary)
2929
Result1 = mysql:fetch(p1, <<"SELECT * FROM developer">>),
3030
io:format("Result1: ~p~n", [Result1]),
31-
31+
3232
%% Register a prepared statement
3333
mysql:prepare(update_developer_country,
3434
<<"UPDATE developer SET country=? where name like ?">>),
35-
35+
3636
%% Execute the prepared statement
3737
mysql:execute(p1, update_developer_country, [<<"Sweden">>, <<"%Wiger">>]),
38-
38+
3939
Result2 = mysql:fetch(p1, <<"SELECT * FROM developer">>),
4040
io:format("Result2: ~p~n", [Result2]),
41-
41+
4242
mysql:transaction(
4343
p1,
4444
fun() -> mysql:fetch(<<"INSERT INTO developer(name, country) VALUES "
@@ -49,7 +49,7 @@ test() ->
4949

5050
Result3 = mysql:fetch(p1, <<"SELECT * FROM developer">>),
5151
io:format("Result3: ~p~n", [Result3]),
52-
52+
5353
mysql:prepare(delete_all, <<"DELETE FROM developer">>),
5454

5555
{aborted, {{error, foo}, _}} =
@@ -70,7 +70,5 @@ test() ->
7070
Result5 = mysql:fetch(p1, <<"SELECT * FROM numbers WHERE name='t1'">>),
7171
{data, {mysql_result, _, [[<<"t1">>, D]], _, _, _, _, _}} = Result5,
7272
mysql:fetch(p1, <<"DELETE FROM numbers">>),
73-
73+
7474
ok.
75-
76-

0 commit comments

Comments
 (0)