From 90d323a5222f2cd3a64d1f94df325693d01bba37 Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Thu, 14 Jun 2018 11:11:41 +0200 Subject: [PATCH] types: add time_native_type CQL3's time_type didn't have any suitable native type, so time_native_type is introduced to serve that purpose. --- types.cc | 3 +++ types.hh | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/types.cc b/types.cc index aca7c56341..61c6ec7231 100644 --- a/types.cc +++ b/types.cc @@ -3720,6 +3720,9 @@ data_value::data_value(simple_date_native_type v) : data_value(make_new(simple_d data_value::data_value(timestamp_native_type v) : data_value(make_new(timestamp_type, v.tp)) { } +data_value::data_value(time_native_type v) : data_value(make_new(time_type, v.nanoseconds)) { +} + data_value::data_value(timeuuid_native_type v) : data_value(make_new(timeuuid_type, v.uuid)) { } diff --git a/types.hh b/types.hh index 45c78561be..5a8bb64389 100644 --- a/types.hh +++ b/types.hh @@ -328,6 +328,11 @@ struct timestamp_native_type { primary_type tp; }; +struct time_native_type { + using primary_type = int64_t; + primary_type nanoseconds; +}; + struct timeuuid_native_type { using primary_type = utils::UUID; primary_type uuid; @@ -371,6 +376,7 @@ public: data_value(seastar::net::inet_address); data_value(simple_date_native_type); data_value(timestamp_native_type); + data_value(time_native_type); data_value(timeuuid_native_type); data_value(db_clock::time_point); data_value(boost::multiprecision::cpp_int); @@ -1285,6 +1291,12 @@ shared_ptr data_type_for() { return timestamp_type; } +template <> +inline +shared_ptr data_type_for() { + return time_type; +} + template <> inline shared_ptr data_type_for() {