IGNITE-2243: Implemented setting of SQL_ATTR_ODBC_VERSION.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c847f8ee Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c847f8ee Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c847f8ee Branch: refs/heads/ignite-1786 Commit: c847f8eed7b5b31c13cc4d6cdb980e5ad3bec1e4 Parents: a172649 Author: isapego <[email protected]> Authored: Wed Jan 20 21:08:41 2016 +0300 Committer: isapego <[email protected]> Committed: Wed Jan 20 21:08:41 2016 +0300 ---------------------------------------------------------------------- .../include/ignite/odbc/common_types.h | 6 ++++ .../include/ignite/odbc/environment.h | 3 ++ .../cpp/odbc/odbc-driver/src/environment.cpp | 30 +++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c847f8ee/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h index 2e64857..e79a572 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h +++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/common_types.h @@ -63,6 +63,12 @@ namespace ignite /** Error in row. */ SQL_STATE_01S01_ERROR_IN_ROW, + /** + * The driver did not support the specified value and + * substituted a similar value. + */ + SQL_STATE_01S02_OPTION_VALUE_CHANGED, + /** Invalid cursor state. */ SQL_STATE_24000_INVALID_CURSOR_STATE, http://git-wip-us.apache.org/repos/asf/ignite/blob/c847f8ee/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 c88a7bf..a9c4889 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 @@ -124,6 +124,9 @@ namespace ignite * @return Operation result. */ SqlResult InternalGetAttribute(int32_t attr, app::ApplicationDataBuffer& buffer); + + /** ODBC version. */ + int32_t odbcVersion; }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/c847f8ee/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 186fdc1..1629e91 100644 --- a/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp +++ b/modules/platforms/cpp/odbc/odbc-driver/src/environment.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include "ignite/odbc/system/odbc_constants.h" #include "ignite/odbc/connection.h" #include "ignite/odbc/environment.h" @@ -22,7 +23,8 @@ namespace ignite { namespace odbc { - Environment::Environment() + Environment::Environment() : + odbcVersion(SQL_OV_ODBC3) { // No-op. } @@ -85,6 +87,32 @@ namespace ignite SqlResult Environment::InternalSetAttribute(int32_t attr, void* value, int32_t len) { + EnvironmentAttribute attribute = EnvironmentAttributeToInternal(attr); + + switch (attribute) + { + case IGNITE_SQL_ENV_ATTR_ODBC_VERSION: + { + int32_t* version = reinterpret_cast<int32_t*>(value); + + if (*version != odbcVersion) + { + AddStatusRecord(SQL_STATE_01S02_OPTION_VALUE_CHANGED, + "ODBC version is not supported."); + + *version = odbcVersion; + + return SQL_RESULT_SUCCESS_WITH_INFO; + } + + break; + } + + case IGNITE_SQL_ENV_ATTR_UNKNOWN: + default: + break; + } + AddStatusRecord(SQL_STATE_HYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED, "Attribute is not supported.");
