From 9da17772026ff1fcbda98cad0c4fb808cb8c901d Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 10 Aug 2017 20:41:14 +0300 Subject: [PATCH 1/3] IGNITE-6032: Test added --- .../cpp/odbc-test/src/meta_queries_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp index ff3695db29748..2b77380e4e156 100644 --- a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp @@ -337,4 +337,17 @@ BOOST_AUTO_TEST_CASE(TestGetDataWithSelectQuery) CheckSingleRowResultSetWithGetData(stmt); } +BOOST_AUTO_TEST_CASE(TestGetInfoScrollOptions) +{ + Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache"); + + SQLUINTEGER val; + SQLRETURN ret = SQLGetInfo(dbc, SQL_SCROLL_OPTIONS, &val, 0, 0); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)); + + BOOST_CHECK_NE(val, 0); +} + BOOST_AUTO_TEST_SUITE_END() From 3f8dbf6ab4e1eafbb888531362d47788dfdf5a95 Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Thu, 10 Aug 2017 20:42:11 +0300 Subject: [PATCH 2/3] IGNITE-6032: Fix --- .../cpp/odbc/src/config/connection_info.cpp | 20 ++++++++++++++++++- .../cpp/odbc/src/meta/column_meta.cpp | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp index 4e7cc3cfbb7d8..d1d0ba11800b9 100644 --- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp +++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp @@ -118,6 +118,7 @@ namespace ignite DBG_STR_CASE(SQL_CONVERT_WLONGVARCHAR); DBG_STR_CASE(SQL_CONVERT_WVARCHAR); DBG_STR_CASE(SQL_CONVERT_GUID); + DBG_STR_CASE(SQL_SCROLL_OPTIONS); DBG_STR_CASE(SQL_PARAM_ARRAY_ROW_COUNTS); DBG_STR_CASE(SQL_PARAM_ARRAY_SELECTS); default: @@ -628,6 +629,20 @@ namespace ignite SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_LONGVARBINARY | SQL_CVT_GUID; #endif //SQL_CONVERT_GUID +#ifdef SQL_SCROLL_OPTIONS + // Bitmask enumerating the scroll options supported for scrollable cursors + // SQL_SO_FORWARD_ONLY = The cursor only scrolls forward. (ODBC 1.0) + // SQL_SO_STATIC = The data in the result set is static. (ODBC 2.0) + // SQL_SO_KEYSET_DRIVEN = The driver saves and uses the keys for every row in the result set. (ODBC 1.0) + // SQL_SO_DYNAMIC = The driver keeps the keys for every row in the rowset(the keyset size is the same + // as the rowset size). (ODBC 1.0) + // SQL_SO_MIXED = The driver keeps the keys for every row in the keyset, and the keyset size is greater + // than the rowset size.The cursor is keyset - driven inside the keyset and dynamic outside the + // keyset. (ODBC 1.0) + + intParams[SQL_SCROLL_OPTIONS] = SQL_SO_FORWARD_ONLY; +#endif //SQL_SCROLL_OPTIONS + //======================= Short Params ======================== #ifdef SQL_MAX_CONCURRENT_ACTIVITIES // The maximum number of active statements that the driver can @@ -666,13 +681,16 @@ namespace ignite SqlResult::Type ConnectionInfo::GetInfo(InfoType type, void* buf, short buflen, short* reslen) const { - if (!buf || !buflen) + if (!buf) return SqlResult::AI_ERROR; StringInfoMap::const_iterator itStr = strParams.find(type); if (itStr != strParams.end()) { + if (!buflen) + return SqlResult::AI_ERROR; + unsigned short strlen = static_cast( utility::CopyStringToBuffer(itStr->second, reinterpret_cast(buf), buflen)); diff --git a/modules/platforms/cpp/odbc/src/meta/column_meta.cpp b/modules/platforms/cpp/odbc/src/meta/column_meta.cpp index 97fdf807101c8..f1bd9a1b17057 100644 --- a/modules/platforms/cpp/odbc/src/meta/column_meta.cpp +++ b/modules/platforms/cpp/odbc/src/meta/column_meta.cpp @@ -60,6 +60,9 @@ namespace ignite DBG_STR_CASE(SQL_DESC_UNNAMED); DBG_STR_CASE(SQL_DESC_UNSIGNED); DBG_STR_CASE(SQL_DESC_UPDATABLE); + DBG_STR_CASE(SQL_COLUMN_LENGTH); + DBG_STR_CASE(SQL_COLUMN_PRECISION); + DBG_STR_CASE(SQL_COLUMN_SCALE); default: break; } From 977ff69c1d17c37888a78cf884e7d514b80de3d8 Mon Sep 17 00:00:00 2001 From: Igor Sapego Date: Tue, 15 Aug 2017 16:08:28 +0300 Subject: [PATCH 3/3] IGNITE-6032: Review fixes --- modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp | 2 +- modules/platforms/cpp/odbc/src/config/connection_info.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp index 2b77380e4e156..5d4e22fa5ae58 100644 --- a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp @@ -341,7 +341,7 @@ BOOST_AUTO_TEST_CASE(TestGetInfoScrollOptions) { Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=cache"); - SQLUINTEGER val; + SQLUINTEGER val = 0; SQLRETURN ret = SQLGetInfo(dbc, SQL_SCROLL_OPTIONS, &val, 0, 0); if (!SQL_SUCCEEDED(ret)) diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp index d1d0ba11800b9..49259570c19dc 100644 --- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp +++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp @@ -639,8 +639,7 @@ namespace ignite // SQL_SO_MIXED = The driver keeps the keys for every row in the keyset, and the keyset size is greater // than the rowset size.The cursor is keyset - driven inside the keyset and dynamic outside the // keyset. (ODBC 1.0) - - intParams[SQL_SCROLL_OPTIONS] = SQL_SO_FORWARD_ONLY; + intParams[SQL_SCROLL_OPTIONS] = SQL_SO_FORWARD_ONLY | SQL_SO_STATIC; #endif //SQL_SCROLL_OPTIONS //======================= Short Params ========================