aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanil Onishchenko <[email protected]>2013-01-11 13:31:31 +0800
committerDanil Onishchenko <[email protected]>2013-01-11 13:31:31 +0800
commit97bfdc2a8922cad77ae88a199729cc7541008d10 (patch)
treecbe565f7492e994d1379fcb681286344f36ef8fb
parent12c4a0b0c8963c03806613bb73487fdc14733db9 (diff)
downloadotp-97bfdc2a8922cad77ae88a199729cc7541008d10.tar.gz
otp-97bfdc2a8922cad77ae88a199729cc7541008d10.tar.bz2
otp-97bfdc2a8922cad77ae88a199729cc7541008d10.zip
Fix aotocommit for Oracle ODBC driver in Linux.
Issue: Oracle ODBC driver for Linux ignores setup autocommit mode during driver initialization before a connection to database has been established. Whereas odbc module in erlang sets autocommit mode before a connection has been established and autocommit mode is true by default it is impossible to turn out autocommit mode for oracle connections. Sulution: This patch sets autocommit mode after a connection to database has been established. The patch changes only C source file odbcserver.c and don't change any erlang source files of odbc module. The patches for older versions of erlang/otp are here https://github.com/RubberCthulhu/erlang-odbc-oracle-fix
-rw-r--r--lib/odbc/c_src/odbcserver.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index 4a7a5224e5..b4ee20c3ee 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -431,6 +431,20 @@ static db_result_msg handle_db_request(byte *reqstring, db_state *state)
<connStrIn>, returns a message indicating the outcome. */
static db_result_msg db_connect(byte *args, db_state *state)
{
+ /*
+ * Danil Onishchenko aka RubberCthulhu, [email protected]. 2013.01.09.
+ * It's a fix for Oracle ODBC driver for Linux.
+ * The issue: Oracle ODBC driver for Linux ignores setup autocommit mode
+ * during driver initialization before a connection to database has been
+ * established.
+ * Solution: set autocommit mode after a connection to database has been
+ * established.
+ *
+ * BEGIN
+ */
+ SQLLEN auto_commit_mode;
+ /* END */
+
SQLCHAR connStrOut[MAX_CONN_STR_OUT + 1] = {0};
SQLRETURN result;
SQLSMALLINT stringlength2ptr = 0, connlen;
@@ -498,6 +512,42 @@ static db_result_msg db_connect(byte *args, db_state *state)
return msg;
}
+ /*
+ * Danil Onishchenko aka RubberCthulhu, [email protected]. 2013.01.09.
+ * It's a fix for Oracle ODBC driver for Linux.
+ * The issue: Oracle ODBC driver for Linux ignores setup autocommit mode
+ * during driver initialization before a connection to database has been
+ * established.
+ * Solution: set autocommit mode after a connection to database has been
+ * established.
+ *
+ * BEGIN
+ */
+ if(erl_auto_commit_mode == ON) {
+ auto_commit_mode = SQL_AUTOCOMMIT_ON;
+ } else {
+ auto_commit_mode = SQL_AUTOCOMMIT_OFF;
+ }
+
+ if(!sql_success(SQLSetConnectAttr(connection_handle(state),
+ SQL_ATTR_AUTOCOMMIT,
+ (SQLPOINTER)auto_commit_mode, 0))) {
+ diagnos = get_diagnos(SQL_HANDLE_DBC, connection_handle(state), extended_errors(state));
+ strcat((char *)diagnos.error_msg, " Set autocommit mode failed.");
+
+ msg = encode_error_message(diagnos.error_msg, extended_error(state, diagnos.sqlState), diagnos.nativeError);
+
+ if(!sql_success(SQLFreeHandle(SQL_HANDLE_DBC,
+ connection_handle(state))))
+ DO_EXIT(EXIT_FREE);
+ if(!sql_success(SQLFreeHandle(SQL_HANDLE_ENV,
+ environment_handle(state))))
+ DO_EXIT(EXIT_FREE);
+
+ return msg;
+ }
+ /* END */
+
msg = retrive_scrollable_cursor_support_info(state);
return msg;