~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to lib/odbc/src/odbc.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%%<copyright>
2
 
%% <year>1999-2008</year>
3
 
%% <holder>Ericsson AB, All Rights Reserved</holder>
4
 
%%</copyright>
5
 
%%<legalnotice>
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
 
5
%% 
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%%
 
11
%% 
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
 
16
%% 
 
17
%% %CopyrightEnd%
16
18
%%
17
 
%% The Initial Developer of the Original Code is Ericsson AB.
18
 
%%</legalnotice>
 
19
 
19
20
%
20
21
 
21
22
-module(odbc).
361
362
 
362
363
param_query(ConnectionReference, SQLQuery, Params, infinity) 
363
364
  when pid(ConnectionReference), list(SQLQuery), list(Params) ->
364
 
    [{_, Values} | _] = Params,
 
365
    Values = param_values(Params),
365
366
    NoRows = length(Values),
366
367
    NewParams = lists:map(fun fix_params/1, Params),
367
368
    ODBCCmd = [?PARAM_QUERY, term_to_binary({SQLQuery ++ [?STR_TERMINATOR],
371
372
param_query(ConnectionReference, SQLQuery, Params, TimeOut)
372
373
  when pid(ConnectionReference), list(SQLQuery), list(Params),
373
374
       integer(TimeOut), TimeOut > 0 ->
374
 
    [{_, Values} | _] = Params,
 
375
    Values = param_values(Params),
375
376
    NoRows = length(Values),
376
377
    NewParams = lists:map(fun fix_params/1, Params),
377
378
    ODBCCmd = [?PARAM_QUERY, term_to_binary({SQLQuery ++ [?STR_TERMINATOR],
430
431
    
431
432
    erlang:monitor(process, ClientPid),
432
433
    
433
 
    Inet = case inet:getaddr("localhost", inet6) of
434
 
               {ok, {_,_,_,_}} ->
435
 
                   inet;
436
 
               {ok, {0, 0, 0, 0, 0, 16#ffff, _, _}} ->
437
 
                   inet;
438
 
               {ok, {_,_,_,_,_,_,_,_}} ->
 
434
    Inet = case gen_tcp:listen(0, [inet6]) of
 
435
               {ok, Dummyport} ->
 
436
                   gen_tcp:close(Dummyport),
439
437
                   inet6;
440
438
               _ ->
441
439
                   inet
884
882
    end.
885
883
 
886
884
%%-------------------------------------------------------------------------
 
885
param_values(Params) ->
 
886
    case Params of    
 
887
        [{_, Values} | _] -> 
 
888
            Values;
 
889
        [{_, _, Values} | _] -> 
 
890
            Values
 
891
    end.
 
892
 
 
893
%%-------------------------------------------------------------------------
887
894
fix_params({sql_integer, InOut, Values}) ->
888
895
    {?USER_INT, fix_inout(InOut), [256 | Values]};
889
896
fix_params({sql_smallint, InOut, Values}) ->