IGNITE-2240: SQLEndTran implemented.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/37de9129 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/37de9129 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/37de9129 Branch: refs/heads/ignite-1786 Commit: 37de912937fafb35bae750a0e34131301c449ee7 Parents: 97c795b Author: isapego <[email protected]> Authored: Thu Jan 14 20:56:51 2016 +0300 Committer: isapego <[email protected]> Committed: Thu Jan 14 20:56:51 2016 +0300 ---------------------------------------------------------------------- .../include/ignite/odbc/connection.h | 26 ++++++++ .../include/ignite/odbc/environment.h | 26 ++++++++ .../cpp/odbc/odbc-driver/src/connection.cpp | 23 +++++++ .../cpp/odbc/odbc-driver/src/environment.cpp | 22 +++++++ .../platforms/cpp/odbc/odbc-driver/src/odbc.cpp | 65 +++++++++++++++++--- 5 files changed, 154 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/37de9129/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h index 068b804..f0f22cf 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h +++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/connection.h @@ -150,6 +150,16 @@ namespace ignite return true; } + /** + * Perform transaction commit. + */ + void TransactionCommit(); + + /** + * Perform transaction rollback. + */ + void TransactionRollback(); + private: IGNITE_NO_COPY_ASSIGNMENT(Connection); @@ -194,6 +204,22 @@ namespace ignite SqlResult InternalCreateStatement(Statement*& statement); /** + * Perform transaction commit on all the associated connections. + * Internal call. + * + * @return Operation result. + */ + SqlResult InternalTransactionCommit(); + + /** + * Perform transaction rollback on all the associated connections. + * Internal call. + * + * @return Operation result. + */ + SqlResult InternalTransactionRollback(); + + /** * Constructor. */ Connection(); http://git-wip-us.apache.org/repos/asf/ignite/blob/37de9129/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h index 5db2914..14d3613 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h +++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/environment.h @@ -49,6 +49,16 @@ namespace ignite */ Connection* CreateConnection(); + /** + * Perform transaction commit on all the associated connections. + */ + void TransactionCommit(); + + /** + * Perform transaction rollback on all the associated connections. + */ + void TransactionRollback(); + private: IGNITE_NO_COPY_ASSIGNMENT(Environment); @@ -60,6 +70,22 @@ namespace ignite * @return Operation result. */ SqlResult InternalCreateConnection(Connection*& connection); + + /** + * Perform transaction commit on all the associated connections. + * Internal call. + * + * @return Operation result. + */ + SqlResult InternalTransactionCommit(); + + /** + * Perform transaction rollback on all the associated connections. + * Internal call. + * + * @return Operation result. + */ + SqlResult InternalTransactionRollback(); }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/37de9129/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp index ad16238..47494eb 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp +++ b/modules/platforms/cpp/odbc/odbc-driver/src/connection.cpp @@ -221,6 +221,29 @@ namespace ignite { return diagnostic::DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum); } + + void Connection::TransactionCommit() + { + IGNITE_ODBC_API_CALL(InternalTransactionCommit()); + } + + SqlResult Connection::InternalTransactionCommit() + { + return SQL_RESULT_SUCCESS; + } + + void Connection::TransactionRollback() + { + IGNITE_ODBC_API_CALL(InternalTransactionRollback()); + } + + SqlResult Connection::InternalTransactionRollback() + { + AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, + "Rollback operation is not supported."); + + return SQL_RESULT_ERROR; + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/37de9129/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp index fa68e83..0063e87 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp +++ b/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp @@ -41,6 +41,28 @@ namespace ignite return connection; } + void Environment::TransactionCommit() + { + IGNITE_ODBC_API_CALL(InternalTransactionCommit()); + } + + SqlResult Environment::InternalTransactionCommit() + { + return SQL_RESULT_SUCCESS; + } + + void Environment::TransactionRollback() + { + IGNITE_ODBC_API_CALL(InternalTransactionRollback()); + } + + SqlResult Environment::InternalTransactionRollback() + { + AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, + "Rollback operation is not supported."); + + return SQL_RESULT_ERROR; + } SqlResult Environment::InternalCreateConnection(Connection*& connection) { http://git-wip-us.apache.org/repos/asf/ignite/blob/37de9129/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp index 824cb32..b819744 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp +++ b/modules/platforms/cpp/odbc/odbc-driver/src/odbc.cpp @@ -1210,6 +1210,63 @@ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, return statement->GetDiagnosticRecords().GetReturnCode(); } +SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType, + SQLHANDLE handle, + SQLSMALLINT completionType) +{ + using namespace ignite::odbc; + + LOG_MSG("SQLEndTran called\n"); + + SQLRETURN result; + + switch (handleType) + { + case SQL_HANDLE_ENV: + { + Environment *env = reinterpret_cast<Environment*>(handle); + + if (!env) + return SQL_INVALID_HANDLE; + + if (completionType == SQL_COMMIT) + env->TransactionCommit(); + else + env->TransactionRollback(); + + result = env->GetDiagnosticRecords().GetReturnCode(); + + break; + } + + case SQL_HANDLE_DBC: + { + Connection *conn = reinterpret_cast<Connection*>(handle); + + if (!conn) + return SQL_INVALID_HANDLE; + + if (completionType == SQL_COMMIT) + conn->TransactionCommit(); + else + conn->TransactionRollback(); + + result = conn->GetDiagnosticRecords().GetReturnCode(); + + break; + } + + default: + { + result = SQL_INVALID_HANDLE; + + break; + } + } + + return result; +} + // // ==== Not implemented ==== // @@ -1471,14 +1528,6 @@ SQLRETURN SQL_API SQLCopyDesc(SQLHDESC src, SQLHDESC dst) return SQL_SUCCESS; } -SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType, - SQLHANDLE handle, - SQLSMALLINT completionType) -{ - LOG_MSG("SQLEndTran called\n"); - return SQL_SUCCESS; -} - SQLRETURN SQL_API SQLGetDescField(SQLHDESC descr, SQLSMALLINT recNum, SQLSMALLINT fieldId,
