IGNITE-6032: ODBC: Added SQL_SCROLL_OPTIONS support for SQLGetInfo (cherry picked from commit f3d3d1bd718068c941e14b4e5949573b0a5d0c6a)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/020ff360 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/020ff360 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/020ff360 Branch: refs/heads/ignite-5947 Commit: 020ff3608d07fc584effe0826d72eb5edac0e1d6 Parents: 276e84a Author: Igor Sapego <[email protected]> Authored: Tue Aug 15 16:55:31 2017 +0300 Committer: Igor Sapego <[email protected]> Committed: Tue Aug 15 16:55:31 2017 +0300 ---------------------------------------------------------------------- .../cpp/odbc-test/src/meta_queries_test.cpp | 13 +++++++++++++ .../cpp/odbc/src/config/connection_info.cpp | 19 ++++++++++++++++++- .../platforms/cpp/odbc/src/meta/column_meta.cpp | 3 +++ 3 files changed, 34 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/020ff360/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp ---------------------------------------------------------------------- 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 ff3695d..5d4e22f 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 = 0; + 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() http://git-wip-us.apache.org/repos/asf/ignite/blob/020ff360/modules/platforms/cpp/odbc/src/config/connection_info.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp index 4e7cc3c..4925957 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,19 @@ 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 | SQL_SO_STATIC; +#endif //SQL_SCROLL_OPTIONS + //======================= Short Params ======================== #ifdef SQL_MAX_CONCURRENT_ACTIVITIES // The maximum number of active statements that the driver can @@ -666,13 +680,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<short>( utility::CopyStringToBuffer(itStr->second, reinterpret_cast<char*>(buf), buflen)); http://git-wip-us.apache.org/repos/asf/ignite/blob/020ff360/modules/platforms/cpp/odbc/src/meta/column_meta.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/meta/column_meta.cpp b/modules/platforms/cpp/odbc/src/meta/column_meta.cpp index 97fdf80..f1bd9a1 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; }
