aboutsummaryrefslogtreecommitdiff
path: root/odb/mssql/error.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-20 14:57:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-20 14:57:35 +0200
commita8a2cd61bb9f3657c65acf3a1d9dfaaa68271f4e (patch)
tree47ce1c808a9695050b27f077763efa627049a93a /odb/mssql/error.cxx
parent16283f61ddd0525b08e615fac6148f544973ac82 (diff)
Implement support for transactions
Diffstat (limited to 'odb/mssql/error.cxx')
-rw-r--r--odb/mssql/error.cxx30
1 files changed, 24 insertions, 6 deletions
diff --git a/odb/mssql/error.cxx b/odb/mssql/error.cxx
index b659bd6..dffe4cf 100644
--- a/odb/mssql/error.cxx
+++ b/odb/mssql/error.cxx
@@ -20,7 +20,8 @@ namespace odb
translate_error (SQLRETURN r,
SQLHANDLE h,
SQLSMALLINT htype,
- connection* conn)
+ connection* conn,
+ bool end_tran)
{
// First see if we have one of the errors indicated via the
// return error code.
@@ -120,6 +121,18 @@ namespace odb
break;
}
+ // If a call to SQLEndTran() fails, then the connection is
+ // put into the so called "suspended state" and should be
+ // disconnected unless we know the transaction was rolled
+ // back. See SQLEndTran() documentation for details.
+ //
+ if (end_tran &&
+ s != "25S03" && // Transaction is rolled back.
+ s != "40001" && // Serialization failure.
+ s != "40002" && // Integrity constraint.
+ s != "HYC00") // Optional feature not implemented.
+ conn->mark_failed ();
+
if (c != code_none && c != nc)
{
// Several different codes.
@@ -173,7 +186,12 @@ namespace odb
string s (sqlstate);
if (s == "08S01" || // Link failure.
- s == "HYT01") // Connection timeout.
+ s == "HYT01" || // Connection timeout.
+ (end_tran &&
+ s != "25S03" &&
+ s != "40001" &&
+ s != "40002" &&
+ s != "HYC00"))
conn->mark_failed ();
}
@@ -191,9 +209,9 @@ namespace odb
}
void
- translate_error (SQLRETURN r, connection& c)
+ translate_error (SQLRETURN r, connection& c, bool end_tran)
{
- translate_error (r, c.handle (), SQL_HANDLE_DBC, &c);
+ translate_error (r, c.handle (), SQL_HANDLE_DBC, &c, end_tran);
}
void
@@ -201,13 +219,13 @@ namespace odb
connection& c,
const auto_handle<SQL_HANDLE_STMT>& h)
{
- translate_error (r, h, SQL_HANDLE_STMT, &c);
+ translate_error (r, h, SQL_HANDLE_STMT, &c, false);
}
void
translate_error (SQLRETURN r, SQLHANDLE h, SQLSMALLINT htype)
{
- translate_error (r, h, htype, 0);
+ translate_error (r, h, htype, 0, false);
}
}
}