From 83ac8604b5d49790f449367c81b39399fcb0a027 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 28 Oct 2022 22:37:58 +0800 Subject: [PATCH] fix inconsistent result before deleting some rows (#6133) (#6142) close pingcap/tiflash#6127 --- dbms/src/Functions/FunctionsLogical.h | 6 ++--- dbms/src/Functions/tests/gtest_logical.cpp | 28 ++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/dbms/src/Functions/FunctionsLogical.h b/dbms/src/Functions/FunctionsLogical.h index 0adfd699b7e..ef508ced229 100644 --- a/dbms/src/Functions/FunctionsLogical.h +++ b/dbms/src/Functions/FunctionsLogical.h @@ -151,7 +151,7 @@ struct NotImpl { using ResultType = UInt8; - static inline UInt8 apply(A a) + static inline bool apply(A a) { return !a; } @@ -194,7 +194,7 @@ struct AssociativeOperationImpl {} /// Returns a combination of values in the i-th row of all columns stored in the constructor. - inline UInt8 apply(size_t i) const + inline bool apply(size_t i) const { if (Op::isSaturable()) { @@ -238,7 +238,7 @@ struct AssociativeOperationImpl : vec(in[in.size() - 1]->getData()) {} - inline UInt8 apply(size_t i) const + inline bool apply(size_t i) const { return vec[i]; } diff --git a/dbms/src/Functions/tests/gtest_logical.cpp b/dbms/src/Functions/tests/gtest_logical.cpp index a5bde6ccd2d..b4e9fb7541f 100644 --- a/dbms/src/Functions/tests/gtest_logical.cpp +++ b/dbms/src/Functions/tests/gtest_logical.cpp @@ -58,6 +58,20 @@ try func_name, createOnlyNullColumnConst(2), createColumn>({1, 0}))); + // issue 6127 + ASSERT_COLUMN_EQ( + createColumn({0, 1, 0, 0}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); + // issue 6127, position of UInt8 column may affect the result + ASSERT_COLUMN_EQ( + createColumn({0, 1, 0, 0}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); } CATCH @@ -73,13 +87,6 @@ try func_name, createColumn>({0, 1, 0, 1, {}, 0}), createColumn>({0, 1, 1, 0, 1, {}}))); - // issue 5849 - ASSERT_COLUMN_EQ( - createColumn({0, 1, 1, 1}), - executeFunction( - func_name, - createColumn({0, 123, 0, 41}), - createColumn({0, 11, 221, 0}))); // column, const ASSERT_COLUMN_EQ( createColumn>({1, 1}), @@ -101,6 +108,13 @@ try func_name, createOnlyNullColumnConst(2), createColumn>({1, 0}))); + // issue 5849 + ASSERT_COLUMN_EQ( + createColumn({0, 1, 1, 1}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); } CATCH