diff options
| author | Hiroshi Inoue | 2007-05-02 21:44:13 +0000 |
|---|---|---|
| committer | Hiroshi Inoue | 2007-05-02 21:44:13 +0000 |
| commit | 273a604ff4894da3f5ddc409bb1b3c5e2847aa06 (patch) | |
| tree | a346c3a29b454797828619ae6d6137dbd942ce8b /options.c | |
| parent | 31de1f80cd6dc50f35bfafdc2434df7f46e95f28 (diff) | |
The version is now 8.2.0401.
[Windows]
Handle AUTOCOMMIT mode more carefully in a distributed transaction
so as not to issue COMMIT unexpectedly.
[UNIX}
Allow the UNIX domain configuration (the same as libpq).
Diffstat (limited to 'options.c')
| -rw-r--r-- | options.c | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -288,8 +288,10 @@ PGAPI_SetConnectOption( { CSTR func = "PGAPI_SetConnectOption"; ConnectionClass *conn = (ConnectionClass *) hdbc; + ConnInfo *ci = &(conn->connInfo); char changed = FALSE; RETCODE retval; + BOOL autocomm_on; mylog("%s: entering fOption = %d vParam = %d\n", func, fOption, vParam); if (!conn) @@ -351,29 +353,33 @@ PGAPI_SetConnectOption( break; case SQL_AUTOCOMMIT: - if (vParam == SQL_AUTOCOMMIT_ON && CC_is_in_autocommit(conn)) - break; - else if (vParam == SQL_AUTOCOMMIT_OFF && !CC_is_in_autocommit(conn)) - break; - if (CC_is_in_trans(conn)) - CC_commit(conn); - - mylog("PGAPI_SetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam); - switch (vParam) { - case SQL_AUTOCOMMIT_OFF: - CC_set_autocommit_off(conn); - break; - case SQL_AUTOCOMMIT_ON: - CC_set_autocommit_on(conn); + autocomm_on = TRUE; + break; + case SQL_AUTOCOMMIT_OFF: + autocomm_on = FALSE; break; - default: CC_set_error(conn, CONN_INVALID_ARGUMENT_NO, "Illegal parameter value for SQL_AUTOCOMMIT", func); return SQL_ERROR; } + if (autocomm_on && SQL_AUTOCOMMIT_OFF != ci->autocommit_public) + break; + else if (!autocomm_on && SQL_AUTOCOMMIT_OFF == ci->autocommit_public) + break; + ci->autocommit_public = (autocomm_on ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); + mylog("%s: AUTOCOMMIT: transact_status=%d, vparam=%d\n", func, conn->transact_status, vParam); + +#ifdef _HANDLE_ENLIST_IN_DTC_ + if (NULL != conn->asdum) + { + mylog("%s: Ignored AUTOCOMMIT in a distributed transaction, OK ?"); + break; + } +#endif /* _HANDLE_ENLIST_IN_DTC_ */ + CC_set_autocommit(conn, autocomm_on); break; case SQL_CURRENT_QUALIFIER: /* ignored */ @@ -522,8 +528,7 @@ PGAPI_GetConnectOption( break; case SQL_AUTOCOMMIT: - *((SQLUINTEGER *) pvParam) = (SQLUINTEGER) (CC_is_in_autocommit(conn) ? - SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF); + *((SQLUINTEGER *) pvParam) = ci->autocommit_public; break; case SQL_CURRENT_QUALIFIER: /* don't use qualifiers */ |
