IGNITE-2793 Added support for byte arrays to ODBC This closes #1371
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/32d2629e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/32d2629e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/32d2629e Branch: refs/heads/ignite-3477 Commit: 32d2629e1a8f828b0a34e363e793a5add2639f2e Parents: 300750f Author: Sergey Kalashnikov <skalashni...@gridgain.com> Authored: Tue Dec 27 13:08:34 2016 +0300 Committer: Pavel Tupitsyn <ptupit...@apache.org> Committed: Tue Dec 27 13:08:34 2016 +0300 ---------------------------------------------------------------------- modules/platforms/cpp/binary/Makefile.am | 2 +- .../ignite/impl/binary/binary_type_manager.h | 2 +- .../src/impl/binary/binary_type_manager.cpp | 6 +- .../binary/src/impl/interop/interop_memory.cpp | 2 +- modules/platforms/cpp/common/Makefile.am | 2 +- .../include/ignite/common/dynamic_size_array.h | 2 +- modules/platforms/cpp/core-test/Makefile.am | 2 +- .../cpp/core-test/src/cache_query_test.cpp | 8 +- .../cpp/core-test/src/reference_test.cpp | 14 +- modules/platforms/cpp/core/Makefile.am | 2 +- .../cache/query/continuous/continuous_query.h | 8 +- .../include/ignite/cache/query/query_cursor.h | 4 +- .../query/continuous/continuous_query_impl.h | 8 +- .../core/include/ignite/impl/handle_registry.h | 2 +- .../cpp/core/include/ignite/impl/operations.h | 4 +- .../cpp/core/src/impl/cache/cache_impl.cpp | 5 +- .../cpp/core/src/impl/handle_registry.cpp | 2 +- .../cpp/examples/odbc-example/Makefile.am | 2 +- .../cpp/examples/putget-example/Makefile.am | 2 +- .../cpp/examples/query-example/Makefile.am | 2 +- modules/platforms/cpp/ignite/Makefile.am | 2 +- modules/platforms/cpp/jni/Makefile.am | 2 +- modules/platforms/cpp/jni/src/java.cpp | 2 +- modules/platforms/cpp/odbc-test/Makefile.am | 2 +- .../cpp/odbc-test/config/queries-default.xml | 1 + .../odbc-test/include/sql_test_suite_fixture.h | 3 + .../platforms/cpp/odbc-test/include/test_type.h | 20 +- .../platforms/cpp/odbc-test/src/column_test.cpp | 189 +++++++++++++++++++ .../odbc-test/src/sql_test_suite_fixture.cpp | 17 ++ .../cpp/odbc-test/src/sql_types_test.cpp | 131 +++++++++++++ modules/platforms/cpp/odbc/Makefile.am | 2 +- .../cpp/odbc/include/ignite/odbc/utility.h | 9 +- modules/platforms/cpp/odbc/src/column.cpp | 28 ++- .../cpp/odbc/src/config/connection_info.cpp | 6 +- modules/platforms/cpp/odbc/src/connection.cpp | 2 + modules/platforms/cpp/odbc/src/odbc.cpp | 5 +- modules/platforms/cpp/odbc/src/utility.cpp | 15 ++ 37 files changed, 469 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/binary/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/Makefile.am b/modules/platforms/cpp/binary/Makefile.am index ca301a6..5ffc4fd 100644 --- a/modules/platforms/cpp/binary/Makefile.am +++ b/modules/platforms/cpp/binary/Makefile.am @@ -32,7 +32,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 libignite_binary_la_LIBADD = \ @top_srcdir@/common/libignite-common.la http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h index 8aca1a0..63853f8 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_manager.h @@ -88,7 +88,7 @@ namespace ignite private: /** Current snapshots. */ - ignite::common::concurrent::SharedPointer<std::map<int32_t, SPSnap>> snapshots; + ignite::common::concurrent::SharedPointer<std::map<int32_t, SPSnap> > snapshots; /** Pending snapshots. */ std::vector<SPSnap>* pending; http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp index 9bd115c..8b5dfc1 100644 --- a/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp +++ b/modules/platforms/cpp/binary/src/impl/binary/binary_type_manager.cpp @@ -28,7 +28,7 @@ namespace ignite namespace binary { BinaryTypeManager::BinaryTypeManager() : - snapshots(SharedPointer<std::map<int32_t, SPSnap>>(new std::map<int32_t, SPSnap>)), + snapshots(SharedPointer<std::map<int32_t, SPSnap> >(new std::map<int32_t, SPSnap>)), pending(new std::vector<SPSnap>()), cs(new CriticalSection()), pendingVer(0), ver(0) @@ -46,7 +46,7 @@ namespace ignite SharedPointer<BinaryTypeHandler> BinaryTypeManager::GetHandler(int32_t typeId) { - SharedPointer<std::map<int32_t, SPSnap>> snapshots0 = snapshots; + SharedPointer<std::map<int32_t, SPSnap> > snapshots0 = snapshots; SPSnap snapshot = (*snapshots0.Get())[typeId]; @@ -156,7 +156,7 @@ namespace ignite if (!snapshotFound) (*newSnapshots)[pendingSnap->GetTypeId()] = *it; - snapshots = SharedPointer<std::map<int32_t, SPSnap>>(newSnapshots); + snapshots = SharedPointer<std::map<int32_t, SPSnap> >(newSnapshots); } else { http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/binary/src/impl/interop/interop_memory.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/src/impl/interop/interop_memory.cpp b/modules/platforms/cpp/binary/src/impl/interop/interop_memory.cpp index 926b7fb..04b27ae 100644 --- a/modules/platforms/cpp/binary/src/impl/interop/interop_memory.cpp +++ b/modules/platforms/cpp/binary/src/impl/interop/interop_memory.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include <cstdlib> #include <ignite/ignite_error.h> #include "ignite/impl/interop/interop_memory.h" http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/common/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/Makefile.am b/modules/platforms/cpp/common/Makefile.am index 2d16c2d..9c27a57 100644 --- a/modules/platforms/cpp/common/Makefile.am +++ b/modules/platforms/cpp/common/Makefile.am @@ -32,7 +32,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 libignite_common_la_LDFLAGS = \ -no-undefined \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/common/include/ignite/common/dynamic_size_array.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/common/include/ignite/common/dynamic_size_array.h b/modules/platforms/cpp/common/include/ignite/common/dynamic_size_array.h index a6bcc13..d233e44 100644 --- a/modules/platforms/cpp/common/include/ignite/common/dynamic_size_array.h +++ b/modules/platforms/cpp/common/include/ignite/common/dynamic_size_array.h @@ -36,7 +36,7 @@ namespace ignite * This is the analogue of the standard vector. It is needed to be used * in exported classes as we can't export standard library classes. */ - template<typename T, typename A = DefaultAllocator<T>> + template<typename T, typename A = DefaultAllocator<T> > class IGNITE_IMPORT_EXPORT DynamicSizeArray { public: http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core-test/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am index 3cf1d0e..a5a60ed 100644 --- a/modules/platforms/cpp/core-test/Makefile.am +++ b/modules/platforms/cpp/core-test/Makefile.am @@ -39,7 +39,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_tests_LDADD = \ @top_srcdir@/core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core-test/src/cache_query_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp index 928d29e..b5bb170 100644 --- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp +++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp @@ -362,7 +362,7 @@ void CheckGetAllFail(QueryCursor<int, QueryPerson>& cur) { try { - std::vector<CacheEntry<int, QueryPerson>> res; + std::vector<CacheEntry<int, QueryPerson> > res; cur.GetAll(res); @@ -406,7 +406,7 @@ void CheckEmpty(QueryFieldsCursor& cur) */ void CheckEmptyGetAll(QueryCursor<int, QueryPerson>& cur) { - std::vector<CacheEntry<int, QueryPerson>> res; + std::vector<CacheEntry<int, QueryPerson> > res; cur.GetAll(res); @@ -478,7 +478,7 @@ void CheckSingle(QueryFieldsCursor& cur, int key, const std::string& name, int a */ void CheckSingleGetAll(QueryCursor<int, QueryPerson>& cur, int key, const std::string& name, int age) { - std::vector<CacheEntry<int, QueryPerson>> res; + std::vector<CacheEntry<int, QueryPerson> > res; cur.GetAll(res); @@ -555,7 +555,7 @@ void CheckMultiple(QueryCursor<int, QueryPerson>& cur, int key1, const std::stri void CheckMultipleGetAll(QueryCursor<int, QueryPerson>& cur, int key1, const std::string& name1, int age1, int key2, const std::string& name2, int age2) { - std::vector<CacheEntry<int, QueryPerson>> res; + std::vector<CacheEntry<int, QueryPerson> > res; cur.GetAll(res); http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core-test/src/reference_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core-test/src/reference_test.cpp b/modules/platforms/cpp/core-test/src/reference_test.cpp index f5c3e8d..b240e2e 100644 --- a/modules/platforms/cpp/core-test/src/reference_test.cpp +++ b/modules/platforms/cpp/core-test/src/reference_test.cpp @@ -148,8 +148,10 @@ void TestFunctionConst3(ConstReference<C3> c3, int expected) BOOST_AUTO_TEST_SUITE(ReferenceTestSuite) + BOOST_AUTO_TEST_CASE(StdSharedPointerTestBefore) { +#if !defined(BOOST_NO_CXX11_SMART_PTR) bool objAlive = false; std::shared_ptr<LivenessMarker> shared = std::make_shared<LivenessMarker>(objAlive); @@ -167,10 +169,12 @@ BOOST_AUTO_TEST_CASE(StdSharedPointerTestBefore) } BOOST_CHECK(!objAlive); +#endif } BOOST_AUTO_TEST_CASE(StdSharedPointerTestAfter) { +#if !defined(BOOST_NO_CXX11_SMART_PTR) bool objAlive = false; std::shared_ptr<LivenessMarker> shared = std::make_shared<LivenessMarker>(objAlive); @@ -188,6 +192,7 @@ BOOST_AUTO_TEST_CASE(StdSharedPointerTestAfter) shared.reset(); BOOST_CHECK(!objAlive); +#endif } BOOST_AUTO_TEST_CASE(StdAutoPointerTest) @@ -209,6 +214,7 @@ BOOST_AUTO_TEST_CASE(StdAutoPointerTest) BOOST_AUTO_TEST_CASE(StdUniquePointerTest) { +#if !defined(BOOST_NO_CXX11_SMART_PTR) bool objAlive = false; std::unique_ptr<LivenessMarker> unique(new LivenessMarker(objAlive)); @@ -222,13 +228,14 @@ BOOST_AUTO_TEST_CASE(StdUniquePointerTest) } BOOST_CHECK(!objAlive); +#endif } BOOST_AUTO_TEST_CASE(BoostSharedPointerTestBefore) { bool objAlive = false; - boost::shared_ptr<LivenessMarker> shared = boost::make_shared<LivenessMarker>(objAlive); + boost::shared_ptr<LivenessMarker> shared = boost::make_shared<LivenessMarker>(boost::ref(objAlive)); BOOST_CHECK(objAlive); @@ -249,7 +256,7 @@ BOOST_AUTO_TEST_CASE(BoostSharedPointerTestAfter) { bool objAlive = false; - boost::shared_ptr<LivenessMarker> shared = boost::make_shared<LivenessMarker>(objAlive); + boost::shared_ptr<LivenessMarker> shared = boost::make_shared<LivenessMarker>(boost::ref(objAlive)); BOOST_CHECK(objAlive); @@ -266,8 +273,10 @@ BOOST_AUTO_TEST_CASE(BoostSharedPointerTestAfter) BOOST_CHECK(!objAlive); } + BOOST_AUTO_TEST_CASE(PassingToFunction) { +#if !defined(BOOST_NO_CXX11_SMART_PTR) bool objAlive = false; std::shared_ptr<LivenessMarker> stdShared = std::make_shared<LivenessMarker>(objAlive); @@ -281,6 +290,7 @@ BOOST_AUTO_TEST_CASE(PassingToFunction) TestFunction(MakeReferenceFromSmartPointer(stdAuto)); TestFunction(MakeReferenceFromSmartPointer(boostShared)); +#endif } BOOST_AUTO_TEST_CASE(CopyTest) http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/Makefile.am b/modules/platforms/cpp/core/Makefile.am index 758e68d..56e0c0a 100644 --- a/modules/platforms/cpp/core/Makefile.am +++ b/modules/platforms/cpp/core/Makefile.am @@ -37,7 +37,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 libignite_la_LIBADD = \ @top_srcdir@/jni/libignite-jni.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/include/ignite/cache/query/continuous/continuous_query.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/continuous/continuous_query.h b/modules/platforms/cpp/core/include/ignite/cache/query/continuous/continuous_query.h index 4bd9c46..781ce2e 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/query/continuous/continuous_query.h +++ b/modules/platforms/cpp/core/include/ignite/cache/query/continuous/continuous_query.h @@ -82,7 +82,7 @@ namespace ignite * @param lsnr Event listener. Invoked on the node where * continuous query execution has been started. */ - ContinuousQuery(Reference<event::CacheEntryEventListener<K, V>> lsnr) : + ContinuousQuery(Reference<event::CacheEntryEventListener<K, V> > lsnr) : impl(new impl::cache::query::continuous::ContinuousQueryImpl<K, V>(lsnr)) { // No-op. @@ -95,7 +95,7 @@ namespace ignite * continuous query execution has been started. * @param loc Whether query should be executed locally. */ - ContinuousQuery(Reference<event::CacheEntryEventListener<K, V>> lsnr, bool loc) : + ContinuousQuery(Reference<event::CacheEntryEventListener<K, V> > lsnr, bool loc) : impl(new impl::cache::query::continuous::ContinuousQueryImpl<K, V>(lsnr, loc)) { // No-op. @@ -202,7 +202,7 @@ namespace ignite * node where continuous query execution has been * started. */ - void SetListener(Reference<event::CacheEntryEventListener<K, V>> lsnr) + void SetListener(Reference<event::CacheEntryEventListener<K, V> > lsnr) { impl.Get()->SetListener(lsnr); } @@ -229,7 +229,7 @@ namespace ignite private: /** Implementation. */ - common::concurrent::SharedPointer<impl::cache::query::continuous::ContinuousQueryImpl<K, V>> impl; + common::concurrent::SharedPointer<impl::cache::query::continuous::ContinuousQueryImpl<K, V> > impl; }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/include/ignite/cache/query/query_cursor.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_cursor.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_cursor.h index 61c6813..9057a03 100644 --- a/modules/platforms/cpp/core/include/ignite/cache/query/query_cursor.h +++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_cursor.h @@ -190,7 +190,7 @@ namespace ignite * * @throw IgniteError class instance in case of failure. */ - void GetAll(std::vector<CacheEntry<K, V>>& res) + void GetAll(std::vector<CacheEntry<K, V> >& res) { IgniteError err; @@ -208,7 +208,7 @@ namespace ignite * @param Vector where query entries will be stored. * @param err Used to set operation result. */ - void GetAll(std::vector<CacheEntry<K, V>>& res, IgniteError& err) + void GetAll(std::vector<CacheEntry<K, V> >& res, IgniteError& err) { impl::cache::query::QueryCursorImpl* impl0 = impl.Get(); http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/include/ignite/impl/cache/query/continuous/continuous_query_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/continuous/continuous_query_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/continuous/continuous_query_impl.h index 50ced12..2a24e5f 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/cache/query/continuous/continuous_query_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/continuous/continuous_query_impl.h @@ -255,7 +255,7 @@ namespace ignite * @param lsnr Event listener. Invoked on the node where * continuous query execution has been started. */ - ContinuousQueryImpl(Reference<ignite::cache::event::CacheEntryEventListener<K, V>>& lsnr) : + ContinuousQueryImpl(Reference<ignite::cache::event::CacheEntryEventListener<K, V> >& lsnr) : ContinuousQueryImplBase(false), lsnr(lsnr) { @@ -269,7 +269,7 @@ namespace ignite * continuous query execution has been started. * @param loc Whether query should be executed locally. */ - ContinuousQueryImpl(Reference<ignite::cache::event::CacheEntryEventListener<K, V>>& lsnr, bool loc) : + ContinuousQueryImpl(Reference<ignite::cache::event::CacheEntryEventListener<K, V> >& lsnr, bool loc) : ContinuousQueryImplBase(loc), lsnr(lsnr) { @@ -283,7 +283,7 @@ namespace ignite * node where continuous query execution has been * started. */ - void SetListener(Reference<ignite::cache::event::CacheEntryEventListener<K, V>>& val) + void SetListener(Reference<ignite::cache::event::CacheEntryEventListener<K, V> >& val) { lsnr = val; } @@ -340,7 +340,7 @@ namespace ignite private: /** Cache entry event listener. */ - Reference<ignite::cache::event::CacheEntryEventListener<K, V>> lsnr; + Reference<ignite::cache::event::CacheEntryEventListener<K, V> > lsnr; }; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h b/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h index 3c4d123..ecaf3ee 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h +++ b/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h @@ -72,7 +72,7 @@ namespace ignite void Clear(); private: /** Map with data. */ - std::map<int64_t, common::concurrent::SharedPointer<void>> map; + std::map<int64_t, common::concurrent::SharedPointer<void> > map; /** Mutex. */ common::concurrent::CriticalSection mux; http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/include/ignite/impl/operations.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/operations.h b/modules/platforms/cpp/core/include/ignite/impl/operations.h index a8fef93..177529d 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/operations.h +++ b/modules/platforms/cpp/core/include/ignite/impl/operations.h @@ -531,7 +531,7 @@ namespace ignite /** * Constructor. */ - OutQueryGetAllOperation(std::vector<ignite::cache::CacheEntry<K, V>>* res) : res(res) + OutQueryGetAllOperation(std::vector<ignite::cache::CacheEntry<K, V> >* res) : res(res) { // No-op. } @@ -556,7 +556,7 @@ namespace ignite private: /** Entries. */ - std::vector<ignite::cache::CacheEntry<K, V>>* res; + std::vector<ignite::cache::CacheEntry<K, V> >* res; IGNITE_NO_COPY_ASSIGNMENT(OutQueryGetAllOperation) }; http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp index ad69d45..5d09e46 100644 --- a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp +++ b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp @@ -325,11 +325,12 @@ namespace ignite return QueryContinuous(qry, initialQry, OP_QRY_SCAN, OP_QRY_CONTINUOUS, err); } + struct DummyQry { void Write(BinaryRawWriter&) const { }}; + ContinuousQueryHandleImpl* CacheImpl::QueryContinuous(const SharedPointer<ContinuousQueryImplBase> qry, IgniteError& err) { - struct { void Write(BinaryRawWriter&) const { }} dummy; - + DummyQry dummy; return QueryContinuous(qry, dummy, -1, OP_QRY_CONTINUOUS, err); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/core/src/impl/handle_registry.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/impl/handle_registry.cpp b/modules/platforms/cpp/core/src/impl/handle_registry.cpp index 069e996..a279762 100644 --- a/modules/platforms/cpp/core/src/impl/handle_registry.cpp +++ b/modules/platforms/cpp/core/src/impl/handle_registry.cpp @@ -37,7 +37,7 @@ namespace ignite SharedPointer<void> HandleRegistrySegment::Get(int64_t hnd) { - typedef std::map<int64_t, SharedPointer<void>> Map; + typedef std::map<int64_t, SharedPointer<void> > Map; CsLockGuard guard(mux); http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/examples/odbc-example/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/examples/odbc-example/Makefile.am b/modules/platforms/cpp/examples/odbc-example/Makefile.am index 83cc63e..f3c9a50 100644 --- a/modules/platforms/cpp/examples/odbc-example/Makefile.am +++ b/modules/platforms/cpp/examples/odbc-example/Makefile.am @@ -36,7 +36,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_odbcexample_LDADD = \ @top_srcdir@/../core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/examples/putget-example/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/examples/putget-example/Makefile.am b/modules/platforms/cpp/examples/putget-example/Makefile.am index cf39002..88edc81 100644 --- a/modules/platforms/cpp/examples/putget-example/Makefile.am +++ b/modules/platforms/cpp/examples/putget-example/Makefile.am @@ -36,7 +36,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_putgetexample_LDADD = \ @top_srcdir@/../core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/examples/query-example/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/examples/query-example/Makefile.am b/modules/platforms/cpp/examples/query-example/Makefile.am index 01231ec..1d00bcf 100644 --- a/modules/platforms/cpp/examples/query-example/Makefile.am +++ b/modules/platforms/cpp/examples/query-example/Makefile.am @@ -36,7 +36,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_queryexample_LDADD = \ @top_srcdir@/../core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/ignite/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/ignite/Makefile.am b/modules/platforms/cpp/ignite/Makefile.am index 2dbc4d6..9b65f05 100644 --- a/modules/platforms/cpp/ignite/Makefile.am +++ b/modules/platforms/cpp/ignite/Makefile.am @@ -36,7 +36,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_LDADD = \ @top_srcdir@/core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/jni/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/jni/Makefile.am b/modules/platforms/cpp/jni/Makefile.am index 2cb4b90..56eaa6c 100644 --- a/modules/platforms/cpp/jni/Makefile.am +++ b/modules/platforms/cpp/jni/Makefile.am @@ -35,7 +35,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 libignite_jni_la_LIBADD = \ -L$(JAVA_HOME)/jre/lib/amd64/server \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/jni/src/java.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/jni/src/java.cpp b/modules/platforms/cpp/jni/src/java.cpp index e6f2f88..2c8c76a 100644 --- a/modules/platforms/cpp/jni/src/java.cpp +++ b/modules/platforms/cpp/jni/src/java.cpp @@ -1552,7 +1552,7 @@ namespace ignite if (consoleWriteHandlers.size() > 0) { ConsoleWriteHandler consoleWrite = consoleWriteHandlers.at(0); - const char* strChars = env->GetStringUTFChars(str, nullptr); + const char* strChars = env->GetStringUTFChars(str, 0); const int strCharsLen = env->GetStringUTFLength(str); consoleWrite(strChars, strCharsLen, isErr); http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am index e10ef7a..c2f3fa2 100644 --- a/modules/platforms/cpp/odbc-test/Makefile.am +++ b/modules/platforms/cpp/odbc-test/Makefile.am @@ -40,7 +40,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 ignite_odbc_tests_LDADD = \ @top_srcdir@/core/libignite.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/config/queries-default.xml ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/config/queries-default.xml b/modules/platforms/cpp/odbc-test/config/queries-default.xml index 6614e93..6dbc4f7 100644 --- a/modules/platforms/cpp/odbc-test/config/queries-default.xml +++ b/modules/platforms/cpp/odbc-test/config/queries-default.xml @@ -59,6 +59,7 @@ <entry key="guidField" value="java.util.UUID"/> <entry key="dateField" value="java.util.Date"/> <entry key="timestampField" value="java.sql.Timestamp"/> + <entry key="i8ArrayField" value="[B"/> </map> </property> http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h index 6d26818..55353e5 100644 --- a/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h +++ b/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h @@ -192,6 +192,9 @@ namespace ignite template<> void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request); + + template<> + void SqlTestSuiteFixture::CheckSingleResult<std::vector<int8_t> >(const char* request, const std::vector<int8_t>& expected); } #endif //_IGNITE_ODBC_TEST_SQL_TEST_SUIT_FIXTURE http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/include/test_type.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/include/test_type.h b/modules/platforms/cpp/odbc-test/include/test_type.h index 0e08251..daeff83 100644 --- a/modules/platforms/cpp/odbc-test/include/test_type.h +++ b/modules/platforms/cpp/odbc-test/include/test_type.h @@ -74,6 +74,7 @@ namespace ignite Guid guidField; Date dateField; Timestamp timestampField; + std::vector<int8_t> i8ArrayField; }; } @@ -107,6 +108,14 @@ namespace ignite writer.WriteGuid("guidField", obj.guidField); writer.WriteDate("dateField", obj.dateField); writer.WriteTimestamp("timestampField", obj.timestampField); + if (obj.i8ArrayField.empty()) + { + writer.WriteNull("i8ArrayField"); + } + else + { + writer.WriteInt8Array("i8ArrayField", &obj.i8ArrayField[0], static_cast<int32_t>(obj.i8ArrayField.size())); + } } else { @@ -121,6 +130,7 @@ namespace ignite writer.WriteNull("guidField"); writer.WriteNull("dateField"); writer.WriteNull("timestampField"); + writer.WriteNull("i8ArrayField"); } } @@ -138,9 +148,17 @@ namespace ignite Date dateField = reader.ReadDate("dateField"); Timestamp timestampField = reader.ReadTimestamp("timestampField"); - return TestType(i8Field, i16Field, i32Field, i64Field, strField, + TestType result(i8Field, i16Field, i32Field, i64Field, strField, floatField, doubleField, boolField, guidField, dateField, timestampField); + + int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0); + if (len > 0) + { + result.i8ArrayField.resize(len); + reader.ReadInt8Array("i8ArrayField", &result.i8ArrayField[0], len); + } + return result; } IGNITE_BINARY_TYPE_END http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/src/column_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/column_test.cpp b/modules/platforms/cpp/odbc-test/src/column_test.cpp index 6cbea8b..66d0214 100644 --- a/modules/platforms/cpp/odbc-test/src/column_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/column_test.cpp @@ -287,4 +287,193 @@ BOOST_AUTO_TEST_CASE(TestColumnMultiString) BOOST_REQUIRE(column2.GetUnreadDataLength() == 0); } +BOOST_AUTO_TEST_CASE(TestColumnByteArray) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + const int8_t bytes[] = { 'A','B','C','D','E','F','G','H','I','J' }; + std::vector<int8_t> data(bytes, bytes + sizeof(bytes) / sizeof(bytes[0])); + writer.WriteInt8Array(&data[0], static_cast<int32_t>(data.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column(reader); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size()); + + std::vector<int8_t> buf(data.size()); + SqlLen reslen = 0; + int* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_BINARY, &buf[0], buf.size(), &reslen, &offset); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + BOOST_REQUIRE_EQUAL_COLLECTIONS(buf.begin(), buf.end(), data.begin(), data.end()); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); +} + +BOOST_AUTO_TEST_CASE(TestColumnByteArrayHalfBuffer) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + const int8_t bytes[] = { 'A','B','C','D','E','F','G','H','I','J' }; + std::vector<int8_t> data(bytes, bytes + sizeof(bytes)/sizeof(bytes[0])); + BOOST_REQUIRE(0 == data.size() % 2); + + writer.WriteInt8Array(&data[0], static_cast<int32_t>(data.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column(reader); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size()); + + std::vector<int8_t> buf(data.size()/2); + SqlLen reslen = 0; + int* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_BINARY, &buf[0], buf.size(), &reslen, &offset); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == data.size() - buf.size()); + + std::vector<int8_t> result; + result.reserve(data.size()); + std::copy(buf.begin(), buf.end(), std::back_inserter(result)); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + std::copy(buf.begin(), buf.end(), std::back_inserter(result)); + + BOOST_REQUIRE(column.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column.IsValid()); + + BOOST_REQUIRE(column.GetSize() == data.size()); + + BOOST_REQUIRE(column.GetUnreadDataLength() == 0); + + BOOST_REQUIRE_EQUAL_COLLECTIONS(result.begin(), result.end(), data.begin(), data.end()); +} + +BOOST_AUTO_TEST_CASE(TestColumnByteArrayTwoColumns) +{ + ignite::impl::interop::InteropUnpooledMemory mem(4096); + ignite::impl::interop::InteropOutputStream outStream(&mem); + ignite::impl::binary::BinaryWriterImpl writer(&outStream, 0); + + const int8_t bytes1[] = { 'A','B','C','D','E','F','G','H','I','J' }; + const int8_t bytes2[] = { 'a','b','c','d','e','f','g','h','i','j' }; + std::vector<int8_t> data1(bytes1, bytes1 + sizeof(bytes1)/sizeof(bytes1[0])); + std::vector<int8_t> data2(bytes2, bytes2 + sizeof(bytes2)/sizeof(bytes2[0])); + writer.WriteInt8Array(&data1[0], static_cast<int32_t>(data1.size())); + writer.WriteInt8Array(&data2[0], static_cast<int32_t>(data2.size())); + + outStream.Synchronize(); + + ignite::impl::interop::InteropInputStream inStream(&mem); + ignite::impl::binary::BinaryReaderImpl reader(&inStream); + + Column column1(reader); + inStream.Position(column1.GetEndPosition()); + Column column2(reader); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == data1.size()); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data2.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == data2.size()); + + int8_t buf[1024] = {}; + SqlLen reslen = 0; + int* offset = 0; + + ApplicationDataBuffer appBuf(type_traits::IGNITE_ODBC_C_TYPE_BINARY, &buf, sizeof(buf), &reslen, &offset); + + BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == 0); + + BOOST_REQUIRE_EQUAL_COLLECTIONS(buf, buf + reslen, data1.begin(), data1.end()); + + BOOST_REQUIRE(column1.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column1.IsValid()); + + BOOST_REQUIRE(column1.GetSize() == data1.size()); + + BOOST_REQUIRE(column1.GetUnreadDataLength() == 0); + + BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_SUCCESS); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data1.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == 0); + + BOOST_REQUIRE_EQUAL_COLLECTIONS(buf, buf + reslen, data2.begin(), data2.end()); + + BOOST_REQUIRE(column2.ReadToBuffer(reader, appBuf) == SQL_RESULT_NO_DATA); + + BOOST_REQUIRE(column2.IsValid()); + + BOOST_REQUIRE(column2.GetSize() == data1.size()); + + BOOST_REQUIRE(column2.GetUnreadDataLength() == 0); +} + BOOST_AUTO_TEST_SUITE_END() http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp index 29d1d18..b118ff8 100644 --- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp +++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp @@ -285,4 +285,21 @@ namespace ignite CheckSingleResult0(request, SQL_C_TIMESTAMP, &res, 0, 0); } + + template<> + void SqlTestSuiteFixture::CheckSingleResult<std::vector<int8_t> >(const char* request, const std::vector<int8_t>& expected) + { + SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 }; + SQLLEN resLen = 0; + + CheckSingleResult0(request, SQL_C_BINARY, res, ODBC_BUFFER_SIZE, &resLen); + + BOOST_REQUIRE_EQUAL(resLen, expected.size()); + + if (resLen > 0) + { + std::vector<int8_t> actual(res, res + resLen); + BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), actual.begin(), actual.end()); + } + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp index ccbb917..33797b0 100644 --- a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp @@ -22,6 +22,7 @@ #include <boost/test/unit_test.hpp> #include "sql_test_suite_fixture.h" +#include "test_utils.h" using namespace ignite; @@ -56,5 +57,135 @@ BOOST_AUTO_TEST_CASE(TestGuidEqualsToColumn) "SELECT i32Field FROM TestType WHERE guidField = {guid '04cc382a-0b82-f520-08d0-07a0620c0004'}", in2.i32Field); } +BOOST_AUTO_TEST_CASE(TestByteArraySelect) +{ + TestType in; + const int8_t data[] = { 'A','B','C','D','E','F','G','H','I','J' }; + in.i8ArrayField.assign(data, data + sizeof(data)/sizeof(data[0])); + testCache.Put(1, in); + + TestType out = testCache.Get(1); + + BOOST_REQUIRE(in.i8ArrayField.size() == out.i8ArrayField.size()); + + BOOST_REQUIRE_EQUAL_COLLECTIONS(in.i8ArrayField.begin(), in.i8ArrayField.end(), out.i8ArrayField.begin(), out.i8ArrayField.end()); + + CheckSingleResult<std::vector<int8_t> >("SELECT i8ArrayField FROM TestType", in.i8ArrayField); +} + +BOOST_AUTO_TEST_CASE(TestByteArrayParam) +{ + SQLRETURN ret; + + TestType in; + in.i8Field = 101; + + const int8_t data[] = { 'A','B','C','D','E','F','G','H','I','J' }; + in.i8ArrayField.assign(data, data + sizeof(data) / sizeof(data[0])); + + testCache.Put(1, in); + + SQLLEN colLen = 0; + SQLCHAR colData = 0; + + ret = SQLBindCol(stmt, 1, SQL_C_TINYINT, &colData, sizeof(colData), &colLen); + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + SQLCHAR request[] = "SELECT i8Field FROM TestType WHERE i8ArrayField = ?"; + + ret = SQLPrepare(stmt, request, SQL_NTS); + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + std::vector<int8_t> paramData(in.i8ArrayField); + SQLLEN paramLen = paramData.size(); + ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, paramData.size(), 0, ¶mData[0], paramData.size(), ¶mLen); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + ret = SQLExecute(stmt); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + ret = SQLFetch(stmt); + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + BOOST_REQUIRE_EQUAL(colData, in.i8Field); + BOOST_REQUIRE_EQUAL(colLen, sizeof(colData)); + + ret = SQLFetch(stmt); + BOOST_REQUIRE(ret == SQL_NO_DATA); +} + +BOOST_AUTO_TEST_CASE(TestByteArrayParamInsert) +{ + SQLRETURN ret; + + const int8_t data[] = { 'A','B','C','D','E','F','G','H','I','J' }; + std::vector<int8_t> paramData(data, data + sizeof(data) / sizeof(data[0])); + SQLCHAR request[] = "INSERT INTO TestType(_key, i8ArrayField) VALUES(?, ?)";; + + ret = SQLPrepare(stmt, request, SQL_NTS); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + int64_t key = 1; + ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_BIGINT, 0, 0, &key, 0, 0); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + SQLLEN paramLen = paramData.size(); + + ret = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, paramData.size(), 0, ¶mData[0], paramData.size(), ¶mLen); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + ret = SQLExecute(stmt); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + TestType out = testCache.Get(key); + BOOST_REQUIRE_EQUAL_COLLECTIONS(out.i8ArrayField.begin(), out.i8ArrayField.end(), paramData.begin(), paramData.end()); +} + +BOOST_AUTO_TEST_CASE(TestByteParamInsert) +{ + SQLRETURN ret; + + SQLCHAR request[] = "INSERT INTO TestType(_key, i8Field) VALUES(?, ?)";; + + ret = SQLPrepare(stmt, request, SQL_NTS); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + int64_t key = 1; + ret = SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_BIGINT, 0, 0, &key, 0, 0); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + int8_t data = 2; + ret = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_TINYINT, SQL_TINYINT, 0, 0, &data, 0, 0); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + ret = SQLExecute(stmt); + + if (!SQL_SUCCEEDED(ret)) + BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)); + + TestType out = testCache.Get(key); + BOOST_REQUIRE_EQUAL(out.i8Field, data); +} BOOST_AUTO_TEST_SUITE_END() http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/Makefile.am ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am index b0cc5f8..1eb42d1 100644 --- a/modules/platforms/cpp/odbc/Makefile.am +++ b/modules/platforms/cpp/odbc/Makefile.am @@ -33,7 +33,7 @@ AM_CPPFLAGS = \ AM_CXXFLAGS = \ -Wall \ - -std=c++0x + -std=c++03 libignite_odbc_la_LIBADD = \ @top_srcdir@/binary/libignite-binary.la \ http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h index 37daa50..590e97c 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h @@ -46,7 +46,6 @@ void logInit(const char*); fprintf(log_file, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__); \ fflush(log_file); \ } while (false) - #else # define LOG_MSG(...) #endif @@ -181,6 +180,14 @@ namespace ignite * @return Standard string containing the same data. */ std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen); + + /** + * Convert binary data to hex dump form + * @param data pointer to data + * @param count data length + * @return standard string containing the formated hex dump + */ + std::string HexDump(const char* data, size_t count); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/src/column.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/column.cpp b/modules/platforms/cpp/odbc/src/column.cpp index 3e6bbca..0ec8078 100644 --- a/modules/platforms/cpp/odbc/src/column.cpp +++ b/modules/platforms/cpp/odbc/src/column.cpp @@ -40,7 +40,7 @@ namespace break; } - + case IGNITE_TYPE_OBJECT: { int8_t protoVer = stream.ReadInt8(); @@ -88,6 +88,7 @@ namespace case IGNITE_TYPE_DOUBLE: case IGNITE_TYPE_BOOL: case IGNITE_HDR_NULL: + case IGNITE_TYPE_ARRAY_BYTE: { // No-op. break; @@ -290,6 +291,17 @@ namespace ignite break; } + case IGNITE_TYPE_ARRAY_BYTE: + { + sizeTmp = reader.ReadInt32(); + assert(sizeTmp >= 0); + + startPosTmp = stream->Position(); + stream->Position(stream->Position() + sizeTmp); + + break; + } + default: { // This is a fail case. @@ -473,6 +485,20 @@ namespace ignite break; } + case IGNITE_TYPE_ARRAY_BYTE: + { + stream->Position(startPos + offset); + int32_t maxRead = std::min(GetUnreadDataLength(), static_cast<int32_t>(dataBuf.GetSize())); + std::vector<int8_t> data(maxRead); + + stream->ReadInt8Array(&data[0], static_cast<int32_t>(data.size())); + + int32_t written = dataBuf.PutBinaryData(data.data(), data.size()); + + IncreaseOffset(written); + break; + } + default: { // This is a fail case. Return false. http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/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 341ab7f..7c612bc 100644 --- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp +++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp @@ -412,7 +412,7 @@ namespace ignite StringInfoMap::const_iterator itStr = strParams.find(type); - if (itStr != strParams.cend()) + if (itStr != strParams.end()) { unsigned short strlen = static_cast<short>( utility::CopyStringToBuffer(itStr->second, @@ -426,7 +426,7 @@ namespace ignite UintInfoMap::const_iterator itInt = intParams.find(type); - if (itInt != intParams.cend()) + if (itInt != intParams.end()) { unsigned int *res = reinterpret_cast<unsigned int*>(buf); @@ -437,7 +437,7 @@ namespace ignite UshortInfoMap::const_iterator itShort = shortParams.find(type); - if (itShort != shortParams.cend()) + if (itShort != shortParams.end()) { unsigned short *res = reinterpret_cast<unsigned short*>(buf); http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/src/connection.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp index 38f8cba..2afa42d 100644 --- a/modules/platforms/cpp/odbc/src/connection.cpp +++ b/modules/platforms/cpp/odbc/src/connection.cpp @@ -194,6 +194,8 @@ namespace ignite if (sent != len + sizeof(OdbcProtocolHeader)) IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not send message"); + + LOG_MSG("message sent: (%d bytes)%s\n", msg.GetSize(), utility::HexDump((char*)msg.GetData(), msg.GetSize()).c_str()); } size_t Connection::SendAll(const int8_t* data, size_t len) http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/src/odbc.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp index 0b18a11..dbec55f 100644 --- a/modules/platforms/cpp/odbc/src/odbc.cpp +++ b/modules/platforms/cpp/odbc/src/odbc.cpp @@ -512,9 +512,10 @@ namespace ignite int32_t res = statement->GetColumnNumber(); if (columnNum) + { *columnNum = static_cast<SQLSMALLINT>(res); - - LOG_MSG("columnNum: %d\n", *columnNum); + LOG_MSG("columnNum: %d\n", *columnNum); + } return statement->GetDiagnosticRecords().GetReturnCode(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/32d2629e/modules/platforms/cpp/odbc/src/utility.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/utility.cpp b/modules/platforms/cpp/odbc/src/utility.cpp index 756ab36..c15c23c 100644 --- a/modules/platforms/cpp/odbc/src/utility.cpp +++ b/modules/platforms/cpp/odbc/src/utility.cpp @@ -154,6 +154,21 @@ namespace ignite else res.clear(); } + + std::string HexDump(const char* data, size_t count) + { + std::stringstream dump; + size_t cnt = 0; + for(const char* p = data, *e = data + count; p != e; ++p) + { + if (cnt++ % 16 == 0) + { + dump << std::endl; + } + dump << std::hex << std::setfill('0') << std::setw(2) << (int)*p << " "; + } + return dump.str(); + } } }