From 38d2e9efa27cad08da69817a6d313405acb66ae4 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 20 Nov 2018 20:36:21 +0300 Subject: [PATCH 1/2] Fixed code that was not quite correct --- dbms/src/Core/Field.h | 62 ++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/dbms/src/Core/Field.h b/dbms/src/Core/Field.h index 6e07e1387f8..ce0e7560bd1 100644 --- a/dbms/src/Core/Field.h +++ b/dbms/src/Core/Field.h @@ -580,36 +580,44 @@ template <> struct TypeName { static std::string get() { return "Tuple"; template struct NearestFieldType; -template <> struct NearestFieldType { using Type = UInt64; }; -template <> struct NearestFieldType { using Type = UInt64; }; -template <> struct NearestFieldType { using Type = UInt64; }; -template <> struct NearestFieldType { using Type = UInt64; }; -#ifdef __APPLE__ -template <> struct NearestFieldType { using Type = UInt64; }; -template <> struct NearestFieldType { using Type = UInt64; }; -#endif -template <> struct NearestFieldType { using Type = UInt64; }; +/// char may be signed or unsigned, and behave identically that signed char or unsigned char, +/// but they are always three different types. +/// signedness of char is different in Linux on Intel and Linux on ARM. +template <> struct NearestFieldType { using Type = std::conditional_t, Int64, UInt64>; }; +template <> struct NearestFieldType { using Type = Int64; }; +template <> struct NearestFieldType { using Type = UInt64; }; + +template <> struct NearestFieldType { using Type = UInt64; }; +template <> struct NearestFieldType { using Type = UInt64; }; + +template <> struct NearestFieldType { using Type = UInt64; }; template <> struct NearestFieldType { using Type = UInt128; }; -template <> struct NearestFieldType { using Type = UInt128; }; -template <> struct NearestFieldType { using Type = Int64; }; -template <> struct NearestFieldType { using Type = Int64; }; -template <> struct NearestFieldType { using Type = Int64; }; -template <> struct NearestFieldType { using Type = Int64; }; -template <> struct NearestFieldType { using Type = Int128; }; -template <> struct NearestFieldType { using Type = DecimalField; }; -template <> struct NearestFieldType { using Type = DecimalField; }; -template <> struct NearestFieldType { using Type = DecimalField; }; -template <> struct NearestFieldType> { using Type = DecimalField; }; -template <> struct NearestFieldType> { using Type = DecimalField; }; -template <> struct NearestFieldType> { using Type = DecimalField; }; +template <> struct NearestFieldType { using Type = UInt128; }; +template <> struct NearestFieldType { using Type = Int64; }; +template <> struct NearestFieldType { using Type = Int64; }; + +/// long and long long are always different types that may behave identically or not. +/// This is different on Linux and Mac. +template <> struct NearestFieldType { using Type = Int64; }; +template <> struct NearestFieldType { using Type = Int64; }; +template <> struct NearestFieldType { using Type = UInt64; }; +template <> struct NearestFieldType { using Type = UInt64; }; + +template <> struct NearestFieldType { using Type = Int128; }; +template <> struct NearestFieldType { using Type = DecimalField; }; +template <> struct NearestFieldType { using Type = DecimalField; }; +template <> struct NearestFieldType { using Type = DecimalField; }; +template <> struct NearestFieldType> { using Type = DecimalField; }; +template <> struct NearestFieldType> { using Type = DecimalField; }; +template <> struct NearestFieldType> { using Type = DecimalField; }; template <> struct NearestFieldType { using Type = Float64; }; template <> struct NearestFieldType { using Type = Float64; }; -template <> struct NearestFieldType { using Type = String; }; -template <> struct NearestFieldType { using Type = String; }; -template <> struct NearestFieldType { using Type = Array; }; -template <> struct NearestFieldType { using Type = Tuple; }; -template <> struct NearestFieldType { using Type = UInt64; }; -template <> struct NearestFieldType { using Type = Null; }; +template <> struct NearestFieldType { using Type = String; }; +template <> struct NearestFieldType { using Type = String; }; +template <> struct NearestFieldType { using Type = Array; }; +template <> struct NearestFieldType { using Type = Tuple; }; +template <> struct NearestFieldType { using Type = UInt64; }; +template <> struct NearestFieldType { using Type = Null; }; template decltype(auto) nearestFieldType(T && x) From 98ed411da35111e71b3e61efc0ea3af7e9db6ccd Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Tue, 20 Nov 2018 20:37:50 +0300 Subject: [PATCH 2/2] Update Field.h --- dbms/src/Core/Field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbms/src/Core/Field.h b/dbms/src/Core/Field.h index ce0e7560bd1..33f18a22e36 100644 --- a/dbms/src/Core/Field.h +++ b/dbms/src/Core/Field.h @@ -580,9 +580,9 @@ template <> struct TypeName { static std::string get() { return "Tuple"; template struct NearestFieldType; -/// char may be signed or unsigned, and behave identically that signed char or unsigned char, +/// char may be signed or unsigned, and behave identically to signed char or unsigned char, /// but they are always three different types. -/// signedness of char is different in Linux on Intel and Linux on ARM. +/// signedness of char is different in Linux on x86 and Linux on ARM. template <> struct NearestFieldType { using Type = std::conditional_t, Int64, UInt64>; }; template <> struct NearestFieldType { using Type = Int64; }; template <> struct NearestFieldType { using Type = UInt64; };