diff options
author | Максим Зражевский <[email protected]> | 2011-12-19 02:43:21 +0800 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-12-21 15:29:03 +0100 |
commit | c6e01fe15d02dc704e5a9e77b59d2ee2db235976 (patch) | |
tree | 0875a4d53cccd62cf89a09a32c8c61542d2fa169 /lib/odbc/src | |
parent | 58336ee5c613de56f6d69562cd59b651eef734f0 (diff) | |
download | otp-c6e01fe15d02dc704e5a9e77b59d2ee2db235976.tar.gz otp-c6e01fe15d02dc704e5a9e77b59d2ee2db235976.tar.bz2 otp-c6e01fe15d02dc704e5a9e77b59d2ee2db235976.zip |
Add support for NULL value in odbc:param_query
Support atom 'null' in odbc:param_query as database NULL value
Fix "ODBC: received unexpected info:{tcp_closed, ...}" when connection is terminating.
Fix possible access violation with 64bit ODBC.
Diffstat (limited to 'lib/odbc/src')
-rw-r--r-- | lib/odbc/src/odbc.erl | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/odbc/src/odbc.erl b/lib/odbc/src/odbc.erl index 36afd1abcf..e187679dc3 100644 --- a/lib/odbc/src/odbc.erl +++ b/lib/odbc/src/odbc.erl @@ -755,7 +755,10 @@ handle_info({'DOWN', _Ref, _Type, _Process, shutdown}, State) -> handle_info({'DOWN', _Ref, _Type, Process, Reason}, State) -> {stop, {stopped, {'EXIT', Process, Reason}}, State#state{reply_to = undefined}}; - + +handle_info({tcp_closed, Socket}, State = #state{odbc_socket=Socket, + state = disconnecting}) -> + {stop, normal, State}; %--------------------------------------------------------------------------- %% Catch all - throws away unknown messages (This could happen by "accident" %% so we do not want to crash, but we make a log entry as it is an @@ -942,9 +945,11 @@ fix_params({sql_bit, InOut, Values}) -> fix_params({'sql_timestamp', InOut, Values}) -> NewValues = case (catch - lists:map(fun({{Year,Month,Day},{Hour,Minute,Second}}) -> - {Year,Month,Day,Hour,Minute,Second} - end, Values)) of + lists:map( + fun({{Year,Month,Day},{Hour,Minute,Second}}) -> + {Year,Month,Day,Hour,Minute,Second}; + (null) -> null + end, Values)) of Result -> Result end, @@ -960,15 +965,15 @@ fix_inout(out) -> fix_inout(inout) -> ?INOUT. -string_terminate([Value| _ ] = Values) when is_list(Value)-> - case (catch - lists:map(fun(Str) -> Str ++ [?STR_TERMINATOR] end, Values)) of - Result -> - Result - end; -string_terminate([Value| _ ] = Values) when is_binary(Value)-> - case (catch - lists:map(fun(B) -> <<B/binary,0:16>> end, Values)) of +string_terminate(Values) -> + case (catch lists:map(fun string_terminate_value/1, Values)) of Result -> Result end. + +string_terminate_value(String) when is_list(String) -> + String ++ [?STR_TERMINATOR]; +string_terminate_value(Binary) when is_binary(Binary) -> + <<Binary/binary,0:16>>; +string_terminate_value(null) -> + null. |