diff options
Diffstat (limited to 'lib/odbc')
-rw-r--r-- | lib/odbc/doc/src/notes.xml | 26 | ||||
-rw-r--r-- | lib/odbc/doc/src/odbc.xml | 12 | ||||
-rw-r--r-- | lib/odbc/src/odbc.erl | 9 | ||||
-rw-r--r-- | lib/odbc/test/odbc_connect_SUITE.erl | 30 | ||||
-rw-r--r-- | lib/odbc/vsn.mk | 2 |
5 files changed, 75 insertions, 4 deletions
diff --git a/lib/odbc/doc/src/notes.xml b/lib/odbc/doc/src/notes.xml index add8229955..59d46de02a 100644 --- a/lib/odbc/doc/src/notes.xml +++ b/lib/odbc/doc/src/notes.xml @@ -32,7 +32,31 @@ <p>This document describes the changes made to the odbc application. </p> - <section><title>ODBC 2.11</title> + <section><title>ODBC 2.11.1</title> + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + New application variable to set timeout of internal + communication setup between the erlang code and the + c-port program that interfaces the odbc driver. This can + be useful if you have an underlying system that is slow + due to heavy load at startup.</p> + <p> + With this environment variable you can easily bypass and + tailor odbc to the needs of the underlying actual system + without changing the configuration. Which is a good thing + because this value is very system specific.</p> + <p> + Own Id: OTP-12935</p> + </item> + </list> + </section> + +</section> + +<section><title>ODBC 2.11</title> <section><title>Improvements and New Features</title> <list> diff --git a/lib/odbc/doc/src/odbc.xml b/lib/odbc/doc/src/odbc.xml index 01bc0cb7ff..6a2a3587e4 100644 --- a/lib/odbc/doc/src/odbc.xml +++ b/lib/odbc/doc/src/odbc.xml @@ -221,6 +221,18 @@ and their meanings are dependent on the database being used.</item> <item><c>Reason</c> is as per the <c>Reason</c> field when extended errors are not enabled.</item> </list> + + <note> + <p>The current implementation spawns a port programm + written in C that utilizes the actual ODBC driver. There + is a default timeout of 5000 msec for this port programm + to connect to the Erlang ODBC application. This timeout + can be changed by setting an application specific + environment variable 'port_timeout' with the number of + milliseconds for the ODBC application. E.g.: [{odbc, + [{port_timeout, 60000}]}] to set it to 60 seconds. + </p> + </note> </desc> </func> <func> diff --git a/lib/odbc/src/odbc.erl b/lib/odbc/src/odbc.erl index 4901821e9c..12560bfb6e 100644 --- a/lib/odbc/src/odbc.erl +++ b/lib/odbc/src/odbc.erl @@ -26,6 +26,8 @@ -include("odbc_internal.hrl"). +-define(ODBC_PORT_TIMEOUT, 5000). + %% API -------------------------------------------------------------------- -export([start/0, start/1, stop/0, @@ -523,10 +525,10 @@ handle_msg({connect, ODBCCmd, AutoCommitMode, SrollableCursors}, NewState = State#state{auto_commit_mode = AutoCommitMode, scrollable_cursors = SrollableCursors}, - case gen_tcp:accept(ListenSocketSup, 5000) of + case gen_tcp:accept(ListenSocketSup, port_timeout()) of {ok, SupSocket} -> gen_tcp:close(ListenSocketSup), - case gen_tcp:accept(ListenSocketOdbc, 5000) of + case gen_tcp:accept(ListenSocketOdbc, port_timeout()) of {ok, OdbcSocket} -> gen_tcp:close(ListenSocketOdbc), odbc_send(OdbcSocket, ODBCCmd), @@ -983,3 +985,6 @@ string_terminate_value(Binary) when is_binary(Binary) -> <<Binary/binary,0:16>>; string_terminate_value(null) -> null. + +port_timeout() -> + application:get_env(?MODULE, port_timeout, ?ODBC_PORT_TIMEOUT). diff --git a/lib/odbc/test/odbc_connect_SUITE.erl b/lib/odbc/test/odbc_connect_SUITE.erl index 93e949faf6..2d4173a008 100644 --- a/lib/odbc/test/odbc_connect_SUITE.erl +++ b/lib/odbc/test/odbc_connect_SUITE.erl @@ -120,7 +120,16 @@ end_per_suite(_Config) -> %% Note: This function is free to add any key/value pairs to the Config %% variable, but should NOT alter/remove any existing entries. %%-------------------------------------------------------------------- +init_per_testcase(connect_port_timeout, Config) -> + odbc:stop(), + application:load(odbc), + application:set_env(odbc, port_timeout, 0), + odbc:start(), + init_per_testcase_common(Config); init_per_testcase(_TestCase, Config) -> + init_per_testcase_common(Config). + +init_per_testcase_common(Config) -> test_server:format("ODBCINI = ~p~n", [os:getenv("ODBCINI")]), Dog = test_server:timetrap(?default_timeout), Temp = lists:keydelete(connection_ref, 1, Config), @@ -135,7 +144,16 @@ init_per_testcase(_TestCase, Config) -> %% A list of key/value pairs, holding the test case configuration. %% Description: Cleanup after each test case %%-------------------------------------------------------------------- + +end_per_testcase(connect_port_timeout, Config) -> + application:unset_env(odbc, port_timeout), + odbc:stop(), + odbc:start(), + end_per_testcase_common(Config); end_per_testcase(_TestCase, Config) -> + end_per_testcase_common(Config). + +end_per_testcase_common(Config) -> Table = ?config(tableName, Config), {ok, Ref} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()), Result = odbc:sql_query(Ref, "DROP TABLE " ++ Table), @@ -423,6 +441,18 @@ connect_timeout(Config) when is_list(Config) -> %% Need to return ok here "{'EXIT',timeout} return value" will %% be interpreted as that the testcase has timed out. ok. + +%%------------------------------------------------------------------------- +connect_port_timeout(doc) -> + ["Test the timeout for the port program to connect back to the odbc " + "application within the connect function."]; +connect_port_timeout(suite) -> []; +connect_port_timeout(Config) when is_list(Config) -> + %% Application environment var 'port_timeout' has been set to 0 by + %% init_per_testcase/2. + {error,timeout} = odbc:connect(?RDBMS:connection_string(), + odbc_test_lib:platform_options()). + %%------------------------------------------------------------------------- timeout(doc) -> ["Test that timeouts don't cause unwanted behavior sush as receiving" diff --git a/lib/odbc/vsn.mk b/lib/odbc/vsn.mk index d4dc6bbe1d..c7c84560d1 100644 --- a/lib/odbc/vsn.mk +++ b/lib/odbc/vsn.mk @@ -1 +1 @@ -ODBC_VSN = 2.11 +ODBC_VSN = 2.11.1 |