aboutsummaryrefslogtreecommitdiffstats
path: root/lib/odbc/c_src
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-01-24 16:08:03 +0100
committerFredrik Gustafsson <[email protected]>2013-01-24 16:08:03 +0100
commit96aae6d5dd034108b4a01e4403f6a765486651af (patch)
tree29908d32ea58491b28065f2aa7b661534dfd48c2 /lib/odbc/c_src
parent7ba536872c3cb1db2e7c8a29c1886b4601f853a4 (diff)
parent97bfdc2a8922cad77ae88a199729cc7541008d10 (diff)
downloadotp-96aae6d5dd034108b4a01e4403f6a765486651af.tar.gz
otp-96aae6d5dd034108b4a01e4403f6a765486651af.tar.bz2
otp-96aae6d5dd034108b4a01e4403f6a765486651af.zip
Merge branch 'kp/odbc-oracle-autocommit-fix/OTP-10735'
* kp/odbc-oracle-autocommit-fix/OTP-10735: Fix aotocommit for Oracle ODBC driver in Linux.
Diffstat (limited to 'lib/odbc/c_src')
-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;