From 69ba035488c225b507f51fba63665b86554b5eb1 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 9 Aug 2014 06:29:03 +0400 Subject: [PATCH] dbms: fixed error with function negate on UInt32 [#METR-2944]. --- dbms/include/DB/Functions/FunctionsArithmetic.h | 2 +- dbms/tests/queries/0_stateless/00064_negate_bug.reference | 1 + dbms/tests/queries/0_stateless/00064_negate_bug.sql | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00064_negate_bug.reference create mode 100644 dbms/tests/queries/0_stateless/00064_negate_bug.sql diff --git a/dbms/include/DB/Functions/FunctionsArithmetic.h b/dbms/include/DB/Functions/FunctionsArithmetic.h index 7996d8f5818..45c6834f316 100644 --- a/dbms/include/DB/Functions/FunctionsArithmetic.h +++ b/dbms/include/DB/Functions/FunctionsArithmetic.h @@ -221,7 +221,7 @@ struct NegateImpl static inline ResultType apply(A a) { - return -a; + return -static_cast(a); } }; diff --git a/dbms/tests/queries/0_stateless/00064_negate_bug.reference b/dbms/tests/queries/0_stateless/00064_negate_bug.reference new file mode 100644 index 00000000000..601e8c52f8b --- /dev/null +++ b/dbms/tests/queries/0_stateless/00064_negate_bug.reference @@ -0,0 +1 @@ +-1 Int64 diff --git a/dbms/tests/queries/0_stateless/00064_negate_bug.sql b/dbms/tests/queries/0_stateless/00064_negate_bug.sql new file mode 100644 index 00000000000..ba076770168 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00064_negate_bug.sql @@ -0,0 +1 @@ +SELECT -toUInt32(1) AS x, toTypeName(x) AS t