You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2017/03/25 00:13:26 UTC
[46/56] [abbrv] ignite git commit: IGNITE-4691: Added Time type
support to ODBC.
IGNITE-4691: Added Time type support to ODBC.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/612e92ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/612e92ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/612e92ac
Branch: refs/heads/ignite-1192
Commit: 612e92ac99f0b8305ae9efe92dc32cb46eeb9358
Parents: 1a93a72
Author: Igor Sapego <is...@gridgain.com>
Authored: Wed Mar 22 17:31:12 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Wed Mar 22 17:31:12 2017 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcMessageParser.java | 13 +-
.../ignite/impl/binary/binary_reader_impl.h | 4 +-
.../cpp/common/include/ignite/common/utils.h | 25 +++
.../cpp/core-test/include/ignite/test_type.h | 10 +-
.../core-test/src/binary_reader_writer_test.cpp | 4 +-
.../cpp/core-test/src/cache_invoke_test.cpp | 56 ++---
.../cpp/core-test/src/cluster_test.cpp | 31 +--
.../cpp/core-test/src/date_time_test.cpp | 22 ++
.../cpp/odbc-test/config/queries-default.xml | 2 +-
.../odbc-test/include/sql_test_suite_fixture.h | 7 +-
.../platforms/cpp/odbc-test/include/test_type.h | 33 ++-
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../cpp/odbc-test/src/api_robustness_test.cpp | 1 -
.../src/application_data_buffer_test.cpp | 224 +++++++++++++++----
.../platforms/cpp/odbc-test/src/cursor_test.cpp | 6 +-
.../cpp/odbc-test/src/queries_test.cpp | 107 +++++----
.../src/sql_date_time_functions_test.cpp | 5 +
.../src/sql_esc_convert_function_test.cpp | 8 +-
.../odbc-test/src/sql_test_suite_fixture.cpp | 33 ++-
.../cpp/odbc-test/src/sql_types_test.cpp | 24 +-
.../platforms/cpp/odbc-test/src/test_utils.cpp | 7 +
.../ignite/odbc/app/application_data_buffer.h | 15 ++
.../cpp/odbc/include/ignite/odbc/message.h | 2 +-
.../cpp/odbc/include/ignite/odbc/type_traits.h | 5 +-
.../odbc/src/app/application_data_buffer.cpp | 184 +++++++++++++++
.../platforms/cpp/odbc/src/app/parameter.cpp | 7 +
modules/platforms/cpp/odbc/src/column.cpp | 19 ++
modules/platforms/cpp/odbc/src/type_traits.cpp | 13 +-
29 files changed, 658 insertions(+), 213 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
index 7b863d6..ab93f25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
@@ -254,9 +254,18 @@ public class OdbcMessageParser {
writer.writeInt(row.size());
for (Object obj : row) {
- if (obj instanceof java.sql.Timestamp)
+ if (obj == null) {
+ writer.writeObjectDetached(null);
+ continue;
+ }
+
+ Class<?> cls = obj.getClass();
+
+ if (cls == java.sql.Time.class)
+ writer.writeTime((java.sql.Time)obj);
+ else if (cls == java.sql.Timestamp.class)
writer.writeTimestamp((java.sql.Timestamp)obj);
- else if (obj instanceof java.util.Date)
+ else if (cls == java.sql.Date.class)
writer.writeDate((java.util.Date)obj);
else
writer.writeObjectDetached(obj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 242bb1e..76f6fbf 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -1113,14 +1113,14 @@ namespace ignite
* @param len Length.
*/
static void ReadTimeArrayInternal(
- interop::InteropInputStream* stream,
+ interop::InteropInputStream* stream,
Time* res,
const int32_t len
);
/**
* Read single value in raw mode.
- *
+ *
* @param func Function to be invoked on stream.
* @return Result.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index 32d250f..67a4a3f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -190,6 +190,17 @@ namespace ignite
}
/**
+ * Convert Time type to standard C type time_t.
+ *
+ * @param time Time type value.
+ * @return Corresponding value of time_t.
+ */
+ inline time_t TimeToCTime(const Time& time)
+ {
+ return static_cast<time_t>(time.GetSeconds());
+ }
+
+ /**
* Convert Date type to standard C type time_t.
*
* @param date Date type value.
@@ -218,6 +229,20 @@ namespace ignite
}
/**
+ * Convert Time type to standard C type struct tm.
+ *
+ * @param time Time type value.
+ * @param ctime Corresponding value of struct tm.
+ * @return True on success.
+ */
+ inline bool TimeToCTm(const Time& time, tm& ctime)
+ {
+ time_t tmt = TimeToCTime(time);
+
+ return common::IgniteGmTime(tmt, ctime);
+ }
+
+ /**
* Convert standard C type time_t to Date.
*
* @param ctime Standard C type time_t.
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
index 7c7e6a2..d1dd967 100644
--- a/modules/platforms/cpp/core-test/include/ignite/test_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-#ifndef _IGNITE_ODBC_TEST_TEST_TYPE
-#define _IGNITE_ODBC_TEST_TEST_TYPE
+#ifndef _IGNITE_CORE_TEST_TEST_TYPE
+#define _IGNITE_CORE_TEST_TEST_TYPE
#include <string>
#include "ignite/ignite.h"
-#include "ignite/ignition.h"
namespace ignite
{
@@ -98,10 +97,7 @@ namespace ignite
Timestamp timestampField;
std::vector<int8_t> i8ArrayField;
};
-}
-namespace ignite
-{
namespace binary
{
IGNITE_BINARY_TYPE_START(ignite::TestType)
@@ -190,4 +186,4 @@ namespace ignite
}
};
-#endif // _IGNITE_ODBC_TEST_TEST_TYPE
+#endif // _IGNITE_CORE_TEST_TEST_TYPE
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index 3115764..8edc0ff 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -66,7 +66,7 @@ void CheckPrimitive(T val)
BOOST_CHECK_EXCEPTION(Read<T>(reader, NULL), IgniteError, IsBinaryError);
- T readVal = Read<T>(reader, "test");
+ T readVal = Read<T>(reader, "test");
BOOST_REQUIRE(readVal == val);
}
@@ -350,7 +350,7 @@ void CheckCollectionEmpty(CollectionType* colType)
BOOST_REQUIRE(colReader.GetSize() == 0);
BOOST_REQUIRE(!colReader.HasNext());
BOOST_REQUIRE(!colReader.IsNull());
-
+
BOOST_CHECK_EXCEPTION(colReader.GetNext(), IgniteError, IsBinaryError);
BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
index 3ab6f2b9..1b548a6 100644
--- a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
@@ -28,6 +28,8 @@
#include "ignite/ignite.h"
#include "ignite/ignition.h"
+#include "ignite/test_utils.h"
+
#include "ignite/ignite_binding_context.h"
#include "ignite/cache/cache_entry_processor.h"
@@ -387,45 +389,17 @@ IGNITE_EXPORTED_CALL void IgniteModuleInit(ignite::IgniteBindingContext& context
/**
* Test setup fixture.
*/
-struct CacheInvokeTestSuiteFixture {
-
- Ignite CreateGrid()
- {
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
- cfg.jvmOpts.push_back("-DIGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE=1000");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 512;
-#else
- cfg.jvmInitMem = 512;
- cfg.jvmMaxMem = 2048;
-#endif
-
- cfg.springCfgPath = std::string(getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH")) + "/cache-query.xml";
-
- IgniteError err;
-
- Ignite grid0 = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_ERROR(err.GetText());
-
- return grid0;
- }
+struct CacheInvokeTestSuiteFixture
+{
+ Ignite node;
/**
* Constructor.
*/
- CacheInvokeTestSuiteFixture()
+ CacheInvokeTestSuiteFixture() :
+ node(ignite_test::StartNode("cache-query.xml", "InvokeTest"))
{
- grid = CreateGrid();
+ // No-op.
}
/**
@@ -433,10 +407,8 @@ struct CacheInvokeTestSuiteFixture {
*/
~CacheInvokeTestSuiteFixture()
{
- Ignition::Stop(grid.GetName(), true);
+ Ignition::StopAll(true);
}
-
- Ignite grid;
};
BOOST_FIXTURE_TEST_SUITE(CacheInvokeTestSuite, CacheInvokeTestSuiteFixture)
@@ -446,7 +418,7 @@ BOOST_FIXTURE_TEST_SUITE(CacheInvokeTestSuite, CacheInvokeTestSuiteFixture)
*/
BOOST_AUTO_TEST_CASE(TestExisting)
{
- Cache<int, int> cache = grid.GetOrCreateCache<int, int>("TestCache");
+ Cache<int, int> cache = node.GetOrCreateCache<int, int>("TestCache");
cache.Put(5, 20);
@@ -464,7 +436,7 @@ BOOST_AUTO_TEST_CASE(TestExisting)
*/
BOOST_AUTO_TEST_CASE(TestNonExisting)
{
- Cache<int, int> cache = grid.GetOrCreateCache<int, int>("TestCache");
+ Cache<int, int> cache = node.GetOrCreateCache<int, int>("TestCache");
CacheEntryModifier ced;
@@ -480,7 +452,7 @@ BOOST_AUTO_TEST_CASE(TestNonExisting)
*/
BOOST_AUTO_TEST_CASE(TestSeveral)
{
- Cache<int, int> cache = grid.GetOrCreateCache<int, int>("TestCache");
+ Cache<int, int> cache = node.GetOrCreateCache<int, int>("TestCache");
CacheEntryModifier ced(2);
Divisor div(10.0);
@@ -515,11 +487,11 @@ BOOST_AUTO_TEST_CASE(TestSeveral)
*/
BOOST_AUTO_TEST_CASE(TestStrings)
{
- IgniteBinding binding = grid.GetBinding();
+ IgniteBinding binding = node.GetBinding();
binding.RegisterCacheEntryProcessor<CharRemover>();
- Cache<std::string, std::string> cache = grid.GetOrCreateCache<std::string, std::string>("TestCache");
+ Cache<std::string, std::string> cache = node.GetOrCreateCache<std::string, std::string>("TestCache");
CharRemover cr('.');
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/core-test/src/cluster_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cluster_test.cpp b/modules/platforms/cpp/core-test/src/cluster_test.cpp
index 660ff59..8dfd39d 100644
--- a/modules/platforms/cpp/core-test/src/cluster_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cluster_test.cpp
@@ -22,6 +22,7 @@
#include <boost/test/unit_test.hpp>
#include <ignite/ignition.h>
+#include <ignite/test_utils.h>
using namespace ignite;
using namespace ignite::common::concurrent;
@@ -35,27 +36,10 @@ struct ClusterTestSuiteFixture {
/*
* Constructor.
*/
- ClusterTestSuiteFixture()
+ ClusterTestSuiteFixture() :
+ node(ignite_test::StartNode("cache-test.xml", "ClusterTest"))
{
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- cfg.springCfgPath.assign(getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH")).append("/cache-test.xml");
-
- grid = Ignition::Start(cfg, "ClusterTest");
+ // No-op.
}
/*
@@ -64,17 +48,16 @@ struct ClusterTestSuiteFixture {
~ClusterTestSuiteFixture()
{
Ignition::StopAll(true);
- grid = Ignite();
}
- Ignite grid;
+ Ignite node;
};
BOOST_FIXTURE_TEST_SUITE(ClusterTestSuite, ClusterTestSuiteFixture)
BOOST_AUTO_TEST_CASE(IgniteImplProjection)
{
- impl::IgniteImpl* impl = impl::IgniteImpl::GetFromProxy(grid);
+ impl::IgniteImpl* impl = impl::IgniteImpl::GetFromProxy(node);
BOOST_REQUIRE(impl != 0);
BOOST_REQUIRE(impl->GetProjection().IsValid());
@@ -82,7 +65,7 @@ BOOST_AUTO_TEST_CASE(IgniteImplProjection)
BOOST_AUTO_TEST_CASE(IgniteImplForServers)
{
- impl::IgniteImpl* impl = impl::IgniteImpl::GetFromProxy(grid);
+ impl::IgniteImpl* impl = impl::IgniteImpl::GetFromProxy(node);
BOOST_REQUIRE(impl != 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/core-test/src/date_time_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/date_time_test.cpp b/modules/platforms/cpp/core-test/src/date_time_test.cpp
index 0c93a17..6e01309 100644
--- a/modules/platforms/cpp/core-test/src/date_time_test.cpp
+++ b/modules/platforms/cpp/core-test/src/date_time_test.cpp
@@ -77,6 +77,18 @@ void CheckOperators(const T& val1, const T& val2, const T& val3)
BOOST_CHECK(val3 >= val1);
}
+void CheckTime(int hour, int mins, int sec)
+{
+ Time time = common::MakeTimeGmt(hour, mins, sec);
+ tm res;
+
+ common::TimeToCTm(time, res);
+
+ BOOST_CHECK_EQUAL(res.tm_hour, hour);
+ BOOST_CHECK_EQUAL(res.tm_min, mins);
+ BOOST_CHECK_EQUAL(res.tm_sec, sec);
+}
+
void CheckDate(int year, int mon, int day)
{
Date date = common::MakeDateGmt(year, mon, day);
@@ -242,6 +254,16 @@ BOOST_AUTO_TEST_CASE(MakeTimestamp)
BOOST_CHECK_EQUAL(MakeTimestampGmt(2017, 3, 20, 18, 43, 19, 170038645).GetDate().GetMilliseconds(), 1490035399170);
}
+BOOST_AUTO_TEST_CASE(CastTimeToTm)
+{
+ CheckTime(21, 8, 5);
+ CheckTime(12, 41, 11);
+ CheckTime(1, 28, 18);
+ CheckTime(8, 12, 59);
+ CheckTime(17, 52, 31);
+ CheckTime(21, 56, 21);
+}
+
BOOST_AUTO_TEST_CASE(CastDateToTm)
{
CheckDate(2024, 8, 5);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 6dbc4f7..c1eaea8 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-default.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-default.xml
@@ -29,7 +29,6 @@
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="localHost" value="127.0.0.1"/>
<property name="connectorConfiguration"><null/></property>
- <!--<property name="odbcConfiguration"><null/></property>-->
<property name="cacheConfiguration">
<list>
@@ -58,6 +57,7 @@
<entry key="boolField" value="java.lang.Boolean"/>
<entry key="guidField" value="java.util.UUID"/>
<entry key="dateField" value="java.util.Date"/>
+ <entry key="timeField" value="java.sql.Time"/>
<entry key="timestampField" value="java.sql.Timestamp"/>
<entry key="i8ArrayField" value="[B"/>
</map>
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 0fa6ec9..bbcc0ad 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
@@ -195,6 +195,9 @@ namespace ignite
void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request);
template<>
+ void SqlTestSuiteFixture::CheckSingleResult<Time>(const char* request);
+
+ template<>
void SqlTestSuiteFixture::CheckSingleResult<std::vector<int8_t> >(const char* request, const std::vector<int8_t>& expected);
template<>
@@ -204,10 +207,10 @@ namespace ignite
void SqlTestSuiteFixture::CheckSingleResult<Date>(const char* request, const Date& expected);
template<>
- void SqlTestSuiteFixture::CheckSingleResult<SQL_TIME_STRUCT>(const char* request, const SQL_TIME_STRUCT& expected);
+ void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected);
template<>
- void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected);
+ void SqlTestSuiteFixture::CheckSingleResult<Time>(const char* request, const Time& expected);
}
#endif //_IGNITE_ODBC_TEST_SQL_TEST_SUIT_FIXTURE
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 daeff83..51271b5 100644
--- a/modules/platforms/cpp/odbc-test/include/test_type.h
+++ b/modules/platforms/cpp/odbc-test/include/test_type.h
@@ -21,7 +21,6 @@
#include <string>
#include "ignite/ignite.h"
-#include "ignite/ignition.h"
namespace ignite
{
@@ -37,6 +36,7 @@ namespace ignite
doubleField(0.0),
boolField(false),
dateField(),
+ timeField(),
timestampField()
{
// No-op.
@@ -45,7 +45,7 @@ namespace ignite
TestType(int8_t i8Field, int16_t i16Field, int32_t i32Field,
int64_t i64Field, const std::string& strField, float floatField,
double doubleField, bool boolField, const Guid& guidField,
- const Date& dateField, const Timestamp& timestampField) :
+ const Date& dateField, const Time& timeField, const Timestamp& timestampField) :
allNulls(false),
i8Field(i8Field),
i16Field(i16Field),
@@ -57,11 +57,31 @@ namespace ignite
boolField(boolField),
guidField(guidField),
dateField(dateField),
+ timeField(timeField),
timestampField(timestampField)
{
// No-op.
}
+ friend bool operator==(const TestType& one, const TestType& two)
+ {
+ return
+ one.allNulls == two.allNulls &&
+ one.i8Field == two.i8Field &&
+ one.i16Field == two.i16Field &&
+ one.i32Field == two.i32Field &&
+ one.i64Field == two.i64Field &&
+ one.strField == two.strField &&
+ one.floatField == two.floatField &&
+ one.doubleField == two.doubleField &&
+ one.boolField == two.boolField &&
+ one.guidField == two.guidField &&
+ one.dateField == two.dateField &&
+ one.timeField == two.timeField &&
+ one.timestampField == two.timestampField &&
+ one.i8ArrayField == two.i8ArrayField;
+ }
+
bool allNulls;
int8_t i8Field;
int16_t i16Field;
@@ -73,13 +93,11 @@ namespace ignite
bool boolField;
Guid guidField;
Date dateField;
+ Time timeField;
Timestamp timestampField;
std::vector<int8_t> i8ArrayField;
};
-}
-namespace ignite
-{
namespace binary
{
IGNITE_BINARY_TYPE_START(ignite::TestType)
@@ -107,6 +125,7 @@ namespace ignite
writer.WriteBool("boolField", obj.boolField);
writer.WriteGuid("guidField", obj.guidField);
writer.WriteDate("dateField", obj.dateField);
+ writer.WriteTime("timeField", obj.timeField);
writer.WriteTimestamp("timestampField", obj.timestampField);
if (obj.i8ArrayField.empty())
{
@@ -129,6 +148,7 @@ namespace ignite
writer.WriteNull("boolField");
writer.WriteNull("guidField");
writer.WriteNull("dateField");
+ writer.WriteNull("timeField");
writer.WriteNull("timestampField");
writer.WriteNull("i8ArrayField");
}
@@ -146,11 +166,12 @@ namespace ignite
bool boolField = reader.ReadBool("boolField");
Guid guidField = reader.ReadGuid("guidField");
Date dateField = reader.ReadDate("dateField");
+ Time timeField = reader.ReadTime("timeField");
Timestamp timestampField = reader.ReadTimestamp("timestampField");
TestType result(i8Field, i16Field, i32Field, i64Field, strField,
floatField, doubleField, boolField, guidField, dateField,
- timestampField);
+ timeField, timestampField);
int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
if (len > 0)
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 8740d5a..0f467f7 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -208,6 +208,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="..\..\config\queries-default.xml" />
<None Include="..\..\config\queries-test-noodbc.xml" />
<None Include="..\..\config\queries-test.xml" />
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index a53cc47..a4d3292 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -143,5 +143,8 @@
<None Include="..\..\config\queries-test-noodbc.xml">
<Filter>Configs</Filter>
</None>
+ <None Include="..\..\config\queries-default.xml">
+ <Filter>Configs</Filter>
+ </None>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
index 343cdc6..c0c68bf 100644
--- a/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/api_robustness_test.cpp
@@ -253,7 +253,6 @@ SQLSMALLINT unsupportedSql[] = {
SQL_WLONGVARCHAR,
SQL_REAL,
SQL_NUMERIC,
- SQL_TYPE_TIME,
SQL_INTERVAL_MONTH,
SQL_INTERVAL_YEAR,
SQL_INTERVAL_YEAR_TO_MONTH,
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
index 82521be..cca1dad 100644
--- a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
@@ -114,18 +114,6 @@ BOOST_AUTO_TEST_CASE(TestPutGuidToString)
BOOST_CHECK(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
}
-BOOST_AUTO_TEST_CASE(TestGetGuidFromString)
-{
- char buffer[] = "1da1ef8f-39ff-4d62-8b72-e8e9f3371801";
- SqlLen reslen = sizeof(buffer) - 1;
-
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer) - 1, &reslen, 0);
-
- ignite::Guid guid = appBuf.GetGuid();
-
- BOOST_CHECK_EQUAL(guid, Guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL));
-}
-
BOOST_AUTO_TEST_CASE(TestPutBinaryToString)
{
char buffer[1024];
@@ -413,29 +401,35 @@ BOOST_AUTO_TEST_CASE(TestPutDateToString)
BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("1999-02-22"));
}
-BOOST_AUTO_TEST_CASE(TestPutTimestampToString)
+BOOST_AUTO_TEST_CASE(TestPutDateToDate)
{
- char strBuf[64] = { 0 };
- SqlLen reslen = 0;
+ SQL_DATE_STRUCT buf = { 0 };
+ SqlLen reslen = sizeof(buf);
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
+ int offset = 0;
+ int* offsetPtr = &offset;
- Timestamp date = common::MakeTimestampGmt(2018, 11, 1, 17, 45, 59);
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr);
- appBuf.PutTimestamp(date);
+ Date date = common::MakeDateGmt(1984, 5, 27);
- BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("2018-11-01 17:45:59"));
+ appBuf.PutDate(date);
+
+ BOOST_CHECK_EQUAL(1984, buf.year);
+ BOOST_CHECK_EQUAL(5, buf.month);
+ BOOST_CHECK_EQUAL(27, buf.day);
}
-BOOST_AUTO_TEST_CASE(TestPutDateToDate)
+BOOST_AUTO_TEST_CASE(TestPutDateToTimestamp)
{
- SQL_DATE_STRUCT buf = { 0 };
+ SQL_TIMESTAMP_STRUCT buf = { 0 };
+
SqlLen reslen = sizeof(buf);
int offset = 0;
int* offsetPtr = &offset;
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TDATE, &buf, sizeof(buf), &reslen, &offsetPtr);
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
Date date = common::MakeDateGmt(1984, 5, 27);
@@ -444,6 +438,57 @@ BOOST_AUTO_TEST_CASE(TestPutDateToDate)
BOOST_CHECK_EQUAL(1984, buf.year);
BOOST_CHECK_EQUAL(5, buf.month);
BOOST_CHECK_EQUAL(27, buf.day);
+ BOOST_CHECK_EQUAL(0, buf.hour);
+ BOOST_CHECK_EQUAL(0, buf.minute);
+ BOOST_CHECK_EQUAL(0, buf.second);
+ BOOST_CHECK_EQUAL(0, buf.fraction);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutTimeToString)
+{
+ char strBuf[64] = { 0 };
+ SqlLen reslen = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
+
+ Time time = common::MakeTimeGmt(7, 15, 0);
+
+ appBuf.PutTime(time);
+
+ BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("07:15:00"));
+}
+
+BOOST_AUTO_TEST_CASE(TestPutTimeToTime)
+{
+ SQL_TIME_STRUCT buf = { 0 };
+ SqlLen reslen = sizeof(buf);
+
+ int offset = 0;
+ int* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIME, &buf, sizeof(buf), &reslen, &offsetPtr);
+
+ Time time = common::MakeTimeGmt(23, 51, 1);
+
+ appBuf.PutTime(time);
+
+ BOOST_CHECK_EQUAL(23, buf.hour);
+ BOOST_CHECK_EQUAL(51, buf.minute);
+ BOOST_CHECK_EQUAL(1, buf.second);
+}
+
+BOOST_AUTO_TEST_CASE(TestPutTimestampToString)
+{
+ char strBuf[64] = { 0 };
+ SqlLen reslen = 0;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &strBuf, sizeof(strBuf), &reslen, 0);
+
+ Timestamp date = common::MakeTimestampGmt(2018, 11, 1, 17, 45, 59);
+
+ appBuf.PutTimestamp(date);
+
+ BOOST_CHECK_EQUAL(std::string(strBuf, reslen), std::string("2018-11-01 17:45:59"));
}
BOOST_AUTO_TEST_CASE(TestPutTimestampToDate)
@@ -465,33 +510,28 @@ BOOST_AUTO_TEST_CASE(TestPutTimestampToDate)
BOOST_CHECK_EQUAL(14, buf.day);
}
-BOOST_AUTO_TEST_CASE(TestPutTimestampToTimestamp)
+BOOST_AUTO_TEST_CASE(TestPutTimestampToTime)
{
- SQL_TIMESTAMP_STRUCT buf = { 0 };
+ SQL_TIME_STRUCT buf = { 0 };
SqlLen reslen = sizeof(buf);
int offset = 0;
int* offsetPtr = &offset;
- ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIME, &buf, sizeof(buf), &reslen, &offsetPtr);
Timestamp ts = common::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623);
appBuf.PutTimestamp(ts);
- BOOST_CHECK_EQUAL(2004, buf.year);
- BOOST_CHECK_EQUAL(8, buf.month);
- BOOST_CHECK_EQUAL(14, buf.day);
BOOST_CHECK_EQUAL(6, buf.hour);
BOOST_CHECK_EQUAL(34, buf.minute);
BOOST_CHECK_EQUAL(51, buf.second);
- BOOST_CHECK_EQUAL(573948623, buf.fraction);
}
-BOOST_AUTO_TEST_CASE(TestPutDateToTimestamp)
+BOOST_AUTO_TEST_CASE(TestPutTimestampToTimestamp)
{
SQL_TIMESTAMP_STRUCT buf = { 0 };
-
SqlLen reslen = sizeof(buf);
int offset = 0;
@@ -499,17 +539,29 @@ BOOST_AUTO_TEST_CASE(TestPutDateToTimestamp)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
- Date date = common::MakeDateGmt(1984, 5, 27);
+ Timestamp ts = common::MakeTimestampGmt(2004, 8, 14, 6, 34, 51, 573948623);
- appBuf.PutDate(date);
+ appBuf.PutTimestamp(ts);
- BOOST_CHECK_EQUAL(1984, buf.year);
- BOOST_CHECK_EQUAL(5, buf.month);
- BOOST_CHECK_EQUAL(27, buf.day);
- BOOST_CHECK_EQUAL(0, buf.hour);
- BOOST_CHECK_EQUAL(0, buf.minute);
- BOOST_CHECK_EQUAL(0, buf.second);
- BOOST_CHECK_EQUAL(0, buf.fraction);
+ BOOST_CHECK_EQUAL(2004, buf.year);
+ BOOST_CHECK_EQUAL(8, buf.month);
+ BOOST_CHECK_EQUAL(14, buf.day);
+ BOOST_CHECK_EQUAL(6, buf.hour);
+ BOOST_CHECK_EQUAL(34, buf.minute);
+ BOOST_CHECK_EQUAL(51, buf.second);
+ BOOST_CHECK_EQUAL(573948623, buf.fraction);
+}
+
+BOOST_AUTO_TEST_CASE(TestGetGuidFromString)
+{
+ char buffer[] = "1da1ef8f-39ff-4d62-8b72-e8e9f3371801";
+ SqlLen reslen = sizeof(buffer) - 1;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer) - 1, &reslen, 0);
+
+ ignite::Guid guid = appBuf.GetGuid();
+
+ BOOST_CHECK_EQUAL(guid, Guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL));
}
BOOST_AUTO_TEST_CASE(TestGetStringFromLong)
@@ -835,6 +887,32 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromString)
BOOST_CHECK_EQUAL(0, tmDate.tm_sec);
}
+BOOST_AUTO_TEST_CASE(TestGetTimeFromString)
+{
+ char buf[] = "17:5:59";
+ SqlLen reslen = sizeof(buf);
+
+ int offset = 0;
+ int* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, &buf[0], sizeof(buf), &reslen, &offsetPtr);
+
+ Time time = appBuf.GetTime();
+
+ tm tmTime;
+
+ bool success = common::TimeToCTm(time, tmTime);
+
+ BOOST_REQUIRE(success);
+
+ BOOST_CHECK_EQUAL(1970, tmTime.tm_year + 1900);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mon + 1);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mday);
+ BOOST_CHECK_EQUAL(17, tmTime.tm_hour);
+ BOOST_CHECK_EQUAL(5, tmTime.tm_min);
+ BOOST_CHECK_EQUAL(59, tmTime.tm_sec);
+}
+
BOOST_AUTO_TEST_CASE(TestGetTimestampFromString)
{
char buf[] = "2018-11-01 17:45:59";
@@ -923,6 +1001,37 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromDate)
BOOST_CHECK_EQUAL(0, tmDate.tm_sec);
}
+BOOST_AUTO_TEST_CASE(TestGetTimestampFromTime)
+{
+ SQL_TIME_STRUCT buf = { 0 };
+
+ buf.hour = 6;
+ buf.minute = 34;
+ buf.second = 51;
+
+ SqlLen reslen = sizeof(buf);
+
+ int offset = 0;
+ int* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIME, &buf, sizeof(buf), &reslen, &offsetPtr);
+
+ Time time = appBuf.GetTime();
+
+ tm tmTime;
+
+ bool success = common::TimeToCTm(time, tmTime);
+
+ BOOST_REQUIRE(success);
+
+ BOOST_CHECK_EQUAL(1970, tmTime.tm_year + 1900);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mon + 1);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mday);
+ BOOST_CHECK_EQUAL(6, tmTime.tm_hour);
+ BOOST_CHECK_EQUAL(34, tmTime.tm_min);
+ BOOST_CHECK_EQUAL(51, tmTime.tm_sec);
+}
+
BOOST_AUTO_TEST_CASE(TestGetTimestampFromTimestamp)
{
SQL_TIMESTAMP_STRUCT buf = { 0 };
@@ -994,4 +1103,39 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromTimestamp)
BOOST_CHECK_EQUAL(51, tmDate.tm_sec);
}
+BOOST_AUTO_TEST_CASE(TestGetTimeFromTimestamp)
+{
+ SQL_TIMESTAMP_STRUCT buf = { 0 };
+
+ buf.year = 2004;
+ buf.month = 8;
+ buf.day = 14;
+ buf.hour = 6;
+ buf.minute = 34;
+ buf.second = 51;
+ buf.fraction = 573948623;
+
+ SqlLen reslen = sizeof(buf);
+
+ int offset = 0;
+ int* offsetPtr = &offset;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_TTIMESTAMP, &buf, sizeof(buf), &reslen, &offsetPtr);
+
+ Time time = appBuf.GetTime();
+
+ tm tmTime;
+
+ bool success = common::TimeToCTm(time, tmTime);
+
+ BOOST_REQUIRE(success);
+
+ BOOST_CHECK_EQUAL(1970, tmTime.tm_year + 1900);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mon + 1);
+ BOOST_CHECK_EQUAL(1, tmTime.tm_mday);
+ BOOST_CHECK_EQUAL(6, tmTime.tm_hour);
+ BOOST_CHECK_EQUAL(34, tmTime.tm_min);
+ BOOST_CHECK_EQUAL(51, tmTime.tm_sec);
+}
+
BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/cursor_test.cpp b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
index 2be2e23..add1e2e 100644
--- a/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/cursor_test.cpp
@@ -23,8 +23,8 @@
#include <ignite/impl/binary/binary_writer_impl.h>
-#include "ignite/odbc/system/odbc_constants.h"
-#include "ignite/odbc/cursor.h"
+#include <ignite/odbc/system/odbc_constants.h>
+#include <ignite/odbc/cursor.h>
using namespace ignite::odbc;
@@ -35,7 +35,7 @@ std::auto_ptr<ResultPage> CreateTestPage(bool last, int32_t size)
using namespace ignite::impl::binary;
using namespace ignite::impl::interop;
- ignite::impl::interop::InteropUnpooledMemory mem(1024);
+ InteropUnpooledMemory mem(1024);
InteropOutputStream outStream(&mem);
BinaryWriterImpl writer(&outStream, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 422648e..99f2994 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -152,16 +152,16 @@ struct QueriesTestSuiteFixture
SQLRETURN ret;
- TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
- TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), common::MakeDateGmt(1976, 1, 12),
- common::MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 456));
+ TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDateGmt(1976, 1, 12),
+ MakeTimeGmt(0, 8, 59), MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 456));
cache1.Put(1, in1);
cache1.Put(2, in2);
- const size_t columnsCnt = 11;
+ const size_t columnsCnt = 12;
T columns[columnsCnt] = { 0 };
@@ -174,8 +174,8 @@ struct QueriesTestSuiteFixture
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
- char request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+ char request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, guidField, dateField, timeField, timestampField FROM TestType";
ret = SQLExecDirect(stmt, reinterpret_cast<SQLCHAR*>(request), SQL_NTS);
if (!SQL_SUCCEEDED(ret))
@@ -200,6 +200,7 @@ struct QueriesTestSuiteFixture
BOOST_CHECK_EQUAL(columns[8], 0);
BOOST_CHECK_EQUAL(columns[9], 0);
BOOST_CHECK_EQUAL(columns[10], 0);
+ BOOST_CHECK_EQUAL(columns[11], 0);
SQLLEN columnLens[columnsCnt] = { 0 };
@@ -227,6 +228,7 @@ struct QueriesTestSuiteFixture
BOOST_CHECK_EQUAL(columns[8], 0);
BOOST_CHECK_EQUAL(columns[9], 0);
BOOST_CHECK_EQUAL(columns[10], 0);
+ BOOST_CHECK_EQUAL(columns[11], 0);
BOOST_CHECK_EQUAL(columnLens[0], static_cast<SQLLEN>(sizeof(T)));
BOOST_CHECK_EQUAL(columnLens[1], static_cast<SQLLEN>(sizeof(T)));
@@ -239,6 +241,7 @@ struct QueriesTestSuiteFixture
BOOST_CHECK_EQUAL(columnLens[8], SQL_NO_TOTAL);
BOOST_CHECK_EQUAL(columnLens[9], SQL_NO_TOTAL);
BOOST_CHECK_EQUAL(columnLens[10], SQL_NO_TOTAL);
+ BOOST_CHECK_EQUAL(columnLens[11], SQL_NO_TOTAL);
ret = SQLFetch(stmt);
BOOST_CHECK(ret == SQL_NO_DATA);
@@ -419,16 +422,16 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
SQLRETURN ret;
- TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
- TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), common::MakeDateGmt(1976, 1, 12),
- common::MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 999999999));
+ TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDateGmt(1976, 1, 12),
+ MakeTimeGmt(0, 8, 59), MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 999999999));
cache1.Put(1, in1);
cache1.Put(2, in2);
- const size_t columnsCnt = 11;
+ const size_t columnsCnt = 12;
SQLCHAR columns[columnsCnt][ODBC_BUFFER_SIZE] = { 0 };
@@ -441,8 +444,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
- SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, guidField, dateField, timeField, timestampField FROM TestType";
ret = SQLExecDirect(stmt, request, SQL_NTS);
if (!SQL_SUCCEEDED(ret))
@@ -467,7 +470,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0008-0000-000000000009");
// Such format is used because Date returned as Timestamp.
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1987-06-05 00:00:00");
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1998-12-27 01:02:03");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "12:48:12");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[11])), "1998-12-27 01:02:03");
SQLLEN columnLens[columnsCnt] = { 0 };
@@ -495,7 +499,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0001-0000-000000000000");
// Such format is used because Date returned as Timestamp.
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1976-01-12 00:00:00");
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1978-08-21 23:13:45");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "00:08:59");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[11])), "1978-08-21 23:13:45");
BOOST_CHECK_EQUAL(columnLens[0], 1);
BOOST_CHECK_EQUAL(columnLens[1], 1);
@@ -507,7 +512,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_CHECK_EQUAL(columnLens[7], 1);
BOOST_CHECK_EQUAL(columnLens[8], 36);
BOOST_CHECK_EQUAL(columnLens[9], 19);
- BOOST_CHECK_EQUAL(columnLens[10], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 8);
+ BOOST_CHECK_EQUAL(columnLens[11], 19);
ret = SQLFetch(stmt);
BOOST_CHECK(ret == SQL_NO_DATA);
@@ -519,12 +525,12 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
SQLRETURN ret;
- TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
cache1.Put(1, in);
- const size_t columnsCnt = 11;
+ const size_t columnsCnt = 12;
SQLCHAR columns[columnsCnt][ODBC_BUFFER_SIZE] = { 0 };
@@ -539,8 +545,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
- SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, guidField, dateField, CAST('12:48:12' AS TIME), timestampField FROM TestType";
ret = SQLExecDirect(stmt, request, SQL_NTS);
if (!SQL_SUCCEEDED(ret))
@@ -561,7 +567,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0008-0000-000000000009");
// Such format is used because Date returned as Timestamp.
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1987-06-05 00:00:00");
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1998-12-27 01:02:03");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "12:48:12");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[11])), "1998-12-27 01:02:03");
BOOST_CHECK_EQUAL(columnLens[0], 1);
BOOST_CHECK_EQUAL(columnLens[1], 1);
@@ -573,7 +580,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
BOOST_CHECK_EQUAL(columnLens[7], 1);
BOOST_CHECK_EQUAL(columnLens[8], 36);
BOOST_CHECK_EQUAL(columnLens[9], 19);
- BOOST_CHECK_EQUAL(columnLens[10], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 8);
+ BOOST_CHECK_EQUAL(columnLens[11], 19);
ret = SQLFetch(stmt);
BOOST_CHECK(ret == SQL_NO_DATA);
@@ -585,12 +593,12 @@ BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
SQLRETURN ret;
- TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
cache1.Put(1, in);
- const size_t columnsCnt = 11;
+ const size_t columnsCnt = 12;
SQLLEN columnLens[columnsCnt] = { 0 };
@@ -603,8 +611,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
- SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, guidField, dateField, timeField, timestampField FROM TestType";
ret = SQLExecDirect(stmt, request, SQL_NTS);
if (!SQL_SUCCEEDED(ret))
@@ -624,7 +632,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
BOOST_CHECK_EQUAL(columnLens[7], 1);
BOOST_CHECK_EQUAL(columnLens[8], 36);
BOOST_CHECK_EQUAL(columnLens[9], 19);
- BOOST_CHECK_EQUAL(columnLens[10], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 8);
+ BOOST_CHECK_EQUAL(columnLens[11], 19);
ret = SQLFetch(stmt);
BOOST_CHECK(ret == SQL_NO_DATA);
@@ -693,16 +702,16 @@ BOOST_AUTO_TEST_CASE(TestDataAtExecution)
SQLRETURN ret;
- TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
- TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), common::MakeDateGmt(1976, 1, 12),
- common::MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 999999999));
+ TestType in2(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDateGmt(1976, 1, 12),
+ MakeTimeGmt(0, 8, 59), MakeTimestampGmt(1978, 8, 21, 23, 13, 45, 999999999));
cache1.Put(1, in1);
cache1.Put(2, in2);
- const size_t columnsCnt = 11;
+ const size_t columnsCnt = 12;
SQLLEN columnLens[columnsCnt] = { 0 };
SQLCHAR columns[columnsCnt][ODBC_BUFFER_SIZE] = { 0 };
@@ -716,8 +725,8 @@ BOOST_AUTO_TEST_CASE(TestDataAtExecution)
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
}
- SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType "
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, guidField, dateField, timeField, timestampField FROM TestType "
"WHERE i32Field = ? AND strField = ?";
ret = SQLPrepare(stmt, request, SQL_NTS);
@@ -792,7 +801,8 @@ BOOST_AUTO_TEST_CASE(TestDataAtExecution)
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0008-0000-000000000009");
// Such format is used because Date returned as Timestamp.
BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1987-06-05 00:00:00");
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1998-12-27 01:02:03");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "12:48:12");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[11])), "1998-12-27 01:02:03");
BOOST_CHECK_EQUAL(columnLens[0], 1);
BOOST_CHECK_EQUAL(columnLens[1], 1);
@@ -804,7 +814,8 @@ BOOST_AUTO_TEST_CASE(TestDataAtExecution)
BOOST_CHECK_EQUAL(columnLens[7], 1);
BOOST_CHECK_EQUAL(columnLens[8], 36);
BOOST_CHECK_EQUAL(columnLens[9], 19);
- BOOST_CHECK_EQUAL(columnLens[10], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 8);
+ BOOST_CHECK_EQUAL(columnLens[11], 19);
ret = SQLFetch(stmt);
BOOST_CHECK(ret == SQL_NO_DATA);
@@ -816,8 +827,8 @@ BOOST_AUTO_TEST_CASE(TestNullFields)
SQLRETURN ret;
- TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), common::MakeDateGmt(1987, 6, 5),
- common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
+ TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDateGmt(1987, 6, 5),
+ MakeTimeGmt(12, 48, 12), MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
TestType inNull;
@@ -827,7 +838,7 @@ BOOST_AUTO_TEST_CASE(TestNullFields)
cache1.Put(2, inNull);
cache1.Put(3, in);
- const size_t columnsCnt = 10;
+ const size_t columnsCnt = 11;
SQLLEN columnLens[columnsCnt] = { 0 };
@@ -840,6 +851,7 @@ BOOST_AUTO_TEST_CASE(TestNullFields)
double doubleColumn;
bool boolColumn;
SQL_DATE_STRUCT dateColumn;
+ SQL_TIME_STRUCT timeColumn;
SQL_TIMESTAMP_STRUCT timestampColumn;
// Binding columns.
@@ -879,12 +891,17 @@ BOOST_AUTO_TEST_CASE(TestNullFields)
if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
- ret = SQLBindCol(stmt, 10, SQL_C_TIMESTAMP, ×tampColumn, 0, &columnLens[9]);
+ ret = SQLBindCol(stmt, 10, SQL_C_TIME, &timeColumn, 0, &columnLens[9]);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLBindCol(stmt, 11, SQL_C_TIMESTAMP, ×tampColumn, 0, &columnLens[10]);
if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
- SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
- "floatField, doubleField, boolField, dateField, timestampField FROM TestType ORDER BY _key";
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, floatField, "
+ "doubleField, boolField, dateField, timeField, timestampField FROM TestType "
+ "ORDER BY _key";
ret = SQLExecDirect(stmt, request, SQL_NTS);
if (!SQL_SUCCEEDED(ret))
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/sql_date_time_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_date_time_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_date_time_functions_test.cpp
index 157a011..c822fec 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_date_time_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_date_time_functions_test.cpp
@@ -32,26 +32,31 @@ BOOST_FIXTURE_TEST_SUITE(SqlDateTimeFunctionTestSuite, ignite::SqlTestSuiteFixtu
BOOST_AUTO_TEST_CASE(TestCurrentDate)
{
CheckSingleResult<Date>("SELECT {fn CURRENT_DATE()}");
+ CheckSingleResult<Timestamp>("SELECT {fn CURRENT_DATE()}");
}
BOOST_AUTO_TEST_CASE(TestCurdate)
{
CheckSingleResult<Date>("SELECT {fn CURDATE()}");
+ CheckSingleResult<Timestamp>("SELECT {fn CURDATE()}");
}
BOOST_AUTO_TEST_CASE(TestCurrentTime)
{
CheckSingleResult<Timestamp>("SELECT {fn CURRENT_TIME()}");
+ CheckSingleResult<Time>("SELECT {fn CURRENT_TIME()}");
}
BOOST_AUTO_TEST_CASE(TestCurtime)
{
CheckSingleResult<Timestamp>("SELECT {fn CURTIME()}");
+ CheckSingleResult<Time>("SELECT {fn CURTIME()}");
}
BOOST_AUTO_TEST_CASE(TestCurrentTimestamp)
{
CheckSingleResult<Timestamp>("SELECT {fn CURRENT_TIMESTAMP()}");
+ CheckSingleResult<Time>("SELECT {fn CURRENT_TIMESTAMP()}");
}
BOOST_AUTO_TEST_CASE(TestDayname)
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/sql_esc_convert_function_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_esc_convert_function_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_esc_convert_function_test.cpp
index 5dc2b58..6879519 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_esc_convert_function_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_esc_convert_function_test.cpp
@@ -143,11 +143,9 @@ BOOST_AUTO_TEST_CASE(TestEscConvertFunctionDate)
BOOST_AUTO_TEST_CASE(TestEscConvertFunctionTime)
{
- SQL_TIME_STRUCT exp;
- exp.hour = 13;
- exp.minute = 20;
- exp.second = 15;
- CheckSingleResult<SQL_TIME_STRUCT>("SELECT {fn CONVERT('13:20:15', SQL_TIME)}", exp);
+ using ignite::impl::binary::BinaryUtils;
+ Time time = common::MakeTimeGmt(13, 20, 15);
+ CheckSingleResult<Time>("SELECT {fn CONVERT('13:20:15', SQL_TIME)}", time);
}
BOOST_AUTO_TEST_CASE(TestEscConvertFunctionTimestamp)
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 400e9a9..03e4396 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
@@ -261,6 +261,14 @@ namespace ignite
}
template<>
+ void SqlTestSuiteFixture::CheckSingleResult<Time>(const char* request)
+ {
+ SQL_TIME_STRUCT res;
+
+ CheckSingleResult0(request, SQL_C_TIME, &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 };
@@ -298,30 +306,31 @@ namespace ignite
Date actual = common::MakeDateGmt(res.year, res.month, res.day);
BOOST_REQUIRE_EQUAL(actual.GetSeconds(), expected.GetSeconds());
}
-
+
template<>
- void SqlTestSuiteFixture::CheckSingleResult<SQL_TIME_STRUCT>(const char* request, const SQL_TIME_STRUCT& expected)
+ void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected)
{
- SQL_TIME_STRUCT res;
+ SQL_TIMESTAMP_STRUCT res;
- CheckSingleResult0(request, SQL_C_TIME, &res, 0, 0);
+ CheckSingleResult0(request, SQL_C_TIMESTAMP, &res, 0, 0);
- BOOST_REQUIRE_EQUAL(res.hour, expected.hour);
- BOOST_REQUIRE_EQUAL(res.minute, expected.minute);
- BOOST_REQUIRE_EQUAL(res.second, expected.second);
+ using ignite::impl::binary::BinaryUtils;
+ Timestamp actual = common::MakeTimestampGmt(res.year, res.month, res.day, res.hour, res.minute, res.second, res.fraction);
+
+ BOOST_REQUIRE_EQUAL(actual.GetSeconds(), expected.GetSeconds());
+ BOOST_REQUIRE_EQUAL(actual.GetSecondFraction(), expected.GetSecondFraction());
}
template<>
- void SqlTestSuiteFixture::CheckSingleResult<Timestamp>(const char* request, const Timestamp& expected)
+ void SqlTestSuiteFixture::CheckSingleResult<Time>(const char* request, const Time& expected)
{
- SQL_TIMESTAMP_STRUCT res;
+ SQL_TIME_STRUCT res;
- CheckSingleResult0(request, SQL_C_TIMESTAMP, &res, 0, 0);
+ CheckSingleResult0(request, SQL_C_TIME, &res, 0, 0);
using ignite::impl::binary::BinaryUtils;
- Timestamp actual = common::MakeTimestampGmt(res.year, res.month, res.day, res.hour, res.minute, res.second, res.fraction);
+ Time actual = common::MakeTimeGmt(res.hour, res.minute, res.second);
BOOST_REQUIRE_EQUAL(actual.GetSeconds(), expected.GetSeconds());
- BOOST_REQUIRE_EQUAL(actual.GetSecondFraction(), expected.GetSecondFraction());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 4c0f892..404fc6e 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
@@ -253,29 +253,22 @@ BOOST_AUTO_TEST_CASE(TestTimestampInsert)
BOOST_AUTO_TEST_CASE(TestTimeSelect)
{
- SQL_TIME_STRUCT ts;
- ts.hour = 19;
- ts.minute = 54;
- ts.second = 1;
-
TestType in1;
in1.i32Field = 1;
- in1.timestampField = common::MakeTimestampGmt(2017, 1, 13, ts.hour, ts.minute, ts.second);
+ in1.timeField = common::MakeTimeGmt(19, 54, 01);
testCache.Put(1, in1);
- CheckSingleResult<SQL_TIME_STRUCT>(
- "SELECT CAST(timestampField AS TIME) FROM TestType WHERE i32Field = 1", ts);
+ CheckSingleResult<int32_t>("SELECT i32Field FROM TestType WHERE timeField = '19:54:01'", in1.i32Field);
- CheckSingleResult<int32_t>(
- "SELECT i32Field FROM TestType WHERE CAST(timestampField AS TIME) = '19:54:01'", in1.i32Field);
+ CheckSingleResult<Time>("SELECT timeField FROM TestType WHERE i32Field = 1", in1.timeField);
}
-BOOST_AUTO_TEST_CASE(TestTimeInsertToTimestamp)
+BOOST_AUTO_TEST_CASE(TestTimeInsert)
{
SQLRETURN ret;
- SQLCHAR request[] = "INSERT INTO TestType(_key, timestampField) VALUES(?, ?)";
+ SQLCHAR request[] = "INSERT INTO TestType(_key, timeField) VALUES(?, ?)";
ret = SQLPrepare(stmt, request, SQL_NTS);
@@ -294,10 +287,10 @@ BOOST_AUTO_TEST_CASE(TestTimeInsertToTimestamp)
data.second = 1;
using ignite::impl::binary::BinaryUtils;
- Timestamp expected = common::MakeTimestampGmt(1970, 1, 1, data.hour, data.minute, data.second, 0);
+ Time expected = common::MakeTimeGmt(data.hour, data.minute, data.second);
SQLLEN lenInd = sizeof(data);
- ret = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TIMESTAMP, sizeof(data), 0, &data, sizeof(data), &lenInd);
+ ret = SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_TIME, SQL_TIME, sizeof(data), 0, &data, sizeof(data), &lenInd);
if (!SQL_SUCCEEDED(ret))
BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
@@ -309,8 +302,7 @@ BOOST_AUTO_TEST_CASE(TestTimeInsertToTimestamp)
TestType out = testCache.Get(key);
- BOOST_REQUIRE_EQUAL(out.timestampField.GetSeconds(), expected.GetSeconds());
- BOOST_REQUIRE_EQUAL(out.timestampField.GetSecondFraction(), expected.GetSecondFraction());
+ BOOST_REQUIRE_EQUAL(out.timeField.GetSeconds(), expected.GetSeconds());
}
BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc-test/src/test_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/test_utils.cpp b/modules/platforms/cpp/odbc-test/src/test_utils.cpp
index 89d50ef..6fceb03 100644
--- a/modules/platforms/cpp/odbc-test/src/test_utils.cpp
+++ b/modules/platforms/cpp/odbc-test/src/test_utils.cpp
@@ -51,6 +51,13 @@ namespace ignite_test
cfg.jvmOpts.push_back("-DIGNITE_CONSOLE_APPENDER=false");
cfg.jvmOpts.push_back("-DIGNITE_UPDATE_NOTIFIER=false");
+ std::string home;
+ bool homeFound = jni::ResolveIgniteHome("", home);
+
+ assert(homeFound);
+
+ cfg.jvmClassPath = jni::CreateIgniteHomeClasspath(home, true);
+
#ifdef IGNITE_TESTS_32
cfg.jvmInitMem = 256;
cfg.jvmMaxMem = 768;
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
index 18ac36a..31c2709 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
@@ -25,6 +25,7 @@
#include <ignite/guid.h>
#include <ignite/date.h>
#include <ignite/timestamp.h>
+#include <ignite/time.h>
#include <ignite/common/decimal.h>
#include "ignite/odbc/common_types.h"
@@ -182,6 +183,13 @@ namespace ignite
void PutTimestamp(const Timestamp& value);
/**
+ * Put time to buffer.
+ *
+ * @param value Value to put.
+ */
+ void PutTime(const Time& value);
+
+ /**
* Get string.
*
* @return String value of buffer.
@@ -252,6 +260,13 @@ namespace ignite
Timestamp GetTimestamp() const;
/**
+ * Get value of type Time.
+ *
+ * @return Value of type Timestamp.
+ */
+ Time GetTime() const;
+
+ /**
* Get value of type Decimal.
*
* @param val Result is placed here.
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
index a2bbd99..7061fc9 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
@@ -123,7 +123,7 @@ namespace ignite
*
* @param cache Cache name.
* @param sql SQL query.
- * @param argsNum Number of arguments.
+ * @param params Query arguments.
*/
QueryExecuteRequest(const std::string& cache, const std::string& sql,
const app::ParameterBindingMap& params) :
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h b/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
index a57abdd..d456d59 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/type_traits.h
@@ -151,6 +151,9 @@ namespace ignite
/** TIMESTAMP SQL type name constant. */
static const std::string TIMESTAMP;
+ /** TIME SQL type name constant. */
+ static const std::string TIME;
+
/** GUID SQL type name constant. */
static const std::string GUID;
};
@@ -190,7 +193,7 @@ namespace ignite
/**
* Convert ODBC type to driver type alias.
*
- * @param ODBC type;
+ * @param type ODBC type;
* @return Internal driver type.
*/
IgniteSqlType ToDriverType(int16_t type);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
index 026cd60..1b5f536 100644
--- a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
+++ b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
@@ -229,6 +229,13 @@ namespace ignite
break;
}
+ case IGNITE_ODBC_C_TYPE_TTIME:
+ {
+ PutTime(Time(static_cast<int64_t>(value)));
+
+ break;
+ }
+
default:
{
if (resLenPtr)
@@ -934,6 +941,127 @@ namespace ignite
}
}
+ void ApplicationDataBuffer::PutTime(const Time& value)
+ {
+ using namespace type_traits;
+
+ tm tmTime;
+
+ common::TimeToCTm(value, tmTime);
+
+ SqlLen* resLenPtr = GetResLen();
+ void* dataPtr = GetData();
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ char* buffer = reinterpret_cast<char*>(dataPtr);
+
+ if (buffer)
+ {
+ strftime(buffer, GetSize(), "%H:%M:%S", &tmTime);
+
+ if (resLenPtr)
+ *resLenPtr = strlen(buffer);
+ }
+ else if (resLenPtr)
+ *resLenPtr = sizeof("HH:MM:SS") - 1;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_WCHAR:
+ {
+ SQLWCHAR* buffer = reinterpret_cast<SQLWCHAR*>(dataPtr);
+
+ if (buffer)
+ {
+ std::string tmp(GetSize(), 0);
+
+ strftime(&tmp[0], GetSize(), "%H:%M:%S", &tmTime);
+
+ SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());
+
+ for (SqlLen i = 0; i < toCopy; ++i)
+ buffer[i] = tmp[i];
+
+ buffer[toCopy] = 0;
+
+ if (resLenPtr)
+ *resLenPtr = toCopy;
+ }
+ else if (resLenPtr)
+ *resLenPtr = sizeof("HH:MM:SS") - 1;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_TTIME:
+ {
+ SQL_TIME_STRUCT* buffer = reinterpret_cast<SQL_TIME_STRUCT*>(dataPtr);
+
+ buffer->hour = tmTime.tm_hour;
+ buffer->minute = tmTime.tm_min;
+ buffer->second = tmTime.tm_sec;
+
+ if (resLenPtr)
+ *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIME_STRUCT));
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_TTIMESTAMP:
+ {
+ SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(dataPtr);
+
+ buffer->year = tmTime.tm_year + 1900;
+ buffer->month = tmTime.tm_mon + 1;
+ buffer->day = tmTime.tm_mday;
+ buffer->hour = tmTime.tm_hour;
+ buffer->minute = tmTime.tm_min;
+ buffer->second = tmTime.tm_sec;
+ buffer->fraction = 0;
+
+ if (resLenPtr)
+ *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIMESTAMP_STRUCT));
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_BINARY:
+ case IGNITE_ODBC_C_TYPE_DEFAULT:
+ {
+ if (dataPtr)
+ memcpy(dataPtr, &value, std::min(static_cast<size_t>(buflen), sizeof(value)));
+
+ if (resLenPtr)
+ *resLenPtr = sizeof(value);
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_BIT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_TINYINT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_SHORT:
+ case IGNITE_ODBC_C_TYPE_SIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_LONG:
+ case IGNITE_ODBC_C_TYPE_SIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_UNSIGNED_BIGINT:
+ case IGNITE_ODBC_C_TYPE_FLOAT:
+ case IGNITE_ODBC_C_TYPE_DOUBLE:
+ case IGNITE_ODBC_C_TYPE_NUMERIC:
+ case IGNITE_ODBC_C_TYPE_TDATE:
+ default:
+ {
+ if (resLenPtr)
+ *resLenPtr = SQL_NO_TOTAL;
+ }
+ }
+ }
+
std::string ApplicationDataBuffer::GetString(size_t maxLen) const
{
using namespace type_traits;
@@ -1385,6 +1513,62 @@ namespace ignite
return common::CTmToTimestamp(tmTime, nanos);
}
+ Time ApplicationDataBuffer::GetTime() const
+ {
+ using namespace type_traits;
+
+ tm tmTime = { 0 };
+
+ tmTime.tm_year = 70;
+ tmTime.tm_mon = 0;
+ tmTime.tm_mday = 1;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_TTIME:
+ {
+ const SQL_TIME_STRUCT* buffer = reinterpret_cast<const SQL_TIME_STRUCT*>(GetData());
+
+ tmTime.tm_hour = buffer->hour;
+ tmTime.tm_min = buffer->minute;
+ tmTime.tm_sec = buffer->second;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_TTIMESTAMP:
+ {
+ const SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<const SQL_TIMESTAMP_STRUCT*>(GetData());
+
+ tmTime.tm_hour = buffer->hour;
+ tmTime.tm_min = buffer->minute;
+ tmTime.tm_sec = buffer->second;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ SqlLen paramLen = GetInputSize();
+
+ if (!paramLen)
+ break;
+
+ std::string str = utility::SqlStringToString(
+ reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));
+
+ sscanf(str.c_str(), "%d:%d:%d", &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return common::CTmToTime(tmTime);
+ }
+
void ApplicationDataBuffer::GetDecimal(common::Decimal& val) const
{
using namespace type_traits;
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/src/app/parameter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/parameter.cpp b/modules/platforms/cpp/odbc/src/app/parameter.cpp
index ded2e4b..d351e29 100644
--- a/modules/platforms/cpp/odbc/src/app/parameter.cpp
+++ b/modules/platforms/cpp/odbc/src/app/parameter.cpp
@@ -164,6 +164,13 @@ namespace ignite
break;
}
+ case SQL_TYPE_TIME:
+ case SQL_TIME:
+ {
+ writer.WriteTime(buf.GetTime());
+ break;
+ }
+
case SQL_BINARY:
case SQL_VARBINARY:
case SQL_LONGVARBINARY:
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/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 0ec8078..e20c7a8 100644
--- a/modules/platforms/cpp/odbc/src/column.cpp
+++ b/modules/platforms/cpp/odbc/src/column.cpp
@@ -282,6 +282,15 @@ namespace ignite
break;
}
+ case IGNITE_TYPE_TIME:
+ {
+ reader.ReadTime();
+
+ sizeTmp = 8;
+
+ break;
+ }
+
case IGNITE_TYPE_TIMESTAMP:
{
reader.ReadTimestamp();
@@ -305,6 +314,7 @@ namespace ignite
default:
{
// This is a fail case.
+ std::cout << (int)hdr << std::endl;
assert(false);
return;
}
@@ -485,6 +495,15 @@ namespace ignite
break;
}
+ case IGNITE_TYPE_TIME:
+ {
+ Time time = reader.ReadTime();
+
+ dataBuf.PutTime(time);
+
+ break;
+ }
+
case IGNITE_TYPE_ARRAY_BYTE:
{
stream->Position(startPos + offset);
http://git-wip-us.apache.org/repos/asf/ignite/blob/612e92ac/modules/platforms/cpp/odbc/src/type_traits.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/type_traits.cpp b/modules/platforms/cpp/odbc/src/type_traits.cpp
index 643e1b4..e4ce10f 100644
--- a/modules/platforms/cpp/odbc/src/type_traits.cpp
+++ b/modules/platforms/cpp/odbc/src/type_traits.cpp
@@ -59,6 +59,8 @@ namespace ignite
const std::string SqlTypeName::TIMESTAMP("TIMESTAMP");
+ const std::string SqlTypeName::TIME("TIME");
+
const std::string SqlTypeName::GUID("GUID");
#ifdef ODBC_DEBUG
@@ -154,6 +156,9 @@ namespace ignite
case IGNITE_TYPE_TIMESTAMP:
return SqlTypeName::TIMESTAMP;
+ case IGNITE_TYPE_TIME:
+ return SqlTypeName::TIME;
+
case IGNITE_TYPE_OBJECT:
case IGNITE_TYPE_ARRAY_BYTE:
case IGNITE_TYPE_ARRAY_SHORT:
@@ -206,6 +211,7 @@ namespace ignite
case SQL_DECIMAL:
case SQL_TYPE_DATE:
case SQL_TYPE_TIMESTAMP:
+ case SQL_TYPE_TIME:
return true;
case SQL_WCHAR:
@@ -213,7 +219,6 @@ namespace ignite
case SQL_WLONGVARCHAR:
case SQL_REAL:
case SQL_NUMERIC:
- case SQL_TYPE_TIME:
case SQL_INTERVAL_MONTH:
case SQL_INTERVAL_YEAR:
case SQL_INTERVAL_YEAR_TO_MONTH:
@@ -281,6 +286,9 @@ namespace ignite
case SQL_TYPE_TIMESTAMP:
return IGNITE_TYPE_TIMESTAMP;
+ case SQL_TYPE_TIME:
+ return IGNITE_TYPE_TIME;
+
default:
break;
}
@@ -402,6 +410,9 @@ namespace ignite
case IGNITE_TYPE_TIMESTAMP:
return SQL_TYPE_TIMESTAMP;
+ case IGNITE_TYPE_TIME:
+ return SQL_TYPE_TIME;
+
case IGNITE_TYPE_ARRAY_BYTE:
case IGNITE_TYPE_ARRAY_SHORT:
case IGNITE_TYPE_ARRAY_INT: